Skip to content

Commit 692f79e

Browse files
committed
chore: using env variables to choose test platform
TEST_PLATFORM will dictate which platform is used (KinD, EKS, etc.) CREATE_CLUSTER decides whether or not we use an existing cluster or create a new one for the test new package.json "scripts": test:integration:kind will run the integration test on a new KinD cluster test:integration:eks will run the integration test on an existing EKS cluster test:integration will remain the same (as :kind) for backwards compatibility, for now
1 parent e572c49 commit 692f79e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
"pretest": "./scripts/build-image.sh",
77
"test": "npm run lint && npm run build && npm run test:unit && npm run test:integration",
88
"test:unit": "./tap test/unit -R spec",
9-
"test:integration": "./tap test/integration/kubernetes.test.ts -R spec --timeout=1200",
9+
"test:integration": "TEST_PLATFORM=kind CREATE_CLUSTER=true ./tap test/integration/kubernetes.test.ts -R spec --timeout=1200",
10+
"test:integration:kind": "TEST_PLATFORM=kind CREATE_CLUSTER=true ./tap test/integration/kubernetes.test.ts -R spec --timeout=1200",
11+
"test:integration:eks": "TEST_PLATFORM=eks CREATE_CLUSTER=false ./tap test/integration/kubernetes.test.ts -R spec --timeout=1200",
1012
"test:coverage": "npm run test:unit -- --coverage",
1113
"test:watch": "tsc-watch --onSuccess 'npm run test:unit'",
12-
"test:apk": "./scripts/build-image.sh && PACKAGE_MANAGER=apk ./tap test/integration/package-manager.test.ts -R spec --timeout=7200",
13-
"test:apt": "./scripts/build-image.sh && PACKAGE_MANAGER=apt ./tap test/integration/package-manager.test.ts -R spec --timeout=7200",
14-
"test:rpm": "./scripts/build-image.sh && PACKAGE_MANAGER=rpm ./tap test/integration/package-manager.test.ts -R spec --timeout=7200",
14+
"test:apk": "./scripts/build-image.sh && TEST_PLATFORM=kind CREATE_CLUSTER=true PACKAGE_MANAGER=apk ./tap test/integration/package-manager.test.ts -R spec --timeout=7200",
15+
"test:apt": "./scripts/build-image.sh && TEST_PLATFORM=kind CREATE_CLUSTER=true PACKAGE_MANAGER=apt ./tap test/integration/package-manager.test.ts -R spec --timeout=7200",
16+
"test:rpm": "./scripts/build-image.sh && TEST_PLATFORM=kind CREATE_CLUSTER=true PACKAGE_MANAGER=rpm ./tap test/integration/package-manager.test.ts -R spec --timeout=7200",
1517
"start": "bin/start",
1618
"prepare": "npm run build",
1719
"build": "tsc",

test/setup/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,15 @@ export async function deployMonitor(): Promise<string> {
129129
'snyk/kubernetes-monitor:local',
130130
);
131131

132+
const testPlatform = process.env['TEST_PLATFORM'] || 'kind';
133+
const createCluster = process.env['CREATE_CLUSTER'] === 'true';
134+
console.log(`platform chosen is ${testPlatform}, createCluster===${createCluster}`);
135+
132136
await kubectl.downloadKubectl();
133-
// this bit is probably where we act upon the decision of which platform we'll use
134-
await platforms.kind.create(imageNameAndTag);
137+
if (createCluster) {
138+
await platforms[testPlatform].create(imageNameAndTag);
139+
}
140+
await platforms[testPlatform].config('kind');
135141
await createEnvironment();
136142
const integrationId = await installKubernetesMonitor(imageNameAndTag);
137143
await waiters.waitForMonitorToBeReady();

0 commit comments

Comments
 (0)