Skip to content

fix(test): de-flake pipeline-payloads (per-test re-seed + honest reset) - #3893

Merged
diegosouzapw merged 1 commit into
release/v3.8.26from
fix/flaky-pipeline-payloads-reseed
Jun 15, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.26from
fix/flaky-pipeline-payloads-reseed

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Problema (main Coverage Shard 3/8 vermelho)

tests/unit/provider-request-failure-pipeline.test.ts semeava call_log_pipeline_enabled: true uma vez (test.before), mas afterEach → resetStorage() apaga o DB a cada teste (resetDbInstance + rmSync). Logo os testes 2-4 dependiam de o setting sobreviver ao wipe via cache de leitura. Sob carga do shard no CI, esse cache é evictado em momentos imprevisíveis → re-lê o DB zerado → call_log_pipeline_enabled no default (falsy) → pipelinePayloads não é capturado → AssertionError: expected pipeline payloads intermitente.

Confirmado: passa isolado (4/4), mas falhou no Coverage Shard (3/8) da main (tests 1902, pass 1900).

Causa-raiz provada (TDD determinística)

  1. Tornar resetStorage() um reset honesto — invalidateDbCache("settings") após o resetDbInstance (espelha um DB frio, como no CI sob carga) → reproduz a falha deterministicamente: 3/4 falham com exatamente expected pipeline payloads.
  2. Re-semear o flag em beforeEach (não before) → 4/4 passam.

O reset honesto fica como guarda permanente contra o mesmo mascaramento por cache stale. Padrão idêntico ao do chatcore-translation-paths.test.ts (que semeia por-teste e por isso não flaca).

Validação

  • TDD: 3 falham (antes) → 4 passam (depois).
  • Stress: 0 falhas em 5 runs isolados + 3 runs concorrentes (--test-concurrency=4, heap reduzido, com os arquivos contendentes database-settings-maintenance/chatcore-translation-paths/db-detailed-logs).

Mudança test-only, nenhuma asserção enfraquecida (o reset foi fortalecido). Não toca produção, não gera versão.

…eset

provider-request-failure-pipeline.test.ts seeded call_log_pipeline_enabled
once in test.before, but afterEach->resetStorage() wipes the DB after every
test. Tests 2-4 therefore depended on the settings read-cache surviving the
wipe; under CI shard load that cache is evicted at unpredictable times, so the
`expected pipeline payloads` assertions flaked (seen on main Coverage Shard 3/8).

TDD: making resetStorage() honest (invalidateDbCache("settings") so the reset
truly mirrors a cold DB) reproduces the failure deterministically (3/4 fail).
Re-seeding the flag in beforeEach instead of before makes all 4 pass — and the
honest reset is kept as a permanent guard against the same stale-cache masking.

Test-only change; no assertion weakened (the reset is strengthened). 4/4 pass
isolated and 0 failures across 5 isolated + 3 concurrent-shard stress runs.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses test flakiness under CI load in tests/unit/provider-request-failure-pipeline.test.ts by ensuring the settings read-cache is cleared during database resets and changing the setup hook from test.before to test.beforeEach to re-seed settings deterministically. The reviewer suggests calling invalidateDbCache() without arguments to clear all cache scopes (including pricing, connections, and combos) for a more robust reset.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

// wipe and silently masks the fact that the fresh DB has the default. In CI
// under load this cache is evicted at unpredictable times, so tests that rely
// on the stale cache flake. Make the reset honest and deterministic here.
invalidateDbCache("settings");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Para garantir um reset verdadeiramente completo e robusto do banco de dados entre os testes, é recomendável invalidar todos os escopos do cache de leitura do banco de dados (não apenas o de settings). Chamar invalidateDbCache() sem argumentos limpa as caches de settings, pricing, connections e incrementa a versão de combos, prevenindo futuros flakes intermitentes caso o teste passe a depender de outras tabelas.

  invalidateDbCache();

@diegosouzapw
diegosouzapw merged commit f8131c8 into release/v3.8.26 Jun 15, 2026
2 checks passed
@diegosouzapw diegosouzapw mentioned this pull request Jun 16, 2026
@diegosouzapw
diegosouzapw deleted the fix/flaky-pipeline-payloads-reseed branch June 17, 2026 00:54
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
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