Skip to content

Commit

Permalink
give ci more tollerance for timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Sep 19, 2023
1 parent 432e975 commit 2434d76
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
5 changes: 0 additions & 5 deletions hscontrol/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ var (
Help: "The total amount of registered machine attempts",
}, []string{"action", "auth", "status", "user"})

updateRequestsFromNode = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: prometheusNamespace,
Name: "update_request_from_node_total",
Help: "The number of updates requested by a node/update function",
}, []string{"user", "machine", "state"})
updateRequestsSentToNode = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: prometheusNamespace,
Name: "update_request_sent_to_node_total",
Expand Down
2 changes: 1 addition & 1 deletion integration/dockertestutil/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ory/dockertest/v3"
)

const dockerExecuteTimeout = time.Second * 10
const dockerExecuteTimeout = time.Second * 30

var (
ErrDockertestCommandFailed = errors.New("dockertest command failed")
Expand Down
4 changes: 1 addition & 3 deletions integration/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/netip"
"os"
"sync"
"time"

v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/juanfont/headscale/hscontrol/util"
Expand All @@ -21,7 +20,6 @@ import (

const (
scenarioHashLength = 6
maxWait = 60 * time.Second
)

var (
Expand Down Expand Up @@ -130,7 +128,7 @@ func NewScenario() (*Scenario, error) {
return nil, fmt.Errorf("could not connect to docker: %w", err)
}

pool.MaxWait = maxWait
pool.MaxWait = dockertestMaxWait()

networkName := fmt.Sprintf("hs-%s", hash)
if overrideNetworkName := os.Getenv("HEADSCALE_TEST_NETWORK_NAME"); overrideNetworkName != "" {
Expand Down
13 changes: 7 additions & 6 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
)

const (
tsicHashLength = 6
defaultPingTimeout = 300 * time.Millisecond
defaultPingCount = 10
dockerContextPath = "../."
headscaleCertPath = "/usr/local/share/ca-certificates/headscale.crt"
tsicHashLength = 6
defaultPingTimeout = 300 * time.Millisecond
defaultPingCount = 10
dockerContextPath = "../."
headscaleCertPath = "/usr/local/share/ca-certificates/headscale.crt"
dockerExecuteTimeout = 60 * time.Second
)

var (
Expand Down Expand Up @@ -361,7 +362,7 @@ func (t *TailscaleInContainer) Login(
)
}

if _, _, err := t.Execute(command); err != nil {
if _, _, err := t.Execute(command, dockertestutil.ExecuteCommandTimeout(dockerExecuteTimeout)); err != nil {
return fmt.Errorf(
"%s failed to join tailscale client (%s): %w",
t.hostname,
Expand Down
33 changes: 33 additions & 0 deletions integration/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration

import (
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -131,6 +132,38 @@ func isSelfClient(client TailscaleClient, addr string) bool {
return false
}

func isCI() bool {
if _, ok := os.LookupEnv("CI"); ok {
return true
}

if _, ok := os.LookupEnv("GITHUB_RUN_ID"); ok {
return true
}

return false
}

func dockertestMaxWait() time.Duration {
wait := 60 * time.Second //nolint

if isCI() {
wait = 300 * time.Second //nolint
}

return wait
}

// func dockertestCommandTimeout() time.Duration {
// timeout := 10 * time.Second //nolint
//
// if isCI() {
// timeout = 60 * time.Second //nolint
// }
//
// return timeout
// }

// pingAllNegativeHelper is intended to have 1 or more nodes timeing out from the ping,
// it counts failures instead of successes.
// func pingAllNegativeHelper(t *testing.T, clients []TailscaleClient, addrs []string) int {
Expand Down

0 comments on commit 2434d76

Please sign in to comment.