From a5f58aeaa61a3111a3578c5dbbe52d168c03f834 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Wed, 9 Aug 2023 10:54:47 +0200 Subject: [PATCH] chore: fix test and add vscode workspace config (#3418) - fix for randomly failing unit test after merging #3375 - add workspace config for vscode - increase coverage --- .gitignore | 1 - .vscode/gh-runners.code-workspace | 34 +++++++++++++++++++ .../src/scale-runners/scale-down.test.ts | 12 +++---- 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 .vscode/gh-runners.code-workspace diff --git a/.gitignore b/.gitignore index 3ebfd49abd..b94a480ede 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ secrets.auto.tfvars *.gz *.tgz *.env* -.vscode **/coverage/* diff --git a/.vscode/gh-runners.code-workspace b/.vscode/gh-runners.code-workspace new file mode 100644 index 0000000000..254f19cd70 --- /dev/null +++ b/.vscode/gh-runners.code-workspace @@ -0,0 +1,34 @@ +{ + "folders": [ + { + "name": "✨ root", + "path": ".." + }, + { + "name": "🚀 @lambda/functions/control-plane", + "path": "../lambdas/functions/control-plane" + }, + { + "name": "🚀 @lambda/functions/gh-agent-syncer", + "path": "../lambdas/functions/gh-agent-syncer" + }, + { + "name": "🚀 @lambda/functions/webhook", + "path": "../lambdas/functions/webhook" + }, + { + "name": "📦 @lambda/libs/aws-ssm-util", + "path": "../lambdas/libs/aws-ssm-util" + }, + { + "name": "📦 @lambdas/libs/aws-powertools-util", + "path": "../lambdas/libs/aws-powertools-util" + } + ], + "settings": { + "jest.autoRun": "on", + "jest.disabledWorkspaceFolders": [ + "✨ root" + ] + } +} diff --git a/lambdas/functions/control-plane/src/scale-runners/scale-down.test.ts b/lambdas/functions/control-plane/src/scale-runners/scale-down.test.ts index 01b2cdeb65..bc802560b2 100644 --- a/lambdas/functions/control-plane/src/scale-runners/scale-down.test.ts +++ b/lambdas/functions/control-plane/src/scale-runners/scale-down.test.ts @@ -86,6 +86,7 @@ let DEFAULT_ORG_RUNNERS_ORPHANED: RunnerInfo[]; // i-running-111 | Repo | running and not exceeding minimumRunningTimeInMinutes // i-running-112 | Org | busy // i-running-113 | Repo | busy +const oldest = moment(new Date()).subtract(25, 'minutes').toDate(); const DEFAULT_RUNNERS_ORIGINAL = [ { instanceId: 'i-idle-101', @@ -105,17 +106,13 @@ const DEFAULT_RUNNERS_ORIGINAL = [ }, { instanceId: 'i-oldest-idle-103', - launchTime: moment(new Date()) - .subtract(minimumRunningTimeInMinutes + 27, 'minutes') - .toDate(), + launchTime: oldest, type: 'Repo', owner: `${TEST_DATA.repositoryOwner}/${TEST_DATA.repositoryName}`, }, { instanceId: 'i-oldest-idle-104', - launchTime: moment(new Date()) - .subtract(minimumRunningTimeInMinutes + 27, 'minutes') - .toDate(), + launchTime: oldest, type: 'Org', owner: TEST_DATA.repositoryOwner, }, @@ -229,6 +226,7 @@ describe('scaleDown', () => { process.env.ENVIRONMENT = environment; process.env.MINIMUM_RUNNING_TIME_IN_MINUTES = minimumRunningTimeInMinutes.toString(); process.env.RUNNER_BOOT_TIME_IN_MINUTES = runnerBootTimeInMinutes.toString(); + nock.disableNetConnect(); jest.clearAllMocks(); jest.resetModules(); @@ -398,6 +396,7 @@ describe('scaleDown', () => { idleCount: 3, cron: '* * * * * *', timeZone: 'Europe/Amsterdam', + evictionStrategy: 'oldest_first', }; beforeEach(() => { process.env.SCALE_DOWN_CONFIG = JSON.stringify([defaultConfig]); @@ -542,6 +541,7 @@ describe('scaleDown', () => { idleCount: 3, cron: '* * * * * *', timeZone: 'Europe/Amsterdam', + evictionStrategy: 'oldest_first', }, ]); });