Skip to content

Commit

Permalink
extend test retries via flags
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Sep 26, 2023
1 parent fff9ba4 commit 0b10870
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-with-lifecycle-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
# Waits for NATS-manager image to be updated and NATS CR readiness.
run: |
export MANAGER_IMAGE=${DOCKER_IMAGE}
make e2e-setup
go test -v ./e2e/setup/setup_test.go --tags=e2e --interval=3 --attempts=120
- name: Run NATS bench
run: |
Expand Down
17 changes: 15 additions & 2 deletions e2e/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package setup_test

import (
"context"
"flag"
"fmt"
"os"
"reflect"
Expand All @@ -33,10 +34,14 @@ import (

// Constants for retries.
const (
interval = 2 * time.Second
attempts = 60
defaultInterval = 2 * time.Second
defaultAttempts = 60
)

// variables for retries.
var interval int
var attempts int

// clientSet is what is used to access K8s build-in resources like Pods, Namespaces and so on.
var clientSet *kubernetes.Clientset //nolint:gochecknoglobals // This will only be accessible in e2e tests.

Expand All @@ -45,6 +50,11 @@ var k8sClient client.Client //nolint:gochecknoglobals // This will only be acces

var logger *zap.Logger

func init() {
flag.Int(&interval, "interval", defaultInterval, "the interval for test retries")
flag.Int(&attempts, "attempts", defaultAttempts, "the number of attempts for test retries")
}

// TestMain runs before all the other test functions. It sets up all the resources that are shared between the different
// test functions. It will then run the tests and finally shuts everything down.
func TestMain(m *testing.M) {
Expand All @@ -54,6 +64,9 @@ func TestMain(m *testing.M) {
logger.Fatal(err.Error())
}

// Parse arguments that are passed to the tests.
flag.Parse()

clientSet, k8sClient, err = GetK8sClients()
if err != nil {
logger.Fatal(err.Error())
Expand Down

0 comments on commit 0b10870

Please sign in to comment.