Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit e6ddf02

Browse files
committed
Log out Scan Jobs when they have timed out
1 parent b1eb1b1 commit e6ddf02

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/integration/helpers.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const kc = new k8s.KubeConfig();
44
kc.loadFromDefault();
55

66
const k8sCRDApi = kc.makeApiClient(k8s.CustomObjectsApi);
7+
const k8sBatchApi = kc.makeApiClient(k8s.BatchV1Api);
78

89
const namespace = "integration-tests";
910

@@ -32,6 +33,19 @@ async function getScan(name) {
3233
return scan
3334
}
3435

36+
async function logJob(name) {
37+
try {
38+
const { body: job } = await k8sBatchApi.readNamespacedJob(
39+
name,
40+
namespace,
41+
);
42+
console.log(`Job: '${name}'`)
43+
console.dir(job)
44+
} catch {
45+
console.info(`Job: '${name} not found.'`)
46+
}
47+
}
48+
3549
/**
3650
*
3751
* @param {string} name name of the scan. Actual name will be sufixed with a random number to avoid conflicts
@@ -74,9 +88,12 @@ async function scan(name, scanType, parameters = [], timeout = 180) {
7488
}
7589

7690
console.error("Scan Timed out!")
91+
7792
const scan = await getScan(actualName);
7893
console.log("Last Scan State:")
7994
console.dir(scan)
95+
await logJob(`scan-${actualName}`)
96+
await logJob(`parse-${actualName}`)
8097

8198
throw new Error("timed out while waiting for scan results");
8299
}

0 commit comments

Comments
 (0)