Skip to content

Commit

Permalink
Up client count, make arguments more explicit and clean up unused ass…
Browse files Browse the repository at this point in the history
…ignments
  • Loading branch information
kradalby committed Aug 18, 2021
1 parent 7d1a5c0 commit 6fa6138
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var ih Headscale
var pool dockertest.Pool
var network dockertest.Network
var headscale dockertest.Resource
var tailscaleCount int = 5
var tailscaleCount int = 20
var tailscales map[string]dockertest.Resource

func executeCommand(resource *dockertest.Resource, cmd []string) (string, error) {
Expand Down Expand Up @@ -115,7 +115,6 @@ func (s *IntegrationTestSuite) SetupSuite() {
PortBindings: map[docker.Port][]docker.PortBinding{
"8080/tcp": []docker.PortBinding{{HostPort: "8080"}},
},
Env: []string{},
}

fmt.Println("Creating headscale container")
Expand All @@ -134,7 +133,6 @@ func (s *IntegrationTestSuite) SetupSuite() {
Name: hostname,
Networks: []*dockertest.Network{&network},
Cmd: []string{"tailscaled", "--tun=userspace-networking", "--socks5-server=localhost:1055"},
Env: []string{},
}

if pts, err := pool.BuildAndRunWithBuildOptions(tailscaleBuildOptions, tailscaleOptions, dockerRestartPolicy); err == nil {
Expand All @@ -145,7 +143,6 @@ func (s *IntegrationTestSuite) SetupSuite() {
fmt.Printf("Created %s container\n", hostname)
}

// TODO: Replace this logic with something that can be detected on Github Actions
fmt.Println("Waiting for headscale to be ready")
hostEndpoint := fmt.Sprintf("localhost:%s", headscale.GetPort("8080/tcp"))

Expand Down Expand Up @@ -197,20 +194,20 @@ func (s *IntegrationTestSuite) SetupSuite() {

// The nodes need a bit of time to get their updated maps from headscale
// TODO: See if we can have a more deterministic wait here.
time.Sleep(20 * time.Second)
time.Sleep(120 * time.Second)
}

func (s *IntegrationTestSuite) TearDownSuite() {
if err := pool.Purge(&headscale); err != nil {
log.Printf("Could not purge resource: %s\n", err)
}

for _, tailscale := range tailscales {
if err := pool.Purge(&tailscale); err != nil {
log.Printf("Could not purge resource: %s\n", err)
}
}

if err := pool.Purge(&headscale); err != nil {
log.Printf("Could not purge resource: %s\n", err)
}

if err := network.Close(); err != nil {
log.Printf("Could not close network: %s\n", err)
}
Expand Down Expand Up @@ -295,7 +292,15 @@ func (s *IntegrationTestSuite) TestPingAllPeers() {
s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) {
// We currently cant ping ourselves, so skip that.
if peername != hostname {
command := []string{"tailscale", "ping", "--timeout=5s", "--c=1", ip.String()}
// We are only interested in "direct ping" which means what we
// might need a couple of more attempts before reaching the node.
command := []string{
"tailscale", "ping",
"--timeout=1s",
"--c=20",
"--until-direct=true",
ip.String(),
}

fmt.Printf("Pinging from %s (%s) to %s (%s)\n", hostname, ips[hostname], peername, ip)
result, err := executeCommand(
Expand Down

0 comments on commit 6fa6138

Please sign in to comment.