-
Notifications
You must be signed in to change notification settings - Fork 567
CNTRLPLANE-3999: add declarative TestPlan for composing v2 cluster variants and test matrices #9420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,14 +42,17 @@ func main() { | |
|
|
||
| sharedDir := requireEnv("SHARED_DIR") | ||
| artifactDir := requireEnv("ARTIFACT_DIR") | ||
| releaseImage := os.Getenv("RELEASE_IMAGE_LATEST") | ||
|
|
||
| eventuallyVerbose := os.Getenv("EVENTUALLY_VERBOSE") | ||
| if eventuallyVerbose == "" { | ||
| eventuallyVerbose = defaultVerbose | ||
| } | ||
| os.Setenv("EVENTUALLY_VERBOSE", eventuallyVerbose) | ||
|
|
||
| if v := os.Getenv("RELEASE_IMAGE_LATEST"); v != "" { | ||
| os.Setenv("E2E_LATEST_RELEASE_IMAGE", v) | ||
| } | ||
|
|
||
| manifest, err := lifecycle.ReadManifest(sharedDir) | ||
| if err != nil { | ||
| log.Fatalf("Failed to read cluster manifest: %v", err) | ||
|
|
@@ -63,9 +66,18 @@ func main() { | |
| // Let the platform set up any env vars it needs for tests. | ||
| platform.SetupTestEnv(sharedDir) | ||
|
|
||
| matrix := platform.TestMatrix(releaseImage) | ||
| testPlanPath := os.Getenv("TEST_PLAN") | ||
| plan, err := lifecycle.ResolveTestPlan(testPlanPath, platform) | ||
| if err != nil { | ||
| log.Fatalf("Failed to resolve test plan: %v", err) | ||
| } | ||
| log.Printf("Using test plan %q", plan.Name) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cleaned this all up so that validation covers the path checks and makes the panic a backstop (i.e. if you panic it's because you forgot to call validate, which is explicitly required / a bug) |
||
|
|
||
| if err := plan.TestMatrix.Validate(); err != nil { | ||
| log.Fatalf("Invalid test plan: %v", err) | ||
| } | ||
|
|
||
| clustersByVariant, err := matrix.ResolveVariants(manifest) | ||
| clustersByVariant, err := plan.TestMatrix.ResolveVariants(manifest) | ||
| if err != nil { | ||
| log.Fatalf("Manifest/test matrix mismatch: %v", err) | ||
| } | ||
|
|
@@ -77,15 +89,15 @@ func main() { | |
| ) | ||
|
|
||
| // Launch parallel test groups. | ||
| for _, g := range matrix.Parallel { | ||
| for _, g := range plan.TestMatrix.Parallel { | ||
| g := g | ||
| entry := clustersByVariant[g.Variant] | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| log.Printf("Running %s tests against %s...", g.Name, entry.Name) | ||
| err := runTestBinary(testBinary, entry.Name, entry.Namespace, g.LabelFilter, g.Skip, | ||
| filepath.Join(artifactDir, g.JUnitFile), g.ExtraEnv) | ||
| filepath.Join(artifactDir, g.JUnitFile())) | ||
| mu.Lock() | ||
| results = append(results, testResult{name: g.Name, err: err}) | ||
| mu.Unlock() | ||
|
|
@@ -99,7 +111,7 @@ func main() { | |
|
|
||
| // Launch sequential groups (each group runs in its own goroutine, | ||
| // but steps within a group run one after another). | ||
| for _, sg := range matrix.Sequential { | ||
| for _, sg := range plan.TestMatrix.Sequential { | ||
| sg := sg | ||
| wg.Add(1) | ||
| go func() { | ||
|
|
@@ -108,7 +120,7 @@ func main() { | |
| entry := clustersByVariant[step.Variant] | ||
| log.Printf("Running %s tests against %s...", step.Name, entry.Name) | ||
| err := runTestBinary(testBinary, entry.Name, entry.Namespace, step.LabelFilter, step.Skip, | ||
| filepath.Join(artifactDir, step.JUnitFile), step.ExtraEnv) | ||
| filepath.Join(artifactDir, step.JUnitFile())) | ||
| mu.Lock() | ||
| results = append(results, testResult{name: step.Name, err: err}) | ||
| mu.Unlock() | ||
|
|
@@ -143,7 +155,7 @@ func main() { | |
| log.Println("All test groups passed") | ||
| } | ||
|
|
||
| func runTestBinary(testBinary, clusterName, namespace, labelFilter, skip, junitPath string, extraEnv []string) error { | ||
| func runTestBinary(testBinary, clusterName, namespace, labelFilter, skip, junitPath string) error { | ||
| ginkgoTimeout := os.Getenv("GINKGO_TIMEOUT") | ||
| if ginkgoTimeout == "" { | ||
| ginkgoTimeout = defaultGinkgoTimeout | ||
|
|
@@ -167,7 +179,6 @@ func runTestBinary(testBinary, clusterName, namespace, labelFilter, skip, junitP | |
| fmt.Sprintf("E2E_HOSTED_CLUSTER_NAME=%s", clusterName), | ||
| fmt.Sprintf("E2E_HOSTED_CLUSTER_NAMESPACE=%s", namespace), | ||
| ) | ||
| cmd.Env = append(cmd.Env, extraEnv...) | ||
|
|
||
| return cmd.Run() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,20 +119,26 @@ func (a *AWSPlatformConfig) PostVersionRollout(ctx context.Context, cl crclient. | |
| return nil | ||
| } | ||
|
|
||
| func (a *AWSPlatformConfig) TestMatrix(releaseImage string) TestMatrix { | ||
| func (a *AWSPlatformConfig) DefaultTestPlan() TestPlan { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default plan's matrix and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made the interface docs for DefaultTestPlan more precise (I think), as to introducing a stronger coupling between the matrix and the clusterspecs, I'd like to deal with that in a followup since I think we could start lifting out the specs into a more declarative form that will help address it more cleanly that I can really do here without increasing the scope of changes too far for now |
||
| return TestPlan{ | ||
| Name: "aws-full", | ||
| Platform: "aws", | ||
| TestMatrix: a.TestMatrix(), | ||
| } | ||
| } | ||
|
|
||
| func (a *AWSPlatformConfig) TestMatrix() TestMatrix { | ||
| return TestMatrix{ | ||
| Parallel: []TestGroup{ | ||
| { | ||
| Name: "public", | ||
| Variant: "public", | ||
| LabelFilter: "!lifecycle || hosted-cluster-aws", | ||
| JUnitFile: "junit_public.xml", | ||
| }, | ||
| { | ||
| Name: "karpenter", | ||
| Variant: "karpenter", | ||
| LabelFilter: "karpenter", | ||
| JUnitFile: "junit_karpenter.xml", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.