mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-29 11:40:40 +00:00
Compare commits
4 Commits
perf/uplot
...
ci/e2e-aff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab863107fa | ||
|
|
ffa8ce6116 | ||
|
|
770c471ea0 | ||
|
|
8214e16248 |
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -140,6 +140,7 @@ go.mod @therealpandey
|
||||
|
||||
# e2e tests
|
||||
/tests/e2e/ @AshwinBhatkal
|
||||
/tests/e2e/affected.json @SigNoz/frontend-maintainers @AshwinBhatkal
|
||||
|
||||
# Flagger Owners
|
||||
|
||||
|
||||
53
.github/workflows/e2eci.yaml
vendored
53
.github/workflows/e2eci.yaml
vendored
@@ -22,6 +22,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
e2e: ${{ steps.changes.outputs.e2e }}
|
||||
shards: ${{ steps.plan.outputs.shards }}
|
||||
shard-count: ${{ steps.plan.outputs.shard-count }}
|
||||
steps:
|
||||
- name: changes
|
||||
id: changes
|
||||
@@ -37,12 +39,49 @@ jobs:
|
||||
|
||||
CHANGED_FILES=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" --paginate --jq '.[].filename | select((startswith("tests/integration/") or startswith("frontend/src/api/generated/")) | not)')
|
||||
PATTERN='^(frontend/|tests/|\.github/workflows/e2eci\.yaml$|cmd/enterprise/Dockerfile\.with-web\.integration$)'
|
||||
printf '%s\n' "$CHANGED_FILES" | grep -E "$PATTERN" > "$RUNNER_TEMP/changed.txt" || true
|
||||
|
||||
if printf '%s\n' "$CHANGED_FILES" | grep -qE "$PATTERN"; then
|
||||
echo "e2e=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "e2e=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: checkout
|
||||
if: steps.changes.outputs.e2e == 'true'
|
||||
uses: actions/checkout@v4
|
||||
- name: node
|
||||
if: steps.changes.outputs.e2e == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
- name: install-pnpm
|
||||
if: steps.changes.outputs.e2e == 'true'
|
||||
uses: pnpm/action-setup@v6
|
||||
with:
|
||||
version: 10
|
||||
- name: pnpm-install
|
||||
if: steps.changes.outputs.e2e == 'true'
|
||||
run: |
|
||||
cd tests/e2e && pnpm install --frozen-lockfile
|
||||
- name: plan
|
||||
id: plan
|
||||
if: steps.changes.outputs.e2e == 'true'
|
||||
env:
|
||||
FORCE: ${{ github.event_name == 'merge_group' || contains(github.event.pull_request.labels.*.name, 'safe-to-e2e') }}
|
||||
run: |
|
||||
cd tests/e2e
|
||||
if [ "$FORCE" = "true" ]; then
|
||||
node scripts/plan.mjs --all < /dev/null
|
||||
else
|
||||
node scripts/plan.mjs < "$RUNNER_TEMP/changed.txt"
|
||||
fi
|
||||
- name: upload-plan
|
||||
if: steps.changes.outputs.e2e == 'true'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-plan
|
||||
path: tests/e2e/artifacts/plan/
|
||||
retention-days: 5
|
||||
fmtlint:
|
||||
needs: changes
|
||||
if: github.event_name != 'merge_group' && needs.changes.outputs.e2e == 'true'
|
||||
@@ -67,15 +106,18 @@ jobs:
|
||||
- name: lint
|
||||
run: |
|
||||
cd tests/e2e && pnpm lint
|
||||
- name: test-scripts
|
||||
run: |
|
||||
cd tests/e2e && pnpm test:scripts
|
||||
test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project:
|
||||
- chromium
|
||||
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
shard: ${{ fromJSON(needs.changes.outputs.shards) }}
|
||||
needs: changes
|
||||
if: needs.changes.outputs.e2e == 'true'
|
||||
if: needs.changes.outputs.e2e == 'true' && needs.changes.outputs.shards != '[]'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
@@ -165,10 +207,15 @@ jobs:
|
||||
e2e/bootstrap/setup.py::test_setup
|
||||
- name: wait-playwright-browsers
|
||||
wait: playwright-browsers
|
||||
- name: download-plan
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: e2e-plan
|
||||
path: tests/e2e/artifacts/plan
|
||||
- name: playwright-test
|
||||
run: |
|
||||
cd tests/e2e && \
|
||||
pnpm playwright test --project=${{ matrix.project }} --shard=${{ matrix.shard }}/10
|
||||
pnpm playwright test --project=${{ matrix.project }} --test-list artifacts/plan/tests.txt --shard=${{ matrix.shard }}/${{ needs.changes.outputs.shard-count }}
|
||||
- name: teardown-stack
|
||||
if: always()
|
||||
run: |
|
||||
|
||||
@@ -314,6 +314,23 @@ cp .env.example .env # fill SIGNOZ_E2E_USERNAME / PASSWORD
|
||||
pnpm test:staging
|
||||
```
|
||||
|
||||
### Which specs run on a PR
|
||||
|
||||
`e2eci` runs the specs a change can reach plus the `@smoke` set, on one shard per 80 tests.
|
||||
|
||||
- A frontend change is traced up the import graph to the pages the router loads. `affected.json` maps each spec folder to the pages its specs visit. Pages under the `@smoke` key are covered by the smoke set alone.
|
||||
- A changed spec runs itself. A changed driver runs every spec that imports it.
|
||||
- The full suite runs when a change reaches the app shell, sits outside the module graph (a lockfile, `package.json`, a public asset, `bootstrap/`, `testdata/`), touches the e2e workflow or the shared Python fixtures, or reaches a page `affected.json` doesn't name.
|
||||
- Backend changes don't pick specs. The merge queue and the `safe-to-e2e` label always run the full suite.
|
||||
|
||||
When you add a spec folder or a page, add it to `affected.json`. A folder whose specs all run as `@smoke` gets an empty list. `pnpm test:scripts` fails until every spec folder and page has an entry. Add `@smoke` to a describe title only for a core path every PR should check.
|
||||
|
||||
```bash
|
||||
pnpm plan # what your branch would run, against origin/main
|
||||
pnpm test:smoke # the smoke set
|
||||
pnpm test:scripts # check affected.json and the spec selection
|
||||
```
|
||||
|
||||
## How to configure different options for E2E tests?
|
||||
|
||||
### Environment variables
|
||||
|
||||
138
tests/e2e/affected.json
Normal file
138
tests/e2e/affected.json
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"alerts": [
|
||||
"frontend/src/pages/AlertList",
|
||||
"frontend/src/pages/CreateAlert",
|
||||
"frontend/src/pages/EditRules",
|
||||
"frontend/src/pages/LogsModulePage",
|
||||
"frontend/src/pages/TracesModulePage"
|
||||
],
|
||||
"api-monitoring": [
|
||||
"frontend/src/pages/ApiMonitoring"
|
||||
],
|
||||
"app-shell": [
|
||||
"frontend/src/pages/DashboardsListPage",
|
||||
"frontend/src/pages/HomePage",
|
||||
"frontend/src/pages/Services",
|
||||
"frontend/src/pages/Settings"
|
||||
],
|
||||
"auth": [
|
||||
"frontend/src/pages/ForgotPassword",
|
||||
"frontend/src/pages/HomePage",
|
||||
"frontend/src/pages/Login",
|
||||
"frontend/src/pages/ResetPassword",
|
||||
"frontend/src/pages/SignUp"
|
||||
],
|
||||
"dashboards": [
|
||||
"frontend/src/pages/DashboardsListPage",
|
||||
"frontend/src/pages/DashboardPage",
|
||||
"frontend/src/pages/HomePage",
|
||||
"frontend/src/pages/LogsModulePage"
|
||||
],
|
||||
"exceptions": [
|
||||
"frontend/src/pages/AllErrors",
|
||||
"frontend/src/pages/ErrorDetails",
|
||||
"frontend/src/pages/TraceDetailsV3"
|
||||
],
|
||||
"home": [
|
||||
"frontend/src/pages/HomePage",
|
||||
"frontend/src/pages/LogsModulePage"
|
||||
],
|
||||
"infra-monitoring": [
|
||||
"frontend/src/pages/InfrastructureMonitoring"
|
||||
],
|
||||
"integrations": [
|
||||
"frontend/src/pages/IntegrationsDetailsPage",
|
||||
"frontend/src/pages/IntegrationsModulePage"
|
||||
],
|
||||
"llm-o11y": [
|
||||
"frontend/src/pages/LLMObservability"
|
||||
],
|
||||
"logs-explorer": [
|
||||
"frontend/src/pages/LogsModulePage",
|
||||
"frontend/src/pages/LogsSettings"
|
||||
],
|
||||
"logs-pipelines": [
|
||||
"frontend/src/pages/LogsModulePage"
|
||||
],
|
||||
"messaging-queues": [
|
||||
"frontend/src/pages/Celery",
|
||||
"frontend/src/pages/MessagingQueues"
|
||||
],
|
||||
"meter": [
|
||||
"frontend/src/pages/MeterExplorer"
|
||||
],
|
||||
"metrics-explorer": [
|
||||
"frontend/src/pages/DashboardsListPage",
|
||||
"frontend/src/pages/MetricsExplorer"
|
||||
],
|
||||
"noz": [
|
||||
"frontend/src/pages/AIAssistantPage",
|
||||
"frontend/src/pages/HomePage",
|
||||
"frontend/src/pages/LogsModulePage"
|
||||
],
|
||||
"onboarding": [
|
||||
"frontend/src/pages/HomePage",
|
||||
"frontend/src/pages/OnboardingPageV2",
|
||||
"frontend/src/pages/OrgOnboarding",
|
||||
"frontend/src/pages/Services"
|
||||
],
|
||||
"public-dashboard": [
|
||||
"frontend/src/pages/DashboardPage",
|
||||
"frontend/src/pages/PublicDashboard"
|
||||
],
|
||||
"query-builder": [
|
||||
"frontend/src/pages/CreateAlert",
|
||||
"frontend/src/pages/DashboardPage",
|
||||
"frontend/src/pages/EditRules",
|
||||
"frontend/src/pages/LogsModulePage",
|
||||
"frontend/src/pages/MetricsExplorer",
|
||||
"frontend/src/pages/TracesModulePage"
|
||||
],
|
||||
"quick-filters": [
|
||||
"frontend/src/pages/LogsModulePage"
|
||||
],
|
||||
"routing": [],
|
||||
"saved-views": [
|
||||
"frontend/src/pages/LogsModulePage",
|
||||
"frontend/src/pages/MeterExplorer",
|
||||
"frontend/src/pages/MetricsExplorer",
|
||||
"frontend/src/pages/TracesModulePage"
|
||||
],
|
||||
"service-map": [
|
||||
"frontend/src/modules/Servicemap",
|
||||
"frontend/src/pages/Services"
|
||||
],
|
||||
"services": [
|
||||
"frontend/src/pages/MetricsApplication",
|
||||
"frontend/src/pages/ServiceTopLevelOperations",
|
||||
"frontend/src/pages/Services"
|
||||
],
|
||||
"settings": [
|
||||
"frontend/src/pages/Settings"
|
||||
],
|
||||
"sso": [
|
||||
"frontend/src/pages/Login",
|
||||
"frontend/src/pages/Settings"
|
||||
],
|
||||
"trace-details": [
|
||||
"frontend/src/pages/TraceDetailsV3"
|
||||
],
|
||||
"traces-explorer": [
|
||||
"frontend/src/pages/TraceDetailsV3",
|
||||
"frontend/src/pages/TracesModulePage"
|
||||
],
|
||||
"traces-funnels": [
|
||||
"frontend/src/pages/TracesModulePage"
|
||||
],
|
||||
"@smoke": [
|
||||
"frontend/src/modules/Usage",
|
||||
"frontend/src/pages/ErrorBoundaryFallback",
|
||||
"frontend/src/pages/License",
|
||||
"frontend/src/pages/Status",
|
||||
"frontend/src/pages/Support",
|
||||
"frontend/src/pages/UnAuthorized",
|
||||
"frontend/src/pages/WorkspaceAccessRestricted",
|
||||
"frontend/src/pages/WorkspaceLocked",
|
||||
"frontend/src/pages/WorkspaceSuspended"
|
||||
]
|
||||
}
|
||||
@@ -17,16 +17,19 @@
|
||||
"test:headed": "playwright test --headed",
|
||||
"test:debug": "playwright test --debug",
|
||||
"test:chromium": "playwright test --project=chromium",
|
||||
"test:smoke": "playwright test --project=chromium --grep @smoke",
|
||||
"test:firefox": "playwright test --project=firefox",
|
||||
"test:webkit": "playwright test --project=webkit",
|
||||
"report": "playwright show-report artifacts/html",
|
||||
"codegen": "playwright codegen",
|
||||
"plan": "node scripts/plan.mjs",
|
||||
"install:browsers": "playwright install",
|
||||
"install:cli": "npm install -g @playwright/cli@latest && playwright-cli install --skills",
|
||||
"fmt": "oxfmt .",
|
||||
"fmt:check": "oxfmt --check .",
|
||||
"lint": "oxlint .",
|
||||
"lint:fix": "oxlint . --fix",
|
||||
"test:scripts": "node scripts/affected.test.mjs",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
206
tests/e2e/scripts/affected.mjs
Normal file
206
tests/e2e/scripts/affected.mjs
Normal file
@@ -0,0 +1,206 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import ts from 'typescript';
|
||||
|
||||
import { E2E_DIR, REPO_DIR } from './utils.mjs';
|
||||
|
||||
const FEATURES = Object.entries(
|
||||
JSON.parse(fs.readFileSync(path.join(E2E_DIR, 'affected.json'), 'utf8')),
|
||||
);
|
||||
export const FEATURE_NAMES = FEATURES.map(([feature]) => feature);
|
||||
const ROUTER = path.join(REPO_DIR, 'frontend/src/AppRoutes/pageComponents.ts');
|
||||
const ENTRY = path.join(REPO_DIR, 'frontend/src/index.tsx');
|
||||
const SPECS_DIR = path.join(E2E_DIR, 'tests');
|
||||
const E2E_SOURCE = /^tests\/e2e\/(tests|drivers|bootstrap)\/.+\.ts$/;
|
||||
const SOURCE = /\.[cm]?[jt]sx?$/;
|
||||
const IGNORED = [
|
||||
/\.md$/,
|
||||
/^docs\//,
|
||||
/^tests\/integration\//,
|
||||
/^frontend\/\.(storybook|husky)\//,
|
||||
/^frontend\/src\/(storybook|mocks-server)\//,
|
||||
/^frontend\/(.*\/)?(__tests__|__mocks__)\//,
|
||||
/^frontend\/.*\.(test|spec|stories)\.[jt]sx?$/,
|
||||
];
|
||||
|
||||
const isIgnored = (file) => IGNORED.some((pattern) => pattern.test(file));
|
||||
const relative = (file) => path.relative(REPO_DIR, file);
|
||||
const isUnder = (file, root) =>
|
||||
file === root || file.startsWith(`${root}/`) || file.startsWith(`${root}.`);
|
||||
const featuresOf = (file) =>
|
||||
FEATURES.filter(([, roots]) => roots.some((root) => isUnder(file, root)));
|
||||
|
||||
function importersOf(tsconfigPath) {
|
||||
const { config } = ts.readConfigFile(tsconfigPath, (file) =>
|
||||
ts.sys.readFile(file),
|
||||
);
|
||||
const { options, fileNames } = ts.parseJsonConfigFileContent(
|
||||
config,
|
||||
ts.sys,
|
||||
path.dirname(tsconfigPath),
|
||||
);
|
||||
const cache = ts.createModuleResolutionCache(
|
||||
path.dirname(tsconfigPath),
|
||||
(name) => name,
|
||||
options,
|
||||
);
|
||||
const aliases = Object.entries(options.paths ?? {});
|
||||
const aliasBase = options.pathsBasePath ?? path.dirname(tsconfigPath);
|
||||
|
||||
const resolve = (specifier, from) => {
|
||||
const { resolvedModule } = ts.resolveModuleName(
|
||||
specifier,
|
||||
from,
|
||||
options,
|
||||
ts.sys,
|
||||
cache,
|
||||
);
|
||||
if (resolvedModule) {
|
||||
return resolvedModule.isExternalLibraryImport
|
||||
? undefined
|
||||
: path.resolve(resolvedModule.resolvedFileName);
|
||||
}
|
||||
// TypeScript resolves only modules, so styles and assets are matched here.
|
||||
const candidates = specifier.startsWith('.')
|
||||
? [path.resolve(path.dirname(from), specifier)]
|
||||
: aliases.flatMap(([pattern, targets]) => {
|
||||
const prefix = pattern.replace(/\*$/, '');
|
||||
const matches = pattern.endsWith('*')
|
||||
? specifier.startsWith(prefix)
|
||||
: specifier === pattern;
|
||||
return matches
|
||||
? targets.map((target) =>
|
||||
path.resolve(
|
||||
aliasBase,
|
||||
target.replace('*', specifier.slice(prefix.length)),
|
||||
),
|
||||
)
|
||||
: [];
|
||||
});
|
||||
return candidates.find((candidate) =>
|
||||
fs.statSync(candidate, { throwIfNoEntry: false })?.isFile(),
|
||||
);
|
||||
};
|
||||
|
||||
const importers = new Map();
|
||||
for (const file of fileNames) {
|
||||
const { importedFiles } = ts.preProcessFile(
|
||||
fs.readFileSync(file, 'utf8'),
|
||||
true,
|
||||
true,
|
||||
);
|
||||
for (const { fileName } of importedFiles) {
|
||||
const target = resolve(fileName, file);
|
||||
if (target) {
|
||||
if (!importers.has(target)) {
|
||||
importers.set(target, new Set());
|
||||
}
|
||||
importers.get(target).add(path.resolve(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
return importers;
|
||||
}
|
||||
|
||||
// Walks importers up from `start`. `tops` are files nothing imports; `routes`
|
||||
// are files imported straight by the router.
|
||||
function climb(start, importers, isRouter) {
|
||||
const seen = new Set([start]);
|
||||
const queue = [start];
|
||||
const tops = [];
|
||||
const routes = [];
|
||||
while (queue.length) {
|
||||
const file = queue.pop();
|
||||
const parents = importers.get(file) ?? new Set();
|
||||
if (!parents.size) {
|
||||
tops.push(file);
|
||||
}
|
||||
for (const parent of parents) {
|
||||
if (isRouter(parent)) {
|
||||
routes.push(file);
|
||||
} else if (!seen.has(parent)) {
|
||||
seen.add(parent);
|
||||
queue.push(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return { tops, routes };
|
||||
}
|
||||
|
||||
// Spec files and feature folders a change can affect. `all` is set when any
|
||||
// changed file can't be traced to them.
|
||||
export function affected(changedFiles) {
|
||||
const reasons = [];
|
||||
const features = new Set();
|
||||
const specs = new Set();
|
||||
let frontend;
|
||||
let e2e;
|
||||
|
||||
for (const changed of changedFiles) {
|
||||
const file = path.join(REPO_DIR, changed);
|
||||
// A deleted module or style's importers are in the change as well.
|
||||
const isDeletedImport =
|
||||
!fs.existsSync(file) &&
|
||||
(SOURCE.test(changed) || changed.startsWith('frontend/src/'));
|
||||
if (isIgnored(changed) || isDeletedImport) {
|
||||
continue;
|
||||
}
|
||||
if (changed.startsWith('frontend/')) {
|
||||
frontend ??= importersOf(path.join(REPO_DIR, 'frontend/tsconfig.json'));
|
||||
const { tops, routes } = climb(
|
||||
file,
|
||||
frontend,
|
||||
(parent) => parent === ROUTER,
|
||||
);
|
||||
// Other tops are dead code, tests or stories. A file outside the module
|
||||
// graph (config, lockfile, public asset, scss partial) is never traced.
|
||||
const isModule = SOURCE.test(changed) && changed.startsWith('frontend/src/');
|
||||
if (tops.includes(ENTRY)) {
|
||||
reasons.push(`${changed} reaches the app shell`);
|
||||
} else if (tops.includes(file) && !isModule) {
|
||||
reasons.push(`${changed} has no importer`);
|
||||
}
|
||||
for (const route of routes) {
|
||||
const matched = featuresOf(relative(route));
|
||||
if (!matched.length) {
|
||||
reasons.push(`${changed} reaches ${relative(route)}, unmapped`);
|
||||
}
|
||||
matched.forEach(([feature]) => features.add(feature));
|
||||
}
|
||||
} else if (E2E_SOURCE.test(changed)) {
|
||||
e2e ??= importersOf(path.join(E2E_DIR, 'tsconfig.json'));
|
||||
for (const top of climb(file, e2e, () => false).tops) {
|
||||
if (top.startsWith(`${SPECS_DIR}/`)) {
|
||||
specs.add(path.relative(SPECS_DIR, top));
|
||||
} else {
|
||||
reasons.push(`${changed} reaches ${relative(top)}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reasons.push(`${changed} is not traced`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
all: reasons.length > 0,
|
||||
reasons,
|
||||
features: [...features].sort((a, b) => a.localeCompare(b)),
|
||||
specs: [...specs].sort((a, b) => a.localeCompare(b)),
|
||||
};
|
||||
}
|
||||
|
||||
// Spec folders and lazily loaded pages that affected.json does not name.
|
||||
export function unmapped() {
|
||||
const folders = fs
|
||||
.readdirSync(SPECS_DIR, { withFileTypes: true })
|
||||
.filter((entry) => entry.isDirectory() && !FEATURE_NAMES.includes(entry.name))
|
||||
.map((entry) => entry.name);
|
||||
const pages = [
|
||||
...fs
|
||||
.readFileSync(ROUTER, 'utf8')
|
||||
.matchAll(/import\(\s*(?:\/\*.*?\*\/\s*)?'([^']+)'/gs),
|
||||
]
|
||||
.map(([, specifier]) => `frontend/src/${specifier}`)
|
||||
.filter((page) => !featuresOf(page).length);
|
||||
return { folders, pages };
|
||||
}
|
||||
40
tests/e2e/scripts/affected.test.mjs
Normal file
40
tests/e2e/scripts/affected.test.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { affected, unmapped } from './affected.mjs';
|
||||
|
||||
assert.deepEqual(
|
||||
affected(['frontend/src/pages/AlertList/index.tsx']).features,
|
||||
['alerts'],
|
||||
'a page change selects the features mapped to its route',
|
||||
);
|
||||
|
||||
for (const file of [
|
||||
'frontend/.storybook/preview.tsx',
|
||||
'docs/api/openapi.yml',
|
||||
]) {
|
||||
assert.deepEqual(
|
||||
affected([file]),
|
||||
{ all: false, reasons: [], features: [], specs: [] },
|
||||
`${file} selects nothing`,
|
||||
);
|
||||
}
|
||||
|
||||
assert.deepEqual(
|
||||
affected(['tests/e2e/drivers/sso.ts']).specs,
|
||||
['sso/auth-domains.spec.ts'],
|
||||
'a driver change selects the specs that import it',
|
||||
);
|
||||
|
||||
for (const file of [
|
||||
'frontend/pnpm-lock.yaml',
|
||||
'frontend/src/index.tsx',
|
||||
'pkg/signoz/signoz.go',
|
||||
]) {
|
||||
assert.equal(affected([file]).all, true, `${file} runs everything`);
|
||||
}
|
||||
|
||||
assert.deepEqual(
|
||||
unmapped(),
|
||||
{ folders: [], pages: [] },
|
||||
'add these spec folders and pages to tests/e2e/affected.json',
|
||||
);
|
||||
96
tests/e2e/scripts/plan.mjs
Normal file
96
tests/e2e/scripts/plan.mjs
Normal file
@@ -0,0 +1,96 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
import { affected } from './affected.mjs';
|
||||
import { E2E_DIR, listTests, REPO_DIR } from './utils.mjs';
|
||||
|
||||
const MAX_SHARDS = 10;
|
||||
const TESTS_PER_SHARD = 80;
|
||||
|
||||
const { values: options } = parseArgs({
|
||||
options: { all: { type: 'boolean', default: false } },
|
||||
});
|
||||
|
||||
function changedFiles() {
|
||||
if (!process.stdin.isTTY) {
|
||||
return fs.readFileSync(0, 'utf8').split('\n').filter(Boolean);
|
||||
}
|
||||
const git = (...args) =>
|
||||
execFileSync('git', args, { cwd: REPO_DIR })
|
||||
.toString()
|
||||
.split('\n')
|
||||
.filter(Boolean);
|
||||
const [base] = git('merge-base', 'origin/main', 'HEAD');
|
||||
return [
|
||||
...git('diff', '--name-only', base),
|
||||
...git('ls-files', '--others', '--exclude-standard'),
|
||||
];
|
||||
}
|
||||
|
||||
const selection = options.all
|
||||
? { all: true, reasons: ['--all'], features: [], specs: [] }
|
||||
: affected(changedFiles());
|
||||
const tests = listTests();
|
||||
const chosen = new Set(
|
||||
tests.filter(
|
||||
(test) =>
|
||||
selection.all ||
|
||||
selection.specs.includes(test.file) ||
|
||||
selection.features.includes(test.file.split('/')[0]),
|
||||
),
|
||||
);
|
||||
if (chosen.size || selection.features.length || selection.specs.length) {
|
||||
tests
|
||||
.filter((test) => test.tags.includes('@smoke'))
|
||||
.forEach((test) => chosen.add(test));
|
||||
}
|
||||
const shardCount = Math.min(
|
||||
MAX_SHARDS,
|
||||
Math.ceil(chosen.size / TESTS_PER_SHARD),
|
||||
);
|
||||
|
||||
const out = path.join(E2E_DIR, 'artifacts/plan');
|
||||
fs.rmSync(out, { recursive: true, force: true });
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(out, 'tests.txt'),
|
||||
[...chosen]
|
||||
.map((test) => `[chromium] › ${[test.file, ...test.titles].join(' › ')}\n`)
|
||||
.join(''),
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(out, 'plan.json'),
|
||||
JSON.stringify({ ...selection, tests: chosen.size, shardCount }, null, '\t'),
|
||||
);
|
||||
|
||||
const scope = selection.all
|
||||
? 'every spec'
|
||||
: [...new Set([...selection.features, ...selection.specs, '@smoke'])].join(
|
||||
', ',
|
||||
);
|
||||
const summary = [
|
||||
shardCount
|
||||
? `**E2E plan:** ${chosen.size} of ${tests.length} tests on ${shardCount} shard${shardCount > 1 ? 's' : ''}.`
|
||||
: '**E2E plan:** no test reaches this change.',
|
||||
shardCount ? `**Runs:** ${scope}` : '',
|
||||
...selection.reasons
|
||||
.slice(0, 5)
|
||||
.map(
|
||||
(reason, index) => `${index ? '' : '**Full suite because:** '}${reason}`,
|
||||
),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n\n');
|
||||
|
||||
process.stdout.write(`${summary.replaceAll('**', '')}\n`);
|
||||
if (process.env.GITHUB_OUTPUT) {
|
||||
fs.appendFileSync(
|
||||
process.env.GITHUB_OUTPUT,
|
||||
`shards=${JSON.stringify(Array.from({ length: shardCount }, (_, index) => index + 1))}\nshard-count=${shardCount}\n`,
|
||||
);
|
||||
}
|
||||
if (process.env.GITHUB_STEP_SUMMARY) {
|
||||
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, `${summary}\n`);
|
||||
}
|
||||
41
tests/e2e/scripts/utils.mjs
Normal file
41
tests/e2e/scripts/utils.mjs
Normal file
@@ -0,0 +1,41 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export const E2E_DIR = path.resolve(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
'..',
|
||||
);
|
||||
export const REPO_DIR = path.resolve(E2E_DIR, '../..');
|
||||
|
||||
export function listTests() {
|
||||
const output = execFileSync(
|
||||
path.join(E2E_DIR, 'node_modules/.bin/playwright'),
|
||||
['test', '--list', '--project=chromium', '--reporter=json'],
|
||||
{ cwd: E2E_DIR, maxBuffer: 64 * 1024 * 1024 },
|
||||
);
|
||||
const report = JSON.parse(output.toString());
|
||||
if (report.errors?.length) {
|
||||
throw new Error(report.errors.map((error) => error.message).join('\n'));
|
||||
}
|
||||
const tests = [];
|
||||
const walk = (suite, titles) => {
|
||||
for (const spec of suite.specs ?? []) {
|
||||
if (spec.tests.some((test) => test.projectName === 'chromium')) {
|
||||
tests.push({
|
||||
file: spec.file,
|
||||
titles: [...titles, spec.title],
|
||||
// The JSON reporter drops the leading @.
|
||||
tags: spec.tags.map((tag) => `@${tag}`),
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const child of suite.suites ?? []) {
|
||||
walk(child, [...titles, child.title]);
|
||||
}
|
||||
};
|
||||
for (const fileSuite of report.suites) {
|
||||
walk(fileSuite, []);
|
||||
}
|
||||
return tests;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { expect, REDIRECTS, ROUTES, test } from '../../drivers/shell';
|
||||
// The broad regression net: every top-level route mounts its own component
|
||||
// without tripping an error boundary, a console error or a failed request.
|
||||
|
||||
test.describe('app shell — routes', () => {
|
||||
test.describe('app shell — routes @smoke', () => {
|
||||
for (const probe of [...ROUTES, ...REDIRECTS]) {
|
||||
test(probe.title, async ({ shell, noise }) => {
|
||||
await shell.visit(probe);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { expect, PATH, test } from '../../drivers/routing';
|
||||
// told otherwise, which only shows when someone presses Back. Runs as `guest`:
|
||||
// an authenticated page would skip the chain under test.
|
||||
|
||||
test.describe('Routing — auth guards', () => {
|
||||
test.describe('Routing — auth guards @smoke', () => {
|
||||
test('TC-14 a deep-linked private route survives the login round trip', async ({
|
||||
guest,
|
||||
}) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, PATH, test } from '../../drivers/routing';
|
||||
|
||||
// The shape of the router mount, which no other spec observes.
|
||||
|
||||
test.describe('Routing: router mount', () => {
|
||||
test.describe('Routing: router mount @smoke', () => {
|
||||
// Under a React transition the previous screen stays up instead of the
|
||||
// Suspense fallback, so an uncached route renders no loader at all.
|
||||
test('TC-18 an in-app navigation to an uncached route commits the Suspense fallback', async ({
|
||||
|
||||
@@ -16,7 +16,7 @@ test.describe.configure({ mode: 'serial' });
|
||||
const BLOCKED_ROLE_NAME = `routing-blocker-${uniqueAlphaSuffix()}`;
|
||||
const SAVED_ROLE_NAME = `routing-bypass-${uniqueAlphaSuffix()}`;
|
||||
|
||||
test.describe('Routing — unsaved-changes navigation blocker', () => {
|
||||
test.describe('Routing — unsaved-changes navigation blocker @smoke', () => {
|
||||
test.afterAll(async ({ browser }) => {
|
||||
await onAdminPage(browser, (page) =>
|
||||
routingDriver(page).roles.removeByName([BLOCKED_ROLE_NAME, SAVED_ROLE_NAME]),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { dashboardListParams, expect, PATH, test } from '../../drivers/routing';
|
||||
// Imperative navigation: the `history.listen` counter behind `hasInAppHistory()`,
|
||||
// `useSafeNavigate`'s same-url suppression, and its `newTab` branch.
|
||||
|
||||
test.describe('Routing — imperative navigation', () => {
|
||||
test.describe('Routing — imperative navigation @smoke', () => {
|
||||
// Both branches of the trace header's Back button in one document:
|
||||
// `hasInAppHistory() ? goBack() : push(TRACES_EXPLORER)`.
|
||||
test('TC-06 the trace-details previous button pushes when deep-linked and pops once in-app', async ({
|
||||
|
||||
@@ -4,7 +4,7 @@ import { expect, PATH, test } from '../../drivers/routing';
|
||||
// `RouteTab`, `TopNav`'s per-route checks, and `SETTINGS`, a prefix route that
|
||||
// needs an explicit `/*` under v7.
|
||||
|
||||
test.describe('Routing — route matching', () => {
|
||||
test.describe('Routing — route matching @smoke', () => {
|
||||
test('TC-09 RouteTab switches the url and survives a reload', async ({
|
||||
routing,
|
||||
}) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ function onlyPod(name: string): string {
|
||||
return `k8s.pod.name = '${name}'`;
|
||||
}
|
||||
|
||||
test.describe('Routing — nuqs and router param coexistence', () => {
|
||||
test.describe('Routing — nuqs and router param coexistence @smoke', () => {
|
||||
test('TC-01 a router write keeps the nuqs params it did not author', async ({
|
||||
routing,
|
||||
pods,
|
||||
|
||||
Reference in New Issue
Block a user