Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion e2e-tests/config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package config

import (
"fmt"
"log"
)

var (
K8sDeployBin string
SourceContext string
Expand All @@ -10,4 +15,21 @@ var (
TargetNonAdminContext string
InsecureSkipTLSVerify bool
RunAs string
)
)

// Validates the --run-as flag value and logs the active mode.
// This should be called in BeforeSuite hooks in test suites.
// Returns an error if the --run-as value is invalid.
func ValidateAndLogRunAsFlag() error {
// Validate --run-as flag value
if RunAs != "" && RunAs != "admin" {
return fmt.Errorf("invalid --run-as value: %q. Valid values: \"admin\" or empty string (for non-admin mode)", RunAs)
}

if RunAs == "admin" {
log.Printf("[E2E] Running tests with --run-as=admin (cluster-admin credentials)")
} else {
log.Printf("[E2E] Running tests in non-admin mode")
}
return nil
}
4 changes: 4 additions & 0 deletions e2e-tests/tests/tier0/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func init() {
flag.StringVar(&config.RunAs, "run-as", "", "Override user context: set to 'admin' to run all tests with cluster-admin credentials")
}

var _ = BeforeSuite(func() {
Expect(config.ValidateAndLogRunAsFlag()).To(Succeed())
})

// TestE2E configures Ginkgo and executes the e2e test suite.
func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
Expand Down
4 changes: 4 additions & 0 deletions e2e-tests/tests/tier1/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func init() {
flag.StringVar(&config.RunAs, "run-as", "", "Override user context: set to 'admin' to run all tests with cluster-admin credentials")
}

var _ = BeforeSuite(func() {
Expect(config.ValidateAndLogRunAsFlag()).To(Succeed())
})

// TestE2E configures Ginkgo and executes the e2e test suite.
func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
Expand Down
Loading