Skip to content

Commit ddbab05

Browse files
feat: [KSBP-101776] - Add flag for parallelTestApp
1 parent b57d1eb commit ddbab05

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

k8s-deployer/src/pitfile/schema-v1.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export class DeployableComponent {
6767
export class Graph {
6868
testApp: DeployableComponent
6969
components: Array<DeployableComponent>
70+
/**
71+
* When true, the test app is deployed concurrently with the component chain.
72+
* Only enable this if the test app can start independently of the components.
73+
* Defaults to false (sequential: test app starts after all components are ready).
74+
*/
75+
parallelTestApp?: boolean
7076
}
7177

7278
export class Deployment {

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,23 @@ export const deployGraph = async (config: Config, workspace: string, testSuiteId
103103
}
104104
})()
105105

106-
// Deploy test app concurrently with the component levels; deployGraph does not return until both are done.
107106
logger.info("%s Deploying test app \"%s\" for suite \"%s\" %s", LOG_SEPARATOR_LINE, graph.testApp.name, testSuiteId, LOG_SEPARATOR_LINE)
108107
const params = [ testSuiteId ]
109-
const deployTestAppPromise = Deployer.deployComponent(config, workspace, graph.testApp, namespace, params)
110-
.then(commitSha => new DeployedComponent(commitSha, graph.testApp))
111108

112-
const [ , testAppDeployedComponent] = await Promise.all([deployComponentsPromise, deployTestAppPromise])
109+
let testAppDeployedComponent: DeployedComponent
110+
if (graph.parallelTestApp === true) {
111+
// Deploy test app concurrently with the component levels (opt-in).
112+
// Only use this when the test app can start independently of the components.
113+
const deployTestAppPromise = Deployer.deployComponent(config, workspace, graph.testApp, namespace, params)
114+
.then(commitSha => new DeployedComponent(commitSha, graph.testApp))
115+
const [ , resolved] = await Promise.all([deployComponentsPromise, deployTestAppPromise])
116+
testAppDeployedComponent = resolved
117+
} else {
118+
// Default: wait for all components to be ready before deploying the test app.
119+
await deployComponentsPromise
120+
const commitSha = await Deployer.deployComponent(config, workspace, graph.testApp, namespace, params)
121+
testAppDeployedComponent = new DeployedComponent(commitSha, graph.testApp)
122+
}
113123

114124
logger.info("")
115125
return new GraphDeploymentResult(deployments, testAppDeployedComponent)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ describe("Deployment happy path", async () => {
5757
location: { type: LocationType.Local },
5858
deployment: {
5959
graph: {
60+
parallelTestApp: true,
6061
testApp: {
6162
name: "comp-1-test-app-name",
6263
id: "comp-1-test-app",
@@ -498,6 +499,7 @@ describe("deployGraph - deployment ordering and concurrency", async () => {
498499
const deployStub = sinon.stub().callsFake(async (_cfg, _ws, spec) => `sha-${spec.id}`)
499500
const SuiteHandler = await loadWithStub(deployStub)
500501
const graph = {
502+
parallelTestApp: true,
501503
testApp: makeSpec("test-app"),
502504
components: [makeSpec("comp-a"), makeSpec("comp-b")]
503505
}
@@ -520,6 +522,7 @@ describe("deployGraph - deployment ordering and concurrency", async () => {
520522
})
521523
const SuiteHandler = await loadWithStub(deployStub)
522524
const graph = {
525+
parallelTestApp: true,
523526
testApp: makeSpec("testApp"),
524527
components: [makeSpec("B", { parallel: true }), makeSpec("C", { parallel: true })]
525528
}
@@ -549,6 +552,7 @@ describe("deployGraph - deployment ordering and concurrency", async () => {
549552
const SuiteHandler = await loadWithStub(deployStub)
550553
// B is parallel:true, C has no parallel flag — same dependency level, so neither waits on the other
551554
const graph = {
555+
parallelTestApp: true,
552556
testApp: makeSpec("testApp"),
553557
components: [makeSpec("B", { parallel: true }), makeSpec("C")]
554558
}
@@ -579,6 +583,7 @@ describe("deployGraph - deployment ordering and concurrency", async () => {
579583
})
580584
const SuiteHandler = await loadWithStub(deployStub)
581585
const graph = {
586+
parallelTestApp: true,
582587
testApp: makeSpec("testApp"),
583588
components: [
584589
makeSpec("A"),
@@ -624,6 +629,7 @@ describe("deployGraph - deployment ordering and concurrency", async () => {
624629
})
625630
const SuiteHandler = await loadWithStub(deployStub)
626631
const graph = {
632+
parallelTestApp: true,
627633
testApp: makeSpec("testApp"),
628634
components: [makeSpec("A")]
629635
}

0 commit comments

Comments
 (0)