Skip to content

[CRE-3594] [CRE-3595] Fix Flaky Tests#22716

Open
kalverra wants to merge 13 commits into
developfrom
flakeExploration
Open

[CRE-3594] [CRE-3595] Fix Flaky Tests#22716
kalverra wants to merge 13 commits into
developfrom
flakeExploration

Conversation

@kalverra
Copy link
Copy Markdown
Collaborator

@kalverra kalverra commented Jun 2, 2026

Discovered and fixed flaky tests in the core/services/workflows/ directory. Used the fix-flaky-tests skill and ./cltest diagnose to do so. Branched off of #22705

core/services/workflows/cmd/cre/utils

TestRunner / happy_path_with_an_empty_workflow

Why: Fake billing gRPC listened on fixed localhost:4319. Parallel diagnose workers collided on that port (address already in use).
Fix: Listen on 127.0.0.1:0. Expose GRPCAddress() from BillingService. Runner passes that address into the standalone engine instead of a hardcoded port.

core/services/workflows/syncer

Test_workflowDeletedHandler (and subtests that register then delete workflows)

Why: Tests used the real engine factory. Slow WASM host.NewModule ran while a Postgres connection stayed open, triggering idle-in-transaction timeout. Missing basic-test-trigger@1.0.0 showed up in logs but the DB timeout was the actual failure.
Fix: WithEngineFactoryFn(mockEngineFactoryFn) so handler tests don't spin a real WASM engine. Build WASM binary before pgtest.NewSqlxDB.

Test_workflowPausedActivatedUpdatedHandler / success_pausing_activating_and_updating_existing_engine_and_spec

Why: Same as deleted handler — real engine + slow WASM + DB timeout under parallel cold start.
Fix: Same — mock engine factory, WASM before DB.

Test_workflowRegisteredHandler (and subtests that use the real engine via testRunningWorkflow)

Why: Real engine couldn't resolve basic-test-trigger@1.0.0 when the registry only had TestMetadataRegistry. Cold-start timing made this worse alongside WASM/DB pressure.
Fix: registerSimpleDAGWorkflowCapabilities() adds a minimal dagTestTrigger to the registry when no custom engineFactoryFn is set.

Test_workflowRegisteredHandler / succeeds_if_correct_engine_already_exists

Why: Failed in the same early iterations as the other syncer handler tests (report iters 0–2).
Fix: Covered by the handler and capability registration changes above.
TestEngineFactoryFn_SuccessfulCreation

Why: Real engine factory needs the DAG trigger registered.
Fix: registerSimpleDAGWorkflowCapabilities() at TestEngineFactoryFn setup.

core/services/workflows/v2

TestEngine_WASMBinary_With_Config / OK_received_expected_config

Why: Workflow logs "onTrigger called" asynchronously to Beholder. requireUserLogs asserted immediately after engine.Close() and sometimes ran before the log arrived.
Fix: requireUserLogs now uses require.Eventually (5s, 50ms poll).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

CORA - Pending Reviewers

Codeowners Entry Overall Num Files Owners
* 6 @smartcontractkit/foundations, @smartcontractkit/core
/core/services/workflows/ 4 @smartcontractkit/keystone
/tools/test/ 39 @smartcontractkit/devex-cicd, @smartcontractkit/devex-tooling, @smartcontractkit/core
.tool-versions 1 @smartcontractkit/core
go.md 1 @smartcontractkit/core, @smartcontractkit/foundations
go.mod 1 @smartcontractkit/core, @smartcontractkit/foundations
go.sum 1 @smartcontractkit/core, @smartcontractkit/foundations

Legend: ✅ Approved | ❌ Changes Requested | 💬 Commented | 🚫 Dismissed | ⏳ Pending | ❓ Unknown

For more details, see the full review summary.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

✅ No conflicts with other open PRs targeting develop

@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Jun 2, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@cl-sonarqube-production
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant