发布

  • [OPIK-6126] [QA] feat: e2e infrastructure foundation (env config + workspace teardown) (#6677)

    frostbyte_neo 发布于 2026-05-13 10:15:14 +00:00

    • [OPIK-6106] [QA] chore: scaffold e2e suite directory structure

    • [OPIK-6106] [QA] feat: env config layer with deployment-aware defaults

    • [OPIK-6106] [QA] feat: minimal playwright config

    • [OPIK-6106] [QA] feat: global-setup stamps runId; teardown stub

    • [OPIK-6106] [QA] test: foundation sanity suite

    • [OPIK-6106] [QA] feat: backend client (REST for inspection/teardown only)

    • fix(e2e): move hand-written schema out of generated/ (gitignored)

    • [OPIK-6106] [QA] feat: global-teardown sweeps cuj-{runId}-* entities

    • [OPIK-6106] [QA] feat: orphan sweep on global-setup (>6h old cuj-* projects)

    • fix(e2e): stabilize cuj-{runId} prefix across setup/workers/teardown

    loadEnvConfig() was re-stamping a fresh runId on every call, so the test
    worker, globalSetup, and globalTeardown each saw a different runId. The
    teardown sweep then targeted a prefix no project actually used, leaving
    orphaned cuj-* projects.

    • cache the stamped runId in module scope (in-process consistency)
    • honour OPIK_RUN_ID env var so globalSetup can propagate the id to workers
    • normalize OPIK_BASE_URL: strip trailing slash, peel /api so the cloud
      /opik/api shorthand still derives a clean apiBaseUrl
    • test(e2e): move env.config unit tests under tests/_unit; add fixture-lifecycle spec
    • relocate env.config.test.ts (it was being skipped because testDir is ./tests)
    • rename to .spec.ts to match the rest of the suite
    • add coverage for the new apiBaseUrl /api normalization
    • fixture-lifecycle.spec.ts creates a cuj-* project via REST and asserts the
      cuj-{runId}-w{worker}-* namespace; teardown sweep is verified out-of-band
      by checking the workspace is empty post-run
    • chore(e2e): remove old env.config.test.ts (moved to tests/_unit/env.config.spec.ts)

    • chore(e2e): trim development scaffolding from foundation PR

    The unit tests for env.config and the _seed foundation/fixture-lifecycle
    specs were TDD scaffolding while building the infrastructure. They cover
    the parser, not any CUJ — the actual CUJ smokes (Phase 3) will exercise
    the same code paths through real flows. Remove them so this PR is purely
    the foundation that future tests sit on top of.

    Also trim:

    • features.testSuites / features.agentConfig — hardcoded true, no
      consumer; one-line additions when actually needed
    • schema.ts — drop fields client.ts never reads
    • openapi-typescript devDep — only used by an aspirational generate
      script against a non-running URL; add back when wiring real generation
    • package.json scripts test:feature / test:ui / codegen — aspirational
      aliases with no tests to exercise them yet

    Result: 9 packages installed (was 41), one boot path, no test runner red
    herrings. npm run test now uses --pass-with-no-tests so a foundation-
    only run exits 0; the first real-test PR drops the flag.

    • fix(e2e): tighten cloud config validation and banner data-flow

    Three findings from CodeQL + Baz review on #6677:

    1. cloud deployment did not require OPIK_API_KEY. globalSetup/Teardown
      pass env.apiKey into makeBackendClient(), which only adds the
      Authorization header when truthy. Result: cloud sweeps run
      unauthenticated, fail, get swallowed by the sweep catch — orphans
      accumulate silently. Now throws when missing.

    2. workspace could resolve to '' on cloud/self-hosted when neither
      OPIK_WORKSPACE nor OPIK_TEST_USER_NAME was set. makeBackendClient()
      then skips the Comet-Workspace header entirely, so cleanup runs
      unscoped against Cloud (where the header is required). Now throws
      when missing for non-oss deployments.

    3. CodeQL flagged printEnvBanner's console.log as clear-text logging of
      process-env data. The banner only forwards non-secret scalars, but
      the data-flow lineage from EnvConfig made the alert unavoidable.
      Refactored to copy each allow-listed field through String() into a
      fresh local before composing the string, with a comment documenting
      the intent.

    • fix(e2e): drop printEnvBanner to clear CodeQL clear-text-logging alert

    CodeQL's js/clear-text-logging is structural: any data path from
    process.env to console.log trips it, regardless of which fields we
    forward. String() wrapping and allowlists don't break the taint trail
    since the analyzer treats process.env in aggregate.

    The banner was a debug aid; runId still gets logged separately by the
    existing '[global-setup] runId stamped' line, and the rest of the
    banner content (deployment, baseUrl, workspace, feature flags) is right
    there in the shell env that invoked the suite. Once Allure TestOps
    lands (Phase 4) the same metadata lives in launch attributes anyway.

    Removes 28 lines net.

    下载附件