Skip to content

Commit

Permalink
Add log command line flags to e2e test binary
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer buringerst@vmware.com
  • Loading branch information
sbueringer committed Jan 10, 2025
1 parent 7f2a8cd commit a432c06
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/component-base/logs"
logsv1 "k8s.io/component-base/logs/api/v1"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"

Expand Down Expand Up @@ -63,6 +65,8 @@ var (

// skipCleanup prevents cleanup of test resources e.g. for debug purposes.
skipCleanup bool

logOptions = logs.NewOptions()
)

// Test suite global vars.
Expand Down Expand Up @@ -94,11 +98,19 @@ func init() {
flag.BoolVar(&skipCleanup, "e2e.skip-resource-cleanup", false, "if true, the resource cleanup after tests will be skipped")
flag.StringVar(&clusterctlConfig, "e2e.clusterctl-config", "", "file which tests will use as a clusterctl config. If it is not set, a local clusterctl repository (including a clusterctl config) will be created automatically.")
flag.BoolVar(&useExistingCluster, "e2e.use-existing-cluster", false, "if true, the test uses the current cluster instead of creating a new one (default discovery rules apply)")

logsv1.AddGoFlags(logOptions, flag.CommandLine)
}

func TestE2E(t *testing.T) {
g := NewWithT(t)

if err := logsv1.ValidateAndApply(logOptions, nil); err != nil {
fmt.Printf("Unable to start tests: %v\n", err)
os.Exit(1)
}

// klog.Background will automatically use the right logger.
ctrl.SetLogger(klog.Background())

// If running in prow, make sure to use the artifacts folder that will be reported in test grid (ignoring the value provided by flag).
Expand Down

0 comments on commit a432c06

Please sign in to comment.