Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
Signed-off-by: Aniruddha Basak <[email protected]>
  • Loading branch information
aniruddha2000 committed Aug 16, 2024
1 parent 376c223 commit 58c4edb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var (
runListImages bool
runConformance bool
continueConformance bool
skipPreflight string
conformanceFocus string
)

Expand Down Expand Up @@ -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.")

Expand Down Expand Up @@ -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)
}
}
Expand Down
21 changes: 15 additions & 6 deletions pkg/conformance/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 58c4edb

Please sign in to comment.