mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-28 12:35:21 +00:00
Rename and move wait for headscale
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
cb87852825
commit
456479eaa1
@ -40,7 +40,7 @@ func TestNamespaceCommand(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
var listNamespaces []v1.Namespace
|
var listNamespaces []v1.Namespace
|
||||||
err = executeAndUnmarshal(scenario.Headscale(),
|
err = executeAndUnmarshal(scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"namespaces",
|
"namespaces",
|
||||||
@ -61,7 +61,7 @@ func TestNamespaceCommand(t *testing.T) {
|
|||||||
result,
|
result,
|
||||||
)
|
)
|
||||||
|
|
||||||
_, err = scenario.Headscale().Execute(
|
_, err = scenario.MustHeadscale().Execute(
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"namespaces",
|
"namespaces",
|
||||||
@ -75,7 +75,7 @@ func TestNamespaceCommand(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
var listAfterRenameNamespaces []v1.Namespace
|
var listAfterRenameNamespaces []v1.Namespace
|
||||||
err = executeAndUnmarshal(scenario.Headscale(),
|
err = executeAndUnmarshal(scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"namespaces",
|
"namespaces",
|
||||||
@ -123,7 +123,7 @@ func TestPreAuthKeyCommand(t *testing.T) {
|
|||||||
for index := 0; index < count; index++ {
|
for index := 0; index < count; index++ {
|
||||||
var preAuthKey v1.PreAuthKey
|
var preAuthKey v1.PreAuthKey
|
||||||
err := executeAndUnmarshal(
|
err := executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -149,7 +149,7 @@ func TestPreAuthKeyCommand(t *testing.T) {
|
|||||||
|
|
||||||
var listedPreAuthKeys []v1.PreAuthKey
|
var listedPreAuthKeys []v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -202,7 +202,7 @@ func TestPreAuthKeyCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test key expiry
|
// Test key expiry
|
||||||
_, err = scenario.Headscale().Execute(
|
_, err = scenario.MustHeadscale().Execute(
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -216,7 +216,7 @@ func TestPreAuthKeyCommand(t *testing.T) {
|
|||||||
|
|
||||||
var listedPreAuthKeysAfterExpire []v1.PreAuthKey
|
var listedPreAuthKeysAfterExpire []v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -256,7 +256,7 @@ func TestPreAuthKeyCommandWithoutExpiry(t *testing.T) {
|
|||||||
|
|
||||||
var preAuthKey v1.PreAuthKey
|
var preAuthKey v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -273,7 +273,7 @@ func TestPreAuthKeyCommandWithoutExpiry(t *testing.T) {
|
|||||||
|
|
||||||
var listedPreAuthKeys []v1.PreAuthKey
|
var listedPreAuthKeys []v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -318,7 +318,7 @@ func TestPreAuthKeyCommandReusableEphemeral(t *testing.T) {
|
|||||||
|
|
||||||
var preAuthReusableKey v1.PreAuthKey
|
var preAuthReusableKey v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -335,7 +335,7 @@ func TestPreAuthKeyCommandReusableEphemeral(t *testing.T) {
|
|||||||
|
|
||||||
var preAuthEphemeralKey v1.PreAuthKey
|
var preAuthEphemeralKey v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
@ -355,7 +355,7 @@ func TestPreAuthKeyCommandReusableEphemeral(t *testing.T) {
|
|||||||
|
|
||||||
var listedPreAuthKeys []v1.PreAuthKey
|
var listedPreAuthKeys []v1.PreAuthKey
|
||||||
err = executeAndUnmarshal(
|
err = executeAndUnmarshal(
|
||||||
scenario.Headscale(),
|
scenario.MustHeadscale(),
|
||||||
[]string{
|
[]string{
|
||||||
"headscale",
|
"headscale",
|
||||||
"preauthkeys",
|
"preauthkeys",
|
||||||
|
@ -156,12 +156,19 @@ func (s *Scenario) StartHeadscale(opts ...hsic.Option) error {
|
|||||||
return fmt.Errorf("failed to create headscale container: %w", err)
|
return fmt.Errorf("failed to create headscale container: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = headscale.WaitForReady()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
s.controlServers["headscale"] = headscale
|
s.controlServers["headscale"] = headscale
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scenario) Headscale() *hsic.HeadscaleInContainer {
|
// MustHeadscale returns the headscale unit of a scenario, it will crash if it
|
||||||
|
// is not available.
|
||||||
|
func (s *Scenario) MustHeadscale() *hsic.HeadscaleInContainer {
|
||||||
//nolint
|
//nolint
|
||||||
return s.controlServers["headscale"].(*hsic.HeadscaleInContainer)
|
return s.controlServers["headscale"].(*hsic.HeadscaleInContainer)
|
||||||
}
|
}
|
||||||
@ -220,8 +227,8 @@ func (s *Scenario) CreateTailscaleNodesInNamespace(
|
|||||||
s.pool,
|
s.pool,
|
||||||
version,
|
version,
|
||||||
s.network,
|
s.network,
|
||||||
tsic.WithHeadscaleTLS(s.Headscale().GetCert()),
|
tsic.WithHeadscaleTLS(s.MustHeadscale().GetCert()),
|
||||||
tsic.WithHeadscaleName(s.Headscale().GetHostname()),
|
tsic.WithHeadscaleName(s.MustHeadscale().GetHostname()),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// return fmt.Errorf("failed to add tailscale node: %w", err)
|
// return fmt.Errorf("failed to add tailscale node: %w", err)
|
||||||
@ -312,11 +319,6 @@ func (s *Scenario) CreateHeadscaleEnv(namespaces map[string]int, opts ...hsic.Op
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.Headscale().WaitForReady()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for namespaceName, clientCount := range namespaces {
|
for namespaceName, clientCount := range namespaces {
|
||||||
err = s.CreateNamespace(namespaceName)
|
err = s.CreateNamespace(namespaceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -333,7 +335,7 @@ func (s *Scenario) CreateHeadscaleEnv(namespaces map[string]int, opts ...hsic.Op
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.RunTailscaleUp(namespaceName, s.Headscale().GetEndpoint(), key.GetKey())
|
err = s.RunTailscaleUp(namespaceName, s.MustHeadscale().GetEndpoint(), key.GetKey())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func TestHeadscale(t *testing.T) {
|
|||||||
t.Errorf("failed to create start headcale: %s", err)
|
t.Errorf("failed to create start headcale: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = scenario.Headscale().WaitForReady()
|
err = scenario.MustHeadscale().WaitForReady()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("headscale failed to become ready: %s", err)
|
t.Errorf("headscale failed to become ready: %s", err)
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ func TestTailscaleNodesJoiningHeadcale(t *testing.T) {
|
|||||||
t.Errorf("failed to create start headcale: %s", err)
|
t.Errorf("failed to create start headcale: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
headscale := scenario.Headscale()
|
headscale := scenario.MustHeadscale()
|
||||||
err = headscale.WaitForReady()
|
err = headscale.WaitForReady()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("headscale failed to become ready: %s", err)
|
t.Errorf("headscale failed to become ready: %s", err)
|
||||||
@ -157,7 +157,7 @@ func TestTailscaleNodesJoiningHeadcale(t *testing.T) {
|
|||||||
t.Errorf("failed to create preauthkey: %s", err)
|
t.Errorf("failed to create preauthkey: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = scenario.RunTailscaleUp(namespace, scenario.Headscale().GetEndpoint(), key.GetKey())
|
err = scenario.RunTailscaleUp(namespace, scenario.MustHeadscale().GetEndpoint(), key.GetKey())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to login: %s", err)
|
t.Errorf("failed to login: %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user