dd-trace 5.134.0 → 5.136.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/init.js +2 -22
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -1
- package/index.d.ts +124 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +19 -15
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +78 -62
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +56 -19
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +29 -20
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/jest.js +265 -82
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -28
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
- package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +10 -8
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -439
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -13
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +9 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
- package/packages/dd-trace/src/config/index.js +111 -43
- package/packages/dd-trace/src/config/parsers.js +18 -1
- package/packages/dd-trace/src/config/supported-configurations.json +174 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +23 -15
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +83 -50
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +21 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
- package/packages/dd-trace/src/llmobs/tagger.js +25 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +13 -2
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +33 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
- package/packages/dd-trace/src/plugins/index.js +9 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +273 -86
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +90 -45
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +81 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +48 -57
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +41 -9
- package/packages/dd-trace/src/span_stats.js +28 -2
- package/packages/dd-trace/src/startup-log.js +8 -5
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +4 -2
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -19
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -650
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -133,6 +133,9 @@ const TELEMETRY_KNOWN_TESTS_MS = 'early_flake_detection.request_ms'
|
|
|
133
133
|
const TELEMETRY_KNOWN_TESTS_ERRORS = 'early_flake_detection.request_errors'
|
|
134
134
|
const TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS = 'early_flake_detection.response_tests'
|
|
135
135
|
const TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES = 'early_flake_detection.response_bytes'
|
|
136
|
+
const TELEMETRY_KNOWN_TESTS_PAGES_FETCHED = 'known_tests.pages_fetched'
|
|
137
|
+
const TELEMETRY_KNOWN_TESTS_TOTAL_FETCH_MS = 'known_tests.total_fetch_ms'
|
|
138
|
+
const TELEMETRY_KNOWN_TESTS_TOTAL_REQUEST_MS = 'known_tests.total_request_ms'
|
|
136
139
|
// coverage upload
|
|
137
140
|
const TELEMETRY_COVERAGE_UPLOAD = 'coverage_upload.request'
|
|
138
141
|
const TELEMETRY_COVERAGE_UPLOAD_MS = 'coverage_upload.request_ms'
|
|
@@ -207,6 +210,9 @@ module.exports = {
|
|
|
207
210
|
TELEMETRY_KNOWN_TESTS_ERRORS,
|
|
208
211
|
TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS,
|
|
209
212
|
TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES,
|
|
213
|
+
TELEMETRY_KNOWN_TESTS_PAGES_FETCHED,
|
|
214
|
+
TELEMETRY_KNOWN_TESTS_TOTAL_FETCH_MS,
|
|
215
|
+
TELEMETRY_KNOWN_TESTS_TOTAL_REQUEST_MS,
|
|
210
216
|
TELEMETRY_COVERAGE_UPLOAD,
|
|
211
217
|
TELEMETRY_COVERAGE_UPLOAD_MS,
|
|
212
218
|
TELEMETRY_COVERAGE_UPLOAD_ERRORS,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Symbols cross Jest's VM/module-registry boundary without initializing the tracer.
|
|
4
|
+
const annotationsKey = Symbol.for('dd-trace:test-annotations')
|
|
5
|
+
/** @type {{ mustFail: boolean, noAutoRetry: boolean, source?: Function }} */
|
|
6
|
+
const emptyAnnotations = Object.freeze({ mustFail: false, noAutoRetry: false })
|
|
7
|
+
|
|
8
|
+
/** @param {Function|undefined} fn */
|
|
9
|
+
function getTestAnnotations (fn) {
|
|
10
|
+
return (fn && fn[annotationsKey]) || emptyAnnotations
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Function|undefined} source
|
|
15
|
+
* @param {Function} target
|
|
16
|
+
*/
|
|
17
|
+
function copyTestAnnotations (source, target) {
|
|
18
|
+
const annotations = source && source[annotationsKey]
|
|
19
|
+
if (annotations && target[annotationsKey] !== annotations) {
|
|
20
|
+
Object.defineProperty(target, annotationsKey, { value: annotations, configurable: true })
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @template {Function} T
|
|
26
|
+
* @param {T} fn
|
|
27
|
+
* @param {'mustFail'|'noAutoRetry'} annotation
|
|
28
|
+
* @returns {T}
|
|
29
|
+
*/
|
|
30
|
+
function annotate (fn, annotation) {
|
|
31
|
+
if (typeof fn !== 'function') throw new TypeError('Test annotations require a test callback')
|
|
32
|
+
const inherited = getTestAnnotations(fn)
|
|
33
|
+
const annotated = function (...args) {
|
|
34
|
+
return fn.apply(this, args)
|
|
35
|
+
}
|
|
36
|
+
Object.setPrototypeOf(annotated, Object.getPrototypeOf(fn))
|
|
37
|
+
Object.defineProperties(annotated, {
|
|
38
|
+
toString: { value: () => fn.toString(), writable: true, configurable: true },
|
|
39
|
+
...Object.getOwnPropertyDescriptors(fn),
|
|
40
|
+
length: { value: fn.length },
|
|
41
|
+
name: { value: fn.name },
|
|
42
|
+
[annotationsKey]: {
|
|
43
|
+
value: Object.freeze({
|
|
44
|
+
...inherited,
|
|
45
|
+
[annotation]: true,
|
|
46
|
+
source: inherited.source || fn,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
if (Object.isFrozen(fn)) Object.freeze(annotated)
|
|
51
|
+
return /** @type {T} */ (/** @type {unknown} */ (annotated))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @template {Function} T
|
|
56
|
+
* @param {T} fn
|
|
57
|
+
* @returns {T}
|
|
58
|
+
*/
|
|
59
|
+
function preventFailureSuppression (fn) {
|
|
60
|
+
return annotate(fn, 'mustFail')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @template {Function} T
|
|
65
|
+
* @param {T} fn
|
|
66
|
+
* @returns {T}
|
|
67
|
+
*/
|
|
68
|
+
function noAutoRetry (fn) {
|
|
69
|
+
return annotate(fn, 'noAutoRetry')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = { preventFailureSuppression, noAutoRetry, getTestAnnotations, copyTestAnnotations }
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const declarationMethods = new Set([
|
|
4
|
+
'concurrent', 'sequential', 'shuffle', 'skip', 'only', 'todo', 'fails', 'each', 'for', 'extend',
|
|
5
|
+
'skipIf', 'runIf', 'describe', 'suite',
|
|
6
|
+
])
|
|
7
|
+
const wrappedDeclarations = new WeakMap()
|
|
8
|
+
const capturedCollectors = new WeakSet()
|
|
9
|
+
const declarationFactories = ['each', 'for', 'extend', 'skipIf', 'runIf']
|
|
10
|
+
let captureLocations = false
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {{
|
|
14
|
+
* type: 'collector', test: Function & { fn: Function }, tasks: object[], options?: { retry?: unknown }
|
|
15
|
+
* }} Collector
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Function & { fn: Function }} test
|
|
20
|
+
* @param {() => Collector} getCurrentSuite
|
|
21
|
+
*/
|
|
22
|
+
function captureDeclarations (test, getCurrentSuite) {
|
|
23
|
+
// The setup-based main-process reporter requests declaration locations.
|
|
24
|
+
captureLocations = true
|
|
25
|
+
captureFactories(test, getCurrentSuite)
|
|
26
|
+
captureCollector(getCurrentSuite())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {Function & { fn: Function }} test
|
|
31
|
+
* @param {() => Collector} getCurrentSuite
|
|
32
|
+
*/
|
|
33
|
+
function captureFactories (test, getCurrentSuite) {
|
|
34
|
+
for (const target of [test, test.fn]) {
|
|
35
|
+
for (const method of declarationFactories) {
|
|
36
|
+
if (typeof target[method] === 'function') target[method] = wrapDeclaration(target[method], getCurrentSuite)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @param {Collector} collector */
|
|
42
|
+
function captureCollector (collector) {
|
|
43
|
+
if (capturedCollectors.has(collector)) return
|
|
44
|
+
capturedCollectors.add(collector)
|
|
45
|
+
|
|
46
|
+
const getCollector = () => collector
|
|
47
|
+
const declaration = collector.test.fn
|
|
48
|
+
const wrapped = wrapDeclaration(declaration, getCollector)
|
|
49
|
+
captureFactories(collector.test, getCollector)
|
|
50
|
+
// Vitest's exported test dispatches through .fn.call; suite-local chains close over .fn and use .apply.
|
|
51
|
+
// Native bindings avoid an extra stack frame inside Vitest's bounded declaration-location capture.
|
|
52
|
+
Object.defineProperties(declaration, {
|
|
53
|
+
call: {
|
|
54
|
+
value: Function.prototype.call.bind(wrapped),
|
|
55
|
+
writable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
},
|
|
58
|
+
apply: {
|
|
59
|
+
value: Function.prototype.apply.bind(wrapped),
|
|
60
|
+
writable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
const push = collector.tasks.push
|
|
65
|
+
collector.tasks.push = function (...tasks) {
|
|
66
|
+
for (const task of tasks) {
|
|
67
|
+
if (task.type === 'collector') captureCollector(task)
|
|
68
|
+
else if (captureLocations && task.type === 'test' && !task.location) {
|
|
69
|
+
const location = getDeclarationLocation(task.file?.filepath)
|
|
70
|
+
if (location) task.location = location
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return push.apply(this, tasks)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Captures declaration metadata before Vitest replaces callbacks for fixtures, timeouts and parameterized cases.
|
|
79
|
+
*
|
|
80
|
+
* @param {Function} declaration
|
|
81
|
+
* @param {() => Collector} getCurrentSuite
|
|
82
|
+
*/
|
|
83
|
+
function wrapDeclaration (declaration, getCurrentSuite) {
|
|
84
|
+
if (wrappedDeclarations.has(declaration)) return wrappedDeclarations.get(declaration)
|
|
85
|
+
const wrapped = new Proxy(declaration, {
|
|
86
|
+
apply (target, receiver, args) {
|
|
87
|
+
const collector = getCurrentSuite()
|
|
88
|
+
captureCollector(collector)
|
|
89
|
+
let annotations
|
|
90
|
+
let options
|
|
91
|
+
for (let index = 1; index < args.length; index++) {
|
|
92
|
+
const argument = args[index]
|
|
93
|
+
if (typeof argument === 'function') {
|
|
94
|
+
const observed = argument[Symbol.for('dd-trace:test-annotations')] || {}
|
|
95
|
+
if (observed.mustFail || observed.noAutoRetry) annotations = observed
|
|
96
|
+
} else if (argument && typeof argument === 'object') {
|
|
97
|
+
options = argument
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const hasFrameworkRetry = options?.retry !== undefined || collector.options?.retry !== undefined
|
|
101
|
+
if (!annotations && !hasFrameworkRetry) {
|
|
102
|
+
const result = Reflect.apply(target, receiver, args)
|
|
103
|
+
return typeof result === 'function' ? wrapDeclaration(result, getCurrentSuite) : result
|
|
104
|
+
}
|
|
105
|
+
const firstTask = collector.tasks.length
|
|
106
|
+
const result = Reflect.apply(target, receiver, args)
|
|
107
|
+
for (let index = firstTask; index < collector.tasks.length; index++) {
|
|
108
|
+
const task = collector.tasks[index]
|
|
109
|
+
if (task.type !== 'test') continue
|
|
110
|
+
if (hasFrameworkRetry) task.meta = { ...task.meta, __ddTestOptNativeRetry: true }
|
|
111
|
+
if (annotations) {
|
|
112
|
+
task.meta = {
|
|
113
|
+
...task.meta,
|
|
114
|
+
__ddTestOptAnnotations: {
|
|
115
|
+
mustFail: annotations.mustFail,
|
|
116
|
+
noAutoRetry: annotations.noAutoRetry,
|
|
117
|
+
hasFrameworkRetry: hasFrameworkRetry || task.meta?.__ddTestOptHasFrameworkRetry === true,
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return typeof result === 'function' ? wrapDeclaration(result, getCurrentSuite) : result
|
|
123
|
+
},
|
|
124
|
+
get (target, property, receiver) {
|
|
125
|
+
const value = Reflect.get(target, property, receiver)
|
|
126
|
+
return declarationMethods.has(property) && typeof value === 'function'
|
|
127
|
+
? wrapDeclaration(value, getCurrentSuite)
|
|
128
|
+
: value
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
wrappedDeclarations.set(wrapped, wrapped)
|
|
132
|
+
wrappedDeclarations.set(declaration, wrapped)
|
|
133
|
+
return wrapped
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param {string|undefined} filepath
|
|
138
|
+
* @returns {{ line: number, column: number }|undefined}
|
|
139
|
+
*/
|
|
140
|
+
function getDeclarationLocation (filepath) {
|
|
141
|
+
if (!filepath) return
|
|
142
|
+
try {
|
|
143
|
+
const limit = Error.stackTraceLimit
|
|
144
|
+
let error
|
|
145
|
+
try {
|
|
146
|
+
// Vitest's ten-frame budget can omit callers behind generated declarations and fixture chains.
|
|
147
|
+
Error.stackTraceLimit = 25
|
|
148
|
+
error = new Error('Datadog Vitest declaration')
|
|
149
|
+
} finally {
|
|
150
|
+
Error.stackTraceLimit = limit
|
|
151
|
+
}
|
|
152
|
+
if (typeof error.stack !== 'string') return
|
|
153
|
+
for (let frame of error.stack.split('\n')) {
|
|
154
|
+
if (!frame.includes(filepath)) {
|
|
155
|
+
try { frame = decodeURIComponent(frame) } catch { continue }
|
|
156
|
+
}
|
|
157
|
+
const start = frame.lastIndexOf(filepath)
|
|
158
|
+
if (start === -1) continue
|
|
159
|
+
const location = frame.slice(start + filepath.length).match(/^(?:[?#].*?)?:(\d+):(\d+)\)?$/)
|
|
160
|
+
if (location) return { line: Number(location[1]), column: Number(location[2]) }
|
|
161
|
+
}
|
|
162
|
+
} catch {}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Browser Mode serves this dependency as ESM without CommonJS conversion in independent projects.
|
|
166
|
+
if (typeof module === 'undefined') {
|
|
167
|
+
globalThis[Symbol.for('dd-trace.vitest.declaration-annotations')] = { captureDeclarations }
|
|
168
|
+
} else {
|
|
169
|
+
module.exports = { wrapDeclaration, captureDeclarations }
|
|
170
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const getConfig = require('../../config')
|
|
4
|
-
const { EVP_SUBDOMAIN_HEADER_NAME } = require('../../evp_proxy/constants')
|
|
5
|
-
const { joinEVPProxyPath } = require('../../evp_proxy/path')
|
|
6
4
|
const id = require('../../id')
|
|
7
5
|
const log = require('../../log')
|
|
8
6
|
const {
|
|
@@ -15,6 +13,7 @@ const {
|
|
|
15
13
|
TELEMETRY_TEST_MANAGEMENT_TESTS_RESPONSE_BYTES,
|
|
16
14
|
} = require('../telemetry')
|
|
17
15
|
const request = require('../requests/request')
|
|
16
|
+
const { createApiRequestRoute } = require('../requests/route')
|
|
18
17
|
const { buildCacheKey, writeToCache, withCache } = require('../requests/fs-cache')
|
|
19
18
|
const { validateTestManagementTestsResponse } = require('../test-optimization-http-cache-schema')
|
|
20
19
|
|
|
@@ -47,7 +46,7 @@ function parseJsonResponse (rawJson) {
|
|
|
47
46
|
function parseTestManagementTestsResponse (rawJson, options = {}) {
|
|
48
47
|
const parsedResponse = parseJsonResponse(rawJson)
|
|
49
48
|
if (options.validateRequiredFields) {
|
|
50
|
-
validateTestManagementTestsResponse(parsedResponse
|
|
49
|
+
validateTestManagementTestsResponse(parsedResponse)
|
|
51
50
|
}
|
|
52
51
|
const { data: { attributes: { modules: testManagementTests } } } = parsedResponse
|
|
53
52
|
return testManagementTests
|
|
@@ -117,32 +116,26 @@ function fetchFromApi ({
|
|
|
117
116
|
branch,
|
|
118
117
|
cacheKey,
|
|
119
118
|
}, done) {
|
|
119
|
+
const path = '/api/v2/test/libraries/test-management/tests'
|
|
120
|
+
const route = createApiRequestRoute(getConfig(), { url, path, isEvpProxy, evpProxyPrefix })
|
|
121
|
+
if (!route) {
|
|
122
|
+
return done(new Error('Test management tests were not fetched because Datadog API key is not defined.'))
|
|
123
|
+
}
|
|
124
|
+
|
|
120
125
|
const options = {
|
|
121
|
-
|
|
126
|
+
...route,
|
|
122
127
|
method: 'POST',
|
|
123
128
|
headers: {
|
|
129
|
+
...route.headers,
|
|
124
130
|
'Content-Type': 'application/json',
|
|
125
131
|
},
|
|
126
132
|
timeout: 20_000,
|
|
127
|
-
url,
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
if (isGzipCompatible) {
|
|
131
136
|
options.headers['accept-encoding'] = 'gzip'
|
|
132
137
|
}
|
|
133
138
|
|
|
134
|
-
if (isEvpProxy) {
|
|
135
|
-
options.path = joinEVPProxyPath(evpProxyPrefix, '/api/v2/test/libraries/test-management/tests')
|
|
136
|
-
options.headers[EVP_SUBDOMAIN_HEADER_NAME] = 'api'
|
|
137
|
-
} else {
|
|
138
|
-
const { DD_API_KEY } = getConfig()
|
|
139
|
-
if (!DD_API_KEY) {
|
|
140
|
-
return done(new Error('Test management tests were not fetched because Datadog API key is not defined.'))
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
options.headers['dd-api-key'] = DD_API_KEY
|
|
144
|
-
}
|
|
145
|
-
|
|
146
139
|
const data = JSON.stringify({
|
|
147
140
|
data: {
|
|
148
141
|
id: id().toString(10),
|
|
@@ -13,25 +13,7 @@ const REQUIRED_SETTINGS_KEYS = [
|
|
|
13
13
|
'impacted_tests_enabled',
|
|
14
14
|
'coverage_report_upload_enabled',
|
|
15
15
|
]
|
|
16
|
-
const SETTINGS_BOOLEAN_KEYS = [
|
|
17
|
-
'code_coverage',
|
|
18
|
-
'tests_skipping',
|
|
19
|
-
'itr_enabled',
|
|
20
|
-
'require_git',
|
|
21
|
-
'flaky_test_retries_enabled',
|
|
22
|
-
'di_enabled',
|
|
23
|
-
'known_tests_enabled',
|
|
24
|
-
'impacted_tests_enabled',
|
|
25
|
-
'coverage_report_upload_enabled',
|
|
26
|
-
]
|
|
27
|
-
const EARLY_FLAKE_DETECTION_KEYS = ['enabled', 'faulty_session_threshold', 'slow_test_retries']
|
|
28
|
-
const TEST_MANAGEMENT_KEYS = ['attempt_to_fix_retries', 'enabled']
|
|
29
|
-
const RETRY_THRESHOLD_PATTERN = /^\d+(?:ms|[smh])$/
|
|
30
|
-
const MAX_VALIDATION_MODULES = 1000
|
|
31
|
-
const MAX_VALIDATION_SUITES = 10_000
|
|
32
|
-
const MAX_VALIDATION_TESTS = 100_000
|
|
33
16
|
const MAX_RETRIES = 100
|
|
34
|
-
const MAX_VALIDATION_STRING_BYTES = 4096
|
|
35
17
|
|
|
36
18
|
function isObject (value) {
|
|
37
19
|
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
@@ -57,7 +39,7 @@ function getAttributes (response, endpoint) {
|
|
|
57
39
|
return attributes
|
|
58
40
|
}
|
|
59
41
|
|
|
60
|
-
function validateSettingsResponse (response
|
|
42
|
+
function validateSettingsResponse (response) {
|
|
61
43
|
const attributes = response?.data?.attributes ?? response
|
|
62
44
|
assertObject(attributes, 'Invalid settings response: attributes must be an object')
|
|
63
45
|
assertHasKeys(attributes, REQUIRED_SETTINGS_KEYS, 'settings')
|
|
@@ -65,26 +47,9 @@ function validateSettingsResponse (response, options = {}) {
|
|
|
65
47
|
assertObject(attributes.test_management, 'Invalid settings response: test_management must be an object')
|
|
66
48
|
assertHasKeys(attributes.early_flake_detection, ['enabled'], 'settings early_flake_detection')
|
|
67
49
|
assertHasKeys(attributes.test_management, ['enabled'], 'settings test_management')
|
|
68
|
-
if (!options.validationMode) return
|
|
69
|
-
|
|
70
|
-
assertOnlyKeys(attributes, REQUIRED_SETTINGS_KEYS, 'settings')
|
|
71
|
-
assertOnlyKeys(attributes.early_flake_detection, EARLY_FLAKE_DETECTION_KEYS, 'settings early_flake_detection')
|
|
72
|
-
assertOnlyKeys(attributes.test_management, TEST_MANAGEMENT_KEYS, 'settings test_management')
|
|
73
|
-
assertBooleanFields(attributes, SETTINGS_BOOLEAN_KEYS, 'settings')
|
|
74
|
-
assertBooleanFields(attributes.early_flake_detection, ['enabled'], 'settings early_flake_detection')
|
|
75
|
-
assertBooleanFields(attributes.test_management, ['enabled'], 'settings test_management')
|
|
76
|
-
assertOptionalBoundedNumber(
|
|
77
|
-
attributes.early_flake_detection.faulty_session_threshold,
|
|
78
|
-
'settings early_flake_detection faulty_session_threshold'
|
|
79
|
-
)
|
|
80
|
-
assertRetryMap(attributes.early_flake_detection.slow_test_retries)
|
|
81
|
-
assertOptionalBoundedNumber(
|
|
82
|
-
attributes.test_management.attempt_to_fix_retries,
|
|
83
|
-
'settings test_management attempt_to_fix_retries'
|
|
84
|
-
)
|
|
85
50
|
}
|
|
86
51
|
|
|
87
|
-
function validateKnownTestsResponse (response
|
|
52
|
+
function validateKnownTestsResponse (response) {
|
|
88
53
|
const attributes = getAttributes(response, 'known tests')
|
|
89
54
|
assertHasKeys(attributes, ['tests'], 'known tests')
|
|
90
55
|
|
|
@@ -92,46 +57,26 @@ function validateKnownTestsResponse (response, options = {}) {
|
|
|
92
57
|
if (tests === null) return
|
|
93
58
|
assertObject(tests, 'Invalid known tests response: tests must be an object or null')
|
|
94
59
|
|
|
95
|
-
|
|
96
|
-
let testCount = 0
|
|
97
|
-
const modules = Object.entries(tests)
|
|
98
|
-
if (options.validationMode && modules.length > MAX_VALIDATION_MODULES) {
|
|
99
|
-
throw new Error('Invalid known tests response: too many modules')
|
|
100
|
-
}
|
|
101
|
-
for (const [moduleName, suites] of modules) {
|
|
102
|
-
if (options.validationMode) assertValidationString(moduleName, 'known tests module')
|
|
60
|
+
for (const suites of Object.values(tests)) {
|
|
103
61
|
assertObject(suites, 'Invalid known tests response: module suites must be objects')
|
|
104
|
-
for (const
|
|
105
|
-
suiteCount++
|
|
106
|
-
if (options.validationMode) {
|
|
107
|
-
if (suiteCount > MAX_VALIDATION_SUITES) throw new Error('Invalid known tests response: too many suites')
|
|
108
|
-
assertValidationString(suiteName, 'known tests suite')
|
|
109
|
-
}
|
|
62
|
+
for (const testNames of Object.values(suites)) {
|
|
110
63
|
if (!Array.isArray(testNames)) {
|
|
111
64
|
throw new TypeError('Invalid known tests response: suite tests must be arrays')
|
|
112
65
|
}
|
|
113
66
|
for (const testName of testNames) {
|
|
114
|
-
testCount++
|
|
115
67
|
if (typeof testName !== 'string') {
|
|
116
68
|
throw new TypeError('Invalid known tests response: test names must be strings')
|
|
117
69
|
}
|
|
118
|
-
if (options.validationMode) {
|
|
119
|
-
if (testCount > MAX_VALIDATION_TESTS) throw new Error('Invalid known tests response: too many tests')
|
|
120
|
-
assertValidationString(testName, 'known test name')
|
|
121
|
-
}
|
|
122
70
|
}
|
|
123
71
|
}
|
|
124
72
|
}
|
|
125
73
|
}
|
|
126
74
|
|
|
127
|
-
function validateSkippableTestsResponse (response
|
|
75
|
+
function validateSkippableTestsResponse (response) {
|
|
128
76
|
assertObject(response, 'Invalid skippable tests response: response must be an object')
|
|
129
77
|
if (!Array.isArray(response.data)) {
|
|
130
78
|
throw new TypeError('Invalid skippable tests response: data must be an array')
|
|
131
79
|
}
|
|
132
|
-
if (options.validationMode && response.data.length > MAX_VALIDATION_TESTS) {
|
|
133
|
-
throw new Error('Invalid skippable tests response: too many items')
|
|
134
|
-
}
|
|
135
80
|
if (response.meta !== undefined) {
|
|
136
81
|
assertObject(response.meta, 'Invalid skippable tests response: meta must be an object')
|
|
137
82
|
}
|
|
@@ -147,56 +92,28 @@ function validateSkippableTestsResponse (response, options = {}) {
|
|
|
147
92
|
if (typeof item.type !== 'string') {
|
|
148
93
|
throw new TypeError('Invalid skippable tests response: data entry type must be a string')
|
|
149
94
|
}
|
|
150
|
-
if (options.validationMode) assertValidationString(item.type, 'skippable test type')
|
|
151
95
|
assertObject(item.attributes, 'Invalid skippable tests response: data entry attributes must be an object')
|
|
152
96
|
if ((item.type === 'suite' || item.type === 'test') && typeof item.attributes.suite !== 'string') {
|
|
153
97
|
throw new Error('Invalid skippable tests response: data entry suite must be a string')
|
|
154
98
|
}
|
|
155
|
-
if (options.validationMode && item.attributes.suite !== undefined) {
|
|
156
|
-
assertValidationString(item.attributes.suite, 'skippable test suite')
|
|
157
|
-
}
|
|
158
99
|
if (item.type === 'test' && typeof item.attributes.name !== 'string') {
|
|
159
100
|
throw new Error('Invalid skippable tests response: data entry name must be a string')
|
|
160
101
|
}
|
|
161
|
-
if (options.validationMode && item.attributes.name !== undefined) {
|
|
162
|
-
assertValidationString(item.attributes.name, 'skippable test name')
|
|
163
|
-
}
|
|
164
102
|
}
|
|
165
103
|
}
|
|
166
104
|
|
|
167
|
-
function validateTestManagementTestsResponse (response
|
|
105
|
+
function validateTestManagementTestsResponse (response) {
|
|
168
106
|
const attributes = getAttributes(response, 'test management tests')
|
|
169
107
|
assertHasKeys(attributes, ['modules'], 'test management tests')
|
|
170
108
|
assertObject(attributes.modules, 'Invalid test management tests response: modules must be an object')
|
|
171
109
|
|
|
172
|
-
|
|
173
|
-
let testCount = 0
|
|
174
|
-
const modules = Object.entries(attributes.modules)
|
|
175
|
-
if (options.validationMode && modules.length > MAX_VALIDATION_MODULES) {
|
|
176
|
-
throw new Error('Invalid test management tests response: too many modules')
|
|
177
|
-
}
|
|
178
|
-
for (const [moduleName, testModule] of modules) {
|
|
179
|
-
if (options.validationMode) assertValidationString(moduleName, 'test management module')
|
|
110
|
+
for (const testModule of Object.values(attributes.modules)) {
|
|
180
111
|
assertObject(testModule, 'Invalid test management tests response: modules entries must be objects')
|
|
181
112
|
assertObject(testModule.suites, 'Invalid test management tests response: module suites must be objects')
|
|
182
|
-
for (const
|
|
183
|
-
suiteCount++
|
|
184
|
-
if (options.validationMode) {
|
|
185
|
-
if (suiteCount > MAX_VALIDATION_SUITES) {
|
|
186
|
-
throw new Error('Invalid test management tests response: too many suites')
|
|
187
|
-
}
|
|
188
|
-
assertValidationString(suiteName, 'test management suite')
|
|
189
|
-
}
|
|
113
|
+
for (const suite of Object.values(testModule.suites)) {
|
|
190
114
|
assertObject(suite, 'Invalid test management tests response: suites entries must be objects')
|
|
191
115
|
assertObject(suite.tests, 'Invalid test management tests response: suite tests must be objects')
|
|
192
|
-
for (const
|
|
193
|
-
testCount++
|
|
194
|
-
if (options.validationMode) {
|
|
195
|
-
if (testCount > MAX_VALIDATION_TESTS) {
|
|
196
|
-
throw new Error('Invalid test management tests response: too many tests')
|
|
197
|
-
}
|
|
198
|
-
assertValidationString(testName, 'test management test')
|
|
199
|
-
}
|
|
116
|
+
for (const test of Object.values(suite.tests)) {
|
|
200
117
|
assertObject(test, 'Invalid test management tests response: tests entries must be objects')
|
|
201
118
|
assertObject(test.properties, 'Invalid test management tests response: test properties must be objects')
|
|
202
119
|
}
|
|
@@ -204,48 +121,6 @@ function validateTestManagementTestsResponse (response, options = {}) {
|
|
|
204
121
|
}
|
|
205
122
|
}
|
|
206
123
|
|
|
207
|
-
function assertBooleanFields (object, keys, endpoint) {
|
|
208
|
-
for (const key of keys) {
|
|
209
|
-
if (typeof object[key] !== 'boolean') {
|
|
210
|
-
throw new TypeError(`Invalid ${endpoint} response: ${key} must be a boolean`)
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function assertOptionalBoundedNumber (value, endpoint) {
|
|
216
|
-
if (value === undefined) return
|
|
217
|
-
if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > MAX_RETRIES) {
|
|
218
|
-
throw new TypeError(`Invalid ${endpoint}: value must be between 0 and ${MAX_RETRIES}`)
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function assertRetryMap (retries) {
|
|
223
|
-
if (retries === undefined) return
|
|
224
|
-
assertObject(retries, 'Invalid settings response: early_flake_detection slow_test_retries must be an object')
|
|
225
|
-
for (const [threshold, count] of Object.entries(retries)) {
|
|
226
|
-
assertValidationString(threshold, 'early flake detection retry threshold')
|
|
227
|
-
if (!RETRY_THRESHOLD_PATTERN.test(threshold)) {
|
|
228
|
-
throw new TypeError('Invalid early flake detection retry threshold: expected a duration such as 5s')
|
|
229
|
-
}
|
|
230
|
-
assertOptionalBoundedNumber(count, `early flake detection retry count ${threshold}`)
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function assertOnlyKeys (object, keys, endpoint) {
|
|
235
|
-
const allowed = new Set(keys)
|
|
236
|
-
for (const key of Object.keys(object)) {
|
|
237
|
-
if (!allowed.has(key)) {
|
|
238
|
-
throw new Error(`Invalid ${endpoint} response: unexpected ${key}`)
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function assertValidationString (value, field) {
|
|
244
|
-
if (typeof value !== 'string' || Buffer.byteLength(value) > MAX_VALIDATION_STRING_BYTES) {
|
|
245
|
-
throw new TypeError(`Invalid ${field}: value must be a bounded string`)
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
124
|
module.exports = {
|
|
250
125
|
MAX_RETRIES,
|
|
251
126
|
validateKnownTestsResponse,
|