@camunda/e2e-test-suite 0.0.1296 → 0.0.1297

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Playwright projects for the Orchestration Cluster REST v2 API suite.
3
+ *
4
+ * `playwright.api.config.ts` uses these, and so do the Helm chart configs in
5
+ * camunda/camunda-platform-helm, which run the suite from the published
6
+ * `@camunda/e2e-test-suite` package on AlwaysGreen. Both read one definition,
7
+ * so the clock ordering below cannot drift between them.
8
+ *
9
+ * `testDir` is this file's own directory: `tests/api` in a checkout and
10
+ * `dist/tests/api` in the package, so either consumer finds the specs.
11
+ */
12
+ import type { Project } from '@playwright/test';
13
+ export declare const apiProjects: Project[];
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * Playwright projects for the Orchestration Cluster REST v2 API suite.
4
+ *
5
+ * `playwright.api.config.ts` uses these, and so do the Helm chart configs in
6
+ * camunda/camunda-platform-helm, which run the suite from the published
7
+ * `@camunda/e2e-test-suite` package on AlwaysGreen. Both read one definition,
8
+ * so the clock ordering below cannot drift between them.
9
+ *
10
+ * `testDir` is this file's own directory: `tests/api` in a checkout and
11
+ * `dist/tests/api` in the package, so either consumer finds the specs.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.apiProjects = void 0;
15
+ exports.apiProjects = [
16
+ {
17
+ name: 'api',
18
+ testDir: __dirname,
19
+ testIgnore: /clock-api-tests\.spec\.[jt]s$/,
20
+ // Safe for every spec except the clock, which the `clock` project below
21
+ // keeps out of this window: identity resources, processes and decisions are
22
+ // randomised per test, so nothing else one file creates is visible to
23
+ // another as anything but an extra row in a filtered search.
24
+ fullyParallel: true,
25
+ // Generous: some assertions wait on exporter lag, and the ingress retry can
26
+ // legitimately spend 90s riding out a pod restart during an upgrade run.
27
+ timeout: 5 * 60 * 1000,
28
+ expect: { timeout: 30000 },
29
+ },
30
+ {
31
+ /**
32
+ * The clock tests pin the cluster clock, and the engine's notion of time
33
+ * is process-wide: while one of them holds 2029, a job in another file
34
+ * activates against a timeout that has already passed and a published
35
+ * message is born expired.
36
+ *
37
+ * `test.describe.configure({mode: 'serial'})` cannot prevent that. It
38
+ * orders tests inside one file, and `fullyParallel` runs the other files at
39
+ * the same time on other workers — the same intra-file-only limitation
40
+ * `docs/serial-specs.md` records for the 8.10 browser specs. A project that
41
+ * depends on `api` is the only ordering Playwright offers that takes them
42
+ * out of the parallel window entirely.
43
+ *
44
+ * The cost, stated because it is a real one: Playwright skips a project
45
+ * whose dependency failed, so any `api` failure skips these three tests.
46
+ * That is accepted here and is not the defect `5d6ac21` fixed — there a
47
+ * *different* suite's failure left a green cluster with no API signal at
48
+ * all, whereas a red `api` project means this suite is already red and
49
+ * being read, and what is skipped is three status-code assertions.
50
+ */
51
+ name: 'clock',
52
+ testDir: __dirname,
53
+ testMatch: /clock-api-tests\.spec\.[jt]s$/,
54
+ dependencies: ['api'],
55
+ fullyParallel: false,
56
+ timeout: 5 * 60 * 1000,
57
+ expect: { timeout: 30000 },
58
+ },
59
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/e2e-test-suite",
3
- "version": "0.0.1296",
3
+ "version": "0.0.1297",
4
4
  "description": "End-to-end test helpers for Camunda 8",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,8 @@
15
15
  "dist",
16
16
  "resources",
17
17
  "playwright.config.ts",
18
- ".github/c8_versions.json"
18
+ ".github/c8_versions.json",
19
+ "scripts/wait-for-orchestration-admin-role.sh"
19
20
  ],
20
21
  "type": "commonjs",
21
22
  "publishConfig": {
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env bash
2
+ # Blocks until CLIENT_ID holds an effective ROLE_ID (default: admin) membership on
3
+ # the orchestration cluster, so the API v2 suite is not started with a client that
4
+ # has no permissions.
5
+ #
6
+ # Membership changes (roles, groups, tenants, component authorizations) are
7
+ # resolved when a session is established and are only re-resolved on the next
8
+ # authentication refresh interval (default PT30S), so a cluster that has just
9
+ # been installed or upgraded can still answer 403 to a client that is configured
10
+ # as an admin:
11
+ # https://docs.camunda.io/docs/self-managed/components/orchestration-cluster/core-settings/configuration/webserver/#propagation-of-membership-changes-to-active-sessions
12
+ #
13
+ # Assigning a client to a role itself requires UPDATE on ROLE, so for a
14
+ # self-assignment the response is the readiness signal:
15
+ # 409 ALREADY_EXISTS -> the caller is an admin and the membership is effective
16
+ # 2xx -> the caller is an admin and the membership was just added
17
+ # 403 FORBIDDEN -> the membership is not effective (yet)
18
+
19
+ set -euo pipefail
20
+
21
+ : "${BASE_URL:?BASE_URL is required, e.g. https://<host>/orchestration}"
22
+ : "${TOKEN_URL:?TOKEN_URL is required}"
23
+ : "${CLIENT_ID:?CLIENT_ID is required}"
24
+ : "${CLIENT_SECRET:?CLIENT_SECRET is required}"
25
+
26
+ ROLE_ID="${ROLE_ID:-admin}"
27
+ MAX_ATTEMPTS="${MAX_ATTEMPTS:-10}"
28
+ REQUEST_TIMEOUT="${REQUEST_TIMEOUT:-30}"
29
+ MAX_BACKOFF="${MAX_BACKOFF:-30}"
30
+
31
+ body_file="$(mktemp)"
32
+ trap 'rm -f "$body_file"' EXIT
33
+
34
+ fetch_token() {
35
+ curl -sS --max-time "$REQUEST_TIMEOUT" -X POST "$TOKEN_URL" \
36
+ -H 'Content-Type: application/x-www-form-urlencoded' \
37
+ --data-urlencode 'grant_type=client_credentials' \
38
+ --data-urlencode "client_id=${CLIENT_ID}" \
39
+ --data-urlencode "client_secret=${CLIENT_SECRET}" |
40
+ jq -r '.access_token // empty'
41
+ }
42
+
43
+ attempt=1
44
+ backoff=5
45
+
46
+ while [ "$attempt" -le "$MAX_ATTEMPTS" ]; do
47
+ # Re-mint the token on every attempt: memberships are attached to the session
48
+ # the token opens, so reusing one token keeps reporting the stale membership.
49
+ token="$(fetch_token || true)"
50
+
51
+ if [ -z "$token" ]; then
52
+ echo "Attempt ${attempt}/${MAX_ATTEMPTS}: no access token returned by ${TOKEN_URL}"
53
+ else
54
+ status="$(
55
+ curl -sS --max-time "$REQUEST_TIMEOUT" -o "$body_file" -w '%{http_code}' \
56
+ -X PUT "${BASE_URL}/v2/roles/${ROLE_ID}/clients/${CLIENT_ID}" \
57
+ -H "Authorization: Bearer ${token}" || echo 000
58
+ )"
59
+
60
+ case "$status" in
61
+ 2*)
62
+ echo "Assigned client '${CLIENT_ID}' to role '${ROLE_ID}' (HTTP ${status})."
63
+ echo "Waiting ${MAX_BACKOFF}s for the new membership to propagate."
64
+ sleep "$MAX_BACKOFF"
65
+ exit 0
66
+ ;;
67
+ 409)
68
+ echo "Client '${CLIENT_ID}' holds role '${ROLE_ID}' and the membership is effective."
69
+ exit 0
70
+ ;;
71
+ 403)
72
+ echo "Attempt ${attempt}/${MAX_ATTEMPTS}: role '${ROLE_ID}' is not effective yet for client '${CLIENT_ID}' (HTTP 403)."
73
+ cat "$body_file"
74
+ echo
75
+ ;;
76
+ *)
77
+ echo "Attempt ${attempt}/${MAX_ATTEMPTS}: unexpected response while assigning role '${ROLE_ID}' (HTTP ${status})."
78
+ cat "$body_file"
79
+ echo
80
+ ;;
81
+ esac
82
+ fi
83
+
84
+ if [ "$attempt" -lt "$MAX_ATTEMPTS" ]; then
85
+ sleep "$backoff"
86
+ backoff=$((backoff * 2))
87
+ if [ "$backoff" -gt "$MAX_BACKOFF" ]; then
88
+ backoff="$MAX_BACKOFF"
89
+ fi
90
+ fi
91
+
92
+ attempt=$((attempt + 1))
93
+ done
94
+
95
+ echo "ERROR: client '${CLIENT_ID}' never obtained an effective '${ROLE_ID}' role on ${BASE_URL}." >&2
96
+ echo "Refusing to start the API v2 suite: without admin permissions every write is rejected with 403" >&2
97
+ echo "and every search is filtered to an empty result, which hides the real failure." >&2
98
+ exit 1