Skip to content

Commit bba76d5

Browse files
Merge pull request #578 from snyk/test/fix-test-condition
test: fix condition for executing test for LOG_LEVEL env existence
2 parents 44c065e + 8e9bdb8 commit bba76d5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/integration/kubernetes.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ tap.test('create local container registry and push an image', async (t) => {
8282
console.log('Creating local container registry...');
8383
await exec('docker run -d --restart=always -p "5000:5000" --name "kind-registry" registry:2');
8484
await exec('docker network connect "kind" "kind-registry"');
85-
85+
8686
console.log('Pushing python:rc-buster image to the local registry');
8787
//Note: this job takes a while and waitForJob() should be called before trying to access local registry image,
8888
//to make sure it completed
@@ -274,7 +274,7 @@ tap.test('snyk-monitor pulls images from a local registry and sends data to kube
274274
await setup.removeLocalContainerRegistry();
275275
console.log('Removed local container registry');
276276
});
277-
277+
278278
if (process.env['TEST_PLATFORM'] !== 'kind') {
279279
t.pass('Not testing local container registry because we\'re not running in KinD');
280280
return;
@@ -288,7 +288,7 @@ tap.test('snyk-monitor pulls images from a local registry and sends data to kube
288288
const imageName = 'kind-registry:5000/python';
289289

290290
await kubectl.waitForJob('push-to-local-registry', 'default');
291-
291+
292292
console.log('Applying local registry workload...');
293293
await kubectl.applyK8sYaml('./test/fixtures/insecure-registries/python-local-deployment.yaml');
294294

@@ -306,7 +306,7 @@ tap.test('snyk-monitor pulls images from a local registry and sends data to kube
306306

307307
const depGraphResult = await getUpstreamResponseBody(
308308
`api/v1/dependency-graphs/${integrationId}/${clusterName}/${namespace}/${deploymentType}/${deploymentName}`);
309-
309+
310310
t.ok('dependencyGraphResults' in depGraphResult,
311311
'expected dependencyGraphResults field to exist in /dependency-graphs response');
312312
t.ok('imageMetadata' in JSON.parse(depGraphResult.dependencyGraphResults[imageName]),
@@ -353,16 +353,17 @@ tap.test('snyk-monitor has resource limits', async (t) => {
353353
});
354354

355355
tap.test('snyk-monitor has log level', async(t) => {
356-
if (['Helm', 'YAML'].includes(process.env.DEPLOYMENT_TYPE || '')) {
357-
t.pass('Not testing LOG_LEVEL existence because we\'re not installing with Helm');
356+
if (!['Helm', 'YAML'].includes(process.env.DEPLOYMENT_TYPE || '')) {
357+
t.pass('Not testing LOG_LEVEL existence because we\'re not installing with Helm or Yaml');
358358
return;
359359
}
360360

361361
const snykMonitorDeployment = await kubectl.getDeploymentJson('snyk-monitor', namespace);
362-
const { LOG_LEVEL } = snykMonitorDeployment.spec.template.spec.containers[0].env;
362+
const env = snykMonitorDeployment.spec.template.spec.containers[0].env;
363+
const logLevel = env.find(({ name }) => name === 'LOG_LEVEL');
363364

364-
t.ok(LOG_LEVEL, 'snyk-monitor has log level');
365-
t.ok(LOG_LEVEL === 'INFO', 'snyk-monitor has correct log level');
365+
t.ok(logLevel.name, 'snyk-monitor has log level variable');
366+
t.ok(logLevel.value, 'snyk-monitor has log level value');
366367
});
367368

368369
tap.test('snyk-monitor has nodeSelector', async (t) => {

0 commit comments

Comments
 (0)