Skip to content

Commit d00977f

Browse files
committed
merged the orchestrator specs down to two
Signed-off-by: rostalan <rlan@redhat.com>
1 parent 6377d9e commit d00977f

10 files changed

Lines changed: 1066 additions & 1115 deletions

workspaces/orchestrator/e2e-tests/playwright.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ export default defineConfig({
1010
projects: [
1111
{
1212
name: "orchestrator",
13-
testMatch: "specs/**/*.spec.ts",
14-
testIgnore: "specs/**/*-rbac.spec.ts",
13+
testMatch: "specs/orchestrator.spec.ts",
1514
},
1615
{
1716
name: "orchestrator-rbac",
1817
dependencies: ["orchestrator"],
19-
testMatch: "specs/**/*-rbac.spec.ts",
18+
testMatch: "specs/orchestrator-rbac.spec.ts",
2019
},
2120
],
2221
});

workspaces/orchestrator/e2e-tests/tests/specs/deploy-sonataflow.ts

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,87 @@
1+
import { readdir, readFile, writeFile } from "fs/promises";
2+
import { join } from "path";
13
import { installOrchestrator } from "rhdh-e2e-test-utils/orchestrator";
24
import { $ } from "rhdh-e2e-test-utils/utils";
35

46
const WORKFLOW_REPO =
57
"https://github.com/rhdhorchestrator/serverless-workflows.git";
68

9+
const MANIFEST_DIRS = [
10+
"workflows/greeting/manifests",
11+
"workflows/fail-switch/src/main/resources/manifests",
12+
];
13+
714
export async function deploySonataflow(namespace: string): Promise<void> {
815
await installOrchestrator(namespace);
916

1017
const workflowDir = `/tmp/serverless-workflows-${process.pid}`;
1118
try {
1219
await $`git clone --depth=1 ${WORKFLOW_REPO} ${workflowDir}`;
13-
await $`oc apply -n ${namespace} -f ${workflowDir}/workflows/greeting/manifests/`;
14-
await $`oc apply -n ${namespace} -f ${workflowDir}/workflows/fail-switch/src/main/resources/manifests/`;
20+
await patchWorkflowPersistence(workflowDir);
21+
for (const rel of MANIFEST_DIRS) {
22+
await $`oc apply -n ${namespace} -f ${join(workflowDir, rel)}`;
23+
}
1524
} finally {
1625
await $`rm -rf ${workflowDir}`.catch(() => {});
1726
}
1827

1928
await waitForWorkflows(namespace);
2029
}
2130

31+
/**
32+
* The upstream serverless-workflows manifests expect a Helm-chart-style
33+
* PostgreSQL (secret & service both named sonataflow-psql-postgresql,
34+
* keys: postgres-username / postgres-password). The e2e infrastructure
35+
* creates a different layout (secret: backstage-psql-secret, service:
36+
* backstage-psql, keys: POSTGRES_USER / POSTGRES_PASSWORD).
37+
* Patch the cloned manifests so the SonataFlow CRs reference the
38+
* resources that actually exist.
39+
*/
40+
async function patchWorkflowPersistence(workflowDir: string): Promise<void> {
41+
for (const rel of MANIFEST_DIRS) {
42+
const dir = join(workflowDir, rel);
43+
const files = (await readdir(dir)).filter(
44+
(f) => f.endsWith(".yaml") || f.endsWith(".yml"),
45+
);
46+
for (const file of files) {
47+
const filePath = join(dir, file);
48+
let content = await readFile(filePath, "utf-8");
49+
content = patchPersistence(content);
50+
await writeFile(filePath, content);
51+
}
52+
}
53+
}
54+
55+
function patchPersistence(content: string): string {
56+
// secretRef precedes serviceRef in these manifests; patch it first so
57+
// the blanket replacement below only touches serviceRef occurrences.
58+
content = content.replace(
59+
/(secretRef:)([\s\S]*?)(serviceRef:)/g,
60+
(_m, pre, block, post) =>
61+
pre +
62+
block
63+
.replace(
64+
/name: sonataflow-psql-postgresql/,
65+
"name: backstage-psql-secret",
66+
)
67+
.replace(/userKey: postgres-username/, "userKey: POSTGRES_USER")
68+
.replace(
69+
/passwordKey: postgres-password/,
70+
"passwordKey: POSTGRES_PASSWORD",
71+
) +
72+
post,
73+
);
74+
75+
// Remaining sonataflow-psql-postgresql refs are in serviceRef blocks.
76+
content = content.replace(/sonataflow-psql-postgresql/g, "backstage-psql");
77+
content = content.replace(
78+
/databaseName: sonataflow\b/g,
79+
"databaseName: backstage_plugin_orchestrator",
80+
);
81+
82+
return content;
83+
}
84+
2285
async function waitForWorkflows(namespace: string): Promise<void> {
2386
const resourceDeadline = Date.now() + 60_000;
2487
while (Date.now() < resourceDeadline) {

workspaces/orchestrator/e2e-tests/tests/specs/failswitch-workflow.spec.ts

Lines changed: 0 additions & 189 deletions
This file was deleted.

workspaces/orchestrator/e2e-tests/tests/specs/greeting-workflow.spec.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)