mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
Lint fix integration tests
This commit is contained in:
parent
85f28a3f4a
commit
ba084b9987
3 changed files with 13 additions and 6 deletions
|
@ -88,6 +88,7 @@ func (s *IntegrationCLITestSuite) SetupTest() {
|
|||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("status code not OK")
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
// TODO(kradalby): If we cannot access headscale, or any other fatal error during
|
||||
|
@ -147,7 +148,6 @@ func (s *IntegrationCLITestSuite) TestNamespaceCommand() {
|
|||
namespaces := make([]*v1.Namespace, len(names))
|
||||
|
||||
for index, namespaceName := range names {
|
||||
|
||||
namespace, err := s.createNamespace(namespaceName)
|
||||
assert.Nil(s.T(), err)
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"github.com/ory/dockertest/v3/docker"
|
||||
)
|
||||
|
||||
const DOCKER_EXECUTE_TIMEOUT = 10 * time.Second
|
||||
|
||||
func ExecuteCommand(
|
||||
resource *dockertest.Resource,
|
||||
cmd []string,
|
||||
|
@ -21,7 +23,7 @@ func ExecuteCommand(
|
|||
var stderr bytes.Buffer
|
||||
|
||||
// TODO(kradalby): Make configurable
|
||||
timeout := 10 * time.Second
|
||||
timeout := DOCKER_EXECUTE_TIMEOUT
|
||||
|
||||
type result struct {
|
||||
exitCode int
|
||||
|
@ -55,11 +57,13 @@ func ExecuteCommand(
|
|||
fmt.Println("Command: ", cmd)
|
||||
fmt.Println("stdout: ", stdout.String())
|
||||
fmt.Println("stderr: ", stderr.String())
|
||||
|
||||
return "", fmt.Errorf("command failed with: %s", stderr.String())
|
||||
}
|
||||
|
||||
return stdout.String(), nil
|
||||
case <-time.After(timeout):
|
||||
|
||||
return "", fmt.Errorf("command timed out after %s", timeout)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,9 @@ import (
|
|||
"github.com/ory/dockertest/v3/docker"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/client/tailscale/apitype"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
|
||||
"inet.af/netaddr"
|
||||
)
|
||||
|
||||
var tailscaleVersions = []string{"1.16.2", "1.14.3", "1.12.3"}
|
||||
|
@ -180,6 +179,7 @@ func (s *IntegrationTestSuite) tailscaleContainer(
|
|||
log.Fatalf("Could not start resource: %s", err)
|
||||
}
|
||||
fmt.Printf("Created %s container\n", hostname)
|
||||
|
||||
return hostname, pts
|
||||
}
|
||||
|
||||
|
@ -248,13 +248,16 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||
|
||||
if err := s.pool.Retry(func() error {
|
||||
url := fmt.Sprintf("http://%s/health", hostEndpoint)
|
||||
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("status code not OK")
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
// TODO(kradalby): If we cannot access headscale, or any other fatal error during
|
||||
|
@ -507,7 +510,6 @@ func (s *IntegrationTestSuite) TestSharedNodes() {
|
|||
assert.Nil(s.T(), err)
|
||||
|
||||
for _, machine := range machineList {
|
||||
|
||||
result, err := ExecuteCommand(
|
||||
&s.headscale,
|
||||
[]string{
|
||||
|
@ -607,7 +609,6 @@ func (s *IntegrationTestSuite) TestTailDrop() {
|
|||
for peername, ip := range ips {
|
||||
s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) {
|
||||
if peername != hostname {
|
||||
|
||||
// Under normal circumstances, we should be able to send a file
|
||||
// using `tailscale file cp` - but not in userspace networking mode
|
||||
// So curl!
|
||||
|
@ -770,6 +771,7 @@ func getIPs(tailscales map[string]dockertest.Resource) (map[string]netaddr.IP, e
|
|||
|
||||
ips[hostname] = ip
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
|
@ -809,5 +811,6 @@ func getAPIURLs(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fts, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue