Skip to content

Commit 679885b

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

10 files changed

Lines changed: 1063 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: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,84 @@
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, namespace);
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: sonataflow-psql-postgresql, keys: postgres-username /
34+
* postgres-password). The e2e infrastructure creates a different layout
35+
* (secret: backstage-psql-secret, keys: POSTGRES_USER / POSTGRES_PASSWORD).
36+
* Patch the cloned manifests so the SonataFlow CRs reference the resources
37+
* that actually exist.
38+
*/
39+
async function patchWorkflowPersistence(
40+
workflowDir: string,
41+
namespace: string,
42+
): Promise<void> {
43+
const result = await $`oc get secrets -n ${namespace} -o name`;
44+
const secretName = result.stdout
45+
.trim()
46+
.split("\n")
47+
.find((s) => s.includes("backstage-psql"))
48+
?.replace("secret/", "");
49+
50+
if (!secretName) {
51+
throw new Error(
52+
`backstage-psql secret not found in namespace ${namespace}`,
53+
);
54+
}
55+
56+
const replacements: [RegExp, string][] = [
57+
[/sonataflow-psql-postgresql/g, secretName],
58+
[/postgres-username/g, "POSTGRES_USER"],
59+
[/postgres-password/g, "POSTGRES_PASSWORD"],
60+
[
61+
/databaseName: sonataflow\b/g,
62+
"databaseName: backstage_plugin_orchestrator",
63+
],
64+
];
65+
66+
for (const rel of MANIFEST_DIRS) {
67+
const dir = join(workflowDir, rel);
68+
const files = (await readdir(dir)).filter(
69+
(f) => f.endsWith(".yaml") || f.endsWith(".yml"),
70+
);
71+
for (const file of files) {
72+
const path = join(dir, file);
73+
let content = await readFile(path, "utf-8");
74+
for (const [pattern, replacement] of replacements) {
75+
content = content.replace(pattern, replacement);
76+
}
77+
await writeFile(path, content);
78+
}
79+
}
80+
}
81+
2282
async function waitForWorkflows(namespace: string): Promise<void> {
2383
const resourceDeadline = Date.now() + 60_000;
2484
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)