From 58c4edb991d7222edd504f2241cb19ad95954c15 Mon Sep 17 00:00:00 2001 From: Aniruddha Basak Date: Fri, 16 Aug 2024 18:19:10 +0200 Subject: [PATCH] a Signed-off-by: Aniruddha Basak --- cmd/root.go | 4 +++- pkg/conformance/deploy.go | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index bac9020..bb62ef8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -41,6 +41,7 @@ var ( runListImages bool runConformance bool continueConformance bool + skipPreflight string conformanceFocus string ) @@ -74,6 +75,7 @@ func New() *cobra.Command { rootCmd.Flags().BoolVar(&runCleanup, "cleanup", false, "cleanup resources (pods, namespaces etc).") rootCmd.Flags().BoolVar(&runListImages, "list-images", false, "list all images that will be used during conformance tests.") rootCmd.Flags().BoolVar(&runConformance, "conformance", false, "run conformance tests.") + rootCmd.Flags().StringVar(&skipPreflight, "skip-preflight", "", "skip namespace check, use the specified namespace.") rootCmd.Flags().BoolVar(&continueConformance, "continue", false, "connect to an already running conformance test pod.") rootCmd.Flags().StringVar(&conformanceFocus, "focus", "", "focus runs a specific e2e test. e.g. - sig-auth. allows regular expressions.") @@ -147,7 +149,7 @@ func action(ctx context.Context, config *types.Configuration) error { if continueConformance { log.Println("Attempting to continue with already running tests...") } else { - if err := testRunner.Deploy(ctx, conformanceFocus, verboseGinkgo, config.StartupTimeout); err != nil { + if err := testRunner.Deploy(ctx, conformanceFocus, skipPreflight, verboseGinkgo, config.StartupTimeout); err != nil { return fmt.Errorf("failed to deploy tests: %w", err) } } diff --git a/pkg/conformance/deploy.go b/pkg/conformance/deploy.go index 2a57937..f1b88e0 100644 --- a/pkg/conformance/deploy.go +++ b/pkg/conformance/deploy.go @@ -33,7 +33,7 @@ import ( ) // Deploy sets up the necessary resources and runs E2E conformance tests. -func (r *TestRunner) Deploy(ctx context.Context, focus string, verboseGinkgo bool, timeout time.Duration) error { +func (r *TestRunner) Deploy(ctx context.Context, focus string, skipPreflight string, verboseGinkgo bool, timeout time.Duration) error { conformanceNS := corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: r.config.Namespace, @@ -116,6 +116,10 @@ func (r *TestRunner) Deploy(ctx context.Context, focus string, verboseGinkgo boo Name: "E2E_EXTRA_ARGS", Value: strings.Join(r.config.ExtraArgs, " "), }, + { + Name: "TZ", + Value: "UTC+", + }, } extraGinkgoArgs := r.config.ExtraGinkgoArgs @@ -195,13 +199,18 @@ func (r *TestRunner) Deploy(ctx context.Context, focus string, verboseGinkgo boo ns, err := r.clientset.CoreV1().Namespaces().Create(ctx, &conformanceNS, metav1.CreateOptions{}) if err != nil { if errors.IsAlreadyExists(err) { - //nolint:stylecheck // error message references a Kubernetes resource type. - err = fmt.Errorf("Namespace %s already exist, please run --cleanup first", conformanceNS.Name) + if skipPreflight != "" { + log.Printf("Using existing namespace: %s", r.config.Namespace) + } else { + //nolint:stylecheck // error message references a Kubernetes resource type. + return fmt.Errorf("namespace %s already exists, please run with --cleanup first", conformanceNS.Name) + } + } else { + return err } - - return err + } else { + log.Printf("Created namespace %s.", ns.Name) } - log.Printf("Created Namespace %s.", ns.Name) sa, err := r.clientset.CoreV1().ServiceAccounts(ns.Name).Create(ctx, &conformanceSA, metav1.CreateOptions{}) if err != nil {