Repository navigation
test(#6169): suite uses unified Driver for repo allocate/deallocate/finalize #6172
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
15c622b
5915a65
4f705d2
e2cc0d2
fdbf826
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 |
|---|---|---|
|
|
@@ -24,9 +24,9 @@ import ( | |
| ) | ||
|
|
||
| // poolSize is the number of enrolled test-repo-NN repos in the pool org. | ||
| // GODOG_CONCURRENCY must not exceed this — extra workers would block in | ||
| // pool.Acquire with no warning because the pool org only has test-repo-01 | ||
| // through test-repo-12 with per-repo mint enrollment. | ||
| // This determines the driver's Capacity — the maximum number of | ||
| // concurrently allocated repos. Scenarios that exceed this block in | ||
| // AllocateRepo until a slot frees. | ||
| const poolSize = 12 | ||
|
|
||
| // suiteName identifies this test suite. It is used to derive the CF Worker | ||
|
|
@@ -46,9 +46,6 @@ func TestBehaviourSuite(t *testing.T) { | |
| } | ||
| concurrency = n | ||
| } | ||
| if concurrency > poolSize { | ||
| t.Fatalf("GODOG_CONCURRENCY=%d exceeds repo pool size %d", concurrency, poolSize) | ||
| } | ||
|
|
||
| cfg := env.LoadRunnerConfig() | ||
| if err := cfg.Validate(); err != nil { | ||
|
|
@@ -70,10 +67,10 @@ func TestBehaviourSuite(t *testing.T) { | |
|
|
||
| binary := e2etest.BuildCLIBinary(t) | ||
|
|
||
| // Construct the CF mint driver with caller-provided parameters. | ||
| // The driver does not hardcode pool size or test-repo-NN assumptions; | ||
| // the calling code passes allowed orgs, per-repo WIF repos, and | ||
| // workflow host repos. | ||
| // Build a Factory that captures the cfmint configuration. | ||
| // The Factory is the #6135 consolidation seam — suite code | ||
| // selects a Factory and does not compose MintDriver + ensurer + | ||
| // pool itself. | ||
| // | ||
| // AllowedOrgs is explicitly empty ("") — this is per-repo mode, so | ||
| // we must not dual-enroll the pool org as an allowed org. The CLI's | ||
|
|
@@ -82,63 +79,57 @@ func TestBehaviourSuite(t *testing.T) { | |
| // WorkflowHostRepos registers the pool repos whose vendored workflows | ||
| // need to mint tokens. Without this, the mint rejects | ||
| // job_workflow_ref values from pool repos → 401. | ||
| installDriver, err := cfmint.NewDriver(client, token, binary, e2eCfg.GCPProjectID, t.Logf, cfmint.Config{ | ||
| factory := cfmint.NewFactory(ctx, e2eCfg, poolSize, cfmint.Config{ | ||
| PEMDir: e2eCfg.CFMintPEMDir, | ||
| SuiteName: suiteName, | ||
| AllowedOrgs: "", | ||
| PerRepoWIFRepos: buildPerRepoWIFRepos(org), | ||
| WorkflowHostRepos: buildWorkflowHostRepos(org), | ||
| AppSet: "fullsend-test", | ||
| }) | ||
|
|
||
| e2etest.CleanupStaleResources(ctx, client, token, org, t) | ||
|
|
||
| // Call the Factory to construct the unified Driver. The Factory | ||
| // creates the MintDriver, calls mint.Install, and wires the | ||
| // internal pool + RepoEnsurer behind the Driver interface. | ||
| driver, err := factory(org, client, token, binary, e2eCfg.GCPProjectID, t.Logf) | ||
| if err != nil { | ||
| t.Fatalf("creating install driver: %v", err) | ||
| } | ||
|
|
||
| e2etest.CleanupStaleResources(ctx, client, token, org, t) | ||
|
|
||
| // Register teardown before Install so that a partially deployed | ||
| // preview mint is cleaned up even if Install fails partway through. | ||
| var installState install.State | ||
| // Register Finalize for teardown — it reclaims any outstanding | ||
| // leases, logs them, and tears down the mint (e.g. CF preview). | ||
| t.Cleanup(func() { | ||
| if installState == nil { | ||
| return | ||
| } | ||
| teardownCtx := context.Background() | ||
| if teardownErr := installDriver.Teardown(teardownCtx, org, installState); teardownErr != nil { | ||
| t.Logf("install teardown: %v", teardownErr) | ||
| if finalizeErr := driver.Finalize(context.Background()); finalizeErr != nil { | ||
|
ifireball marked this conversation as resolved.
Resolved
|
||
| t.Logf("driver finalize: %v", finalizeErr) | ||
| } | ||
| }) | ||
|
|
||
| installState, err = installDriver.Install(ctx, org) | ||
| if err != nil { | ||
| t.Fatalf("installing fullsend on %s: %v", org, err) | ||
| // Advisory: excess workers block in AllocateRepo (#6135). | ||
| if concurrency > driver.Capacity() { | ||
| t.Logf("WARNING: GODOG_CONCURRENCY=%d exceeds driver capacity %d; excess workers may block in AllocateRepo", concurrency, driver.Capacity()) | ||
|
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. [low] error-handling The guard for GODOG_CONCURRENCY exceeding driver capacity was downgraded from t.Fatalf (hard failure) to t.Logf (advisory warning). While this is intentional per the #6135 contract (AllocateRepo blocks until a slot frees), excess goroutines will block until the go test timeout fires, producing a confusing timeout failure. The log warning appears early in output and may be missed. Suggested fix: Consider using t.Errorf instead of t.Logf so the misconfiguration is visible in test results as a failure, even though the run continues. |
||
| } | ||
|
|
||
| // The install state carries the mint URL from the selected driver. | ||
| // Thread it to the ensurer so additional pool repos use the same | ||
| // mint endpoint. | ||
| if m, ok := installState.(install.MintURLProvider); ok && m.MintURL() != "" { | ||
| t.Logf("using mint URL for ensurer: %s", m.MintURL()) | ||
| e2eCfg.MintURL = m.MintURL() | ||
| } | ||
|
|
||
| pool, err := world.NewRepoPool(poolSize) | ||
| if err != nil { | ||
| t.Fatalf("creating repo pool: %v", err) | ||
| } | ||
|
|
||
| ensurer := install.NewRepoEnsurer(e2eCfg, client, token, binary, t.Logf) | ||
|
|
||
| // The install driver only manages the mint lifecycle — it does not | ||
| // install on any specific repo. RepoName and RepoFull are set per- | ||
| // scenario by the ensurer when "Given the enrolled test repository" | ||
| // scenario by AllocateRepo when "Given the enrolled test repository" | ||
| // acquires a leased pool repo. | ||
| // | ||
| // The Driver carries the mint install state internally; extract it | ||
| // via the StateProvider interface so the suite does not thread State | ||
| // separately. | ||
| var mintState install.State | ||
| if sp, ok := driver.(install.StateProvider); ok { | ||
| mintState = sp.InstallState() | ||
| } | ||
|
|
||
| template := &world.World{ | ||
| Config: cfg, | ||
| SCM: scmgh.New(client), | ||
| CI: gaci.New(client, token), | ||
| Install: installState, | ||
| Ensurer: ensurer, | ||
| Install: mintState, | ||
| RepoDriver: driver, | ||
| Org: org, | ||
| Token: token, | ||
| Logf: t.Logf, | ||
|
|
@@ -148,7 +139,7 @@ func TestBehaviourSuite(t *testing.T) { | |
|
|
||
| suiteRunner := godog.TestSuite{ | ||
| Name: "behaviour", | ||
| ScenarioInitializer: func(sc *godog.ScenarioContext) { suite.InitScenario(sc, template, pool) }, | ||
| ScenarioInitializer: func(sc *godog.ScenarioContext) { suite.InitScenario(sc, template) }, | ||
| Options: &godog.Options{ | ||
| Format: "pretty", | ||
| Paths: []string{"features"}, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.