Skip to content

Commit 98701e2

Browse files
feat: [KSBP-101776] - Additional work on parallelisation of test app with other components
1 parent f720f65 commit 98701e2

3 files changed

Lines changed: 56 additions & 12 deletions

File tree

k8s-deployer/src/dependency-resolver.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,44 @@ const reconstructCyclePath = (startId: string, parent: Map<string, string>): Arr
210210
}
211211

212212
/**
213-
* Print the dependency graph in a visually grouped format.
214-
* Components that can be deployed in parallel are shown together and annotated.
213+
* Print the full deployment graph including testApp placement.
214+
*
215+
* - Components are shown in topological stages.
216+
* - If testApp.parallel === true it is shown in a separate concurrent section
217+
* (it runs alongside all component stages).
218+
* - Otherwise testApp is shown as the final sequential stage after all components.
215219
*/
216-
export const printDependencyGraph = (components: Array<Schema.DeployableComponent>): void => {
220+
export const printDependencyGraph = (graph: Schema.Graph): void => {
221+
const { components, testApp } = graph
217222
const { levels } = topologicalSort(components)
218223
const sep = "─".repeat(40)
224+
const label = (c: Schema.DeployableComponent) => c.parallel ? `${c.id} 🔀` : c.id
219225
const edges = components.flatMap(c => (c.dependsOn ?? []).map(dep => ` ${dep} ──▶ ${c.id}`))
226+
const anyConcurrent = components.some(c => c.parallel) || testApp.parallel === true
220227

221228
console.log("Dependency Graph")
222229
console.log(sep)
223-
levels.forEach((level, idx) =>
224-
console.log(` Stage ${idx + 1}${level.map(c => c.parallel ? `${c.id} 🔀` : c.id).join(" ")}`)
225-
)
230+
231+
if (testApp.parallel === true) {
232+
// testApp runs concurrently with the entire component chain — show it in a separate section
233+
levels.forEach((level, idx) =>
234+
console.log(` Stage ${idx + 1}${level.map(label).join(" ")}`)
235+
)
236+
console.log(sep)
237+
console.log(` ${label(testApp)} (concurrent with component stages)`)
238+
} else {
239+
// testApp runs after all components — append it as the final stage
240+
levels.forEach((level, idx) =>
241+
console.log(` Stage ${idx + 1}${level.map(label).join(" ")}`)
242+
)
243+
console.log(` Stage ${levels.length + 1}${testApp.id}`)
244+
}
245+
226246
if (edges.length > 0) {
227247
console.log(sep)
228248
edges.forEach(e => console.log(e))
229249
}
230-
if (components.some(c => c.parallel)) {
250+
if (anyConcurrent) {
231251
console.log(sep)
232252
console.log(" 🔀 = concurrent deployment")
233253
}

k8s-deployer/src/test-suite-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const deployGraph = async (config: Config, workspace: string, testSuiteId
4646

4747
logger.info("")
4848
logger.info("Dependency Graph for %s:", testSuiteId)
49-
printDependencyGraph(graph.components)
49+
printDependencyGraph(graph)
5050
logger.info("")
5151

5252
if (testAppDirForRemoteTestSuite) {

k8s-deployer/test/dependency-resolver.spec.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ describe("Dependency Resolver", () => {
395395
describe("printDependencyGraph", () => {
396396
let logOutput: string[]
397397
let originalLog: typeof console.log
398+
const testApp: Schema.DeployableComponent = {
399+
name: "test-app", id: "test-app",
400+
location: { type: Schema.LocationType.Local },
401+
deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }
402+
}
398403
beforeEach(() => {
399404
logOutput = []
400405
originalLog = console.log
@@ -410,9 +415,10 @@ describe("Dependency Resolver", () => {
410415
{ name: "B", id: "b", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" } },
411416
{ name: "C", id: "c", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" } }
412417
]
413-
printDependencyGraph(components)
418+
printDependencyGraph({ testApp, components })
414419
expect(logOutput[0]).to.equal("Dependency Graph")
415420
expect(logOutput).to.include(" Stage 1 │ a b c")
421+
expect(logOutput).to.include(" Stage 2 │ test-app")
416422
})
417423

418424
it("prints graph for components with dependencies at multiple stages", () => {
@@ -421,10 +427,11 @@ describe("Dependency Resolver", () => {
421427
{ name: "API", id: "api", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["db"] },
422428
{ name: "Cache", id: "cache", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["db"] }
423429
]
424-
printDependencyGraph(components)
430+
printDependencyGraph({ testApp, components })
425431
expect(logOutput[0]).to.equal("Dependency Graph")
426432
expect(logOutput).to.include(" Stage 1 │ db")
427433
expect(logOutput).to.include(" Stage 2 │ api cache")
434+
expect(logOutput).to.include(" Stage 3 │ test-app")
428435
expect(logOutput).to.include(" db ──▶ api")
429436
expect(logOutput).to.include(" db ──▶ cache")
430437
})
@@ -435,11 +442,12 @@ describe("Dependency Resolver", () => {
435442
{ name: "B", id: "b", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["a"] },
436443
{ name: "C", id: "c", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["b"] }
437444
]
438-
printDependencyGraph(components)
445+
printDependencyGraph({ testApp, components })
439446
expect(logOutput[0]).to.equal("Dependency Graph")
440447
expect(logOutput).to.include(" Stage 1 │ a")
441448
expect(logOutput).to.include(" Stage 2 │ b")
442449
expect(logOutput).to.include(" Stage 3 │ c")
450+
expect(logOutput).to.include(" Stage 4 │ test-app")
443451
expect(logOutput).to.include(" a ──▶ b")
444452
expect(logOutput).to.include(" b ──▶ c")
445453
})
@@ -450,13 +458,29 @@ describe("Dependency Resolver", () => {
450458
{ name: "B", id: "b", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["a"], parallel: true },
451459
{ name: "C", id: "c", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["a"], parallel: true }
452460
]
453-
printDependencyGraph(components)
461+
printDependencyGraph({ testApp, components })
454462
expect(logOutput[0]).to.equal("Dependency Graph")
455463
expect(logOutput).to.include(" Stage 1 │ a")
456464
expect(logOutput).to.include(" Stage 2 │ b 🔀 c 🔀")
465+
expect(logOutput).to.include(" Stage 3 │ test-app")
457466
expect(logOutput).to.include(" a ──▶ b")
458467
expect(logOutput).to.include(" a ──▶ c")
459468
expect(logOutput).to.include(" 🔀 = concurrent deployment")
460469
})
470+
471+
it("shows testApp in a concurrent section when testApp.parallel is true", () => {
472+
const parallelTestApp: Schema.DeployableComponent = { ...testApp, id: "my-test-app", parallel: true }
473+
const components: Array<Schema.DeployableComponent> = [
474+
{ name: "A", id: "a", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" } },
475+
{ name: "B", id: "b", location: { type: Schema.LocationType.Local }, deploy: { command: "deploy.sh" }, undeploy: { command: "undeploy.sh" }, dependsOn: ["a"] }
476+
]
477+
printDependencyGraph({ testApp: parallelTestApp, components })
478+
expect(logOutput[0]).to.equal("Dependency Graph")
479+
expect(logOutput).to.include(" Stage 1 │ a")
480+
expect(logOutput).to.include(" Stage 2 │ b")
481+
expect(logOutput).to.include(" my-test-app 🔀 (concurrent with component stages)")
482+
expect(logOutput).to.not.include(" Stage 3 │ my-test-app")
483+
expect(logOutput).to.include(" 🔀 = concurrent deployment")
484+
})
461485
})
462486
})

0 commit comments

Comments
 (0)