Skip to content

Commit ea9524c

Browse files
committed
test: fix race condition in test
1 parent 6c182aa commit ea9524c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/system/kind.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import * as fsExtra from 'fs-extra';
21
import * as nock from 'nock';
3-
import { copyFile, readFile, mkdir, exists } from 'fs';
42
import { promisify } from 'util';
3+
import { randomUUID } from 'crypto';
4+
import * as fsExtra from 'fs-extra';
5+
import * as sleep from 'sleep-promise';
56
import { resolve as resolvePath } from 'path';
6-
import { v4 as uuid } from 'uuid';
7+
import { copyFile, readFile, mkdir, exists } from 'fs';
78

89
import * as kubectl from '../helpers/kubectl';
910
import * as kind from '../setup/platforms/kind';
@@ -32,6 +33,9 @@ async function tearDown() {
3233
console.log('Begin removing the snyk-monitor...');
3334
try {
3435
await kind.deleteCluster();
36+
37+
// Workaround. Tests are failing, cos deleting cluster finishes after the test
38+
await sleep(15 * 1000);
3539
} catch (err) {
3640
console.log('Could not cleanly tear down the environment', err.message);
3741
}
@@ -52,7 +56,7 @@ test('Kubernetes-Monitor with KinD', async (jestDoneCallback) => {
5256
.spyOn(fsExtra, 'emptyDirSync')
5357
.mockReturnValue({});
5458

55-
const agentId = uuid();
59+
const agentId = randomUUID();
5660
const retryKubernetesApiRequestMock = jest
5761
.spyOn(kubernetesApiWrappers, 'retryKubernetesApiRequest')
5862
.mockResolvedValueOnce({

0 commit comments

Comments
 (0)