diff --git a/lambdas/functions/control-plane/src/lambda.test.ts b/lambdas/functions/control-plane/src/lambda.test.ts index 26b130ffe1..4d970f0f22 100644 --- a/lambdas/functions/control-plane/src/lambda.test.ts +++ b/lambdas/functions/control-plane/src/lambda.test.ts @@ -276,14 +276,14 @@ describe('Test scale down lambda wrapper.', () => { describe('Adjust pool.', () => { it('Receive message to adjust pool.', async () => { vi.mocked(adjust).mockResolvedValue(); - await expect(adjustPool({ poolSize: 2, type: 'ec2' }, context)).resolves.not.toThrow(); + await expect(adjustPool({ poolSize: 2 }, context)).resolves.not.toThrow(); }); it('Handle error for adjusting pool.', async () => { const error = new Error('Handle error for adjusting pool.'); vi.mocked(adjust).mockRejectedValue(error); const logSpy = vi.spyOn(logger, 'error'); - await adjustPool({ poolSize: 0, type: 'ec2' }, context); + await adjustPool({ poolSize: 0 }, context); expect(logSpy).toHaveBeenCalledWith(`Handle error for adjusting pool. ${error.message}`, { error }); }); }); diff --git a/lambdas/functions/control-plane/src/local-pool.ts b/lambdas/functions/control-plane/src/local-pool.ts index d743ac759b..ab8c74a1a0 100644 --- a/lambdas/functions/control-plane/src/local-pool.ts +++ b/lambdas/functions/control-plane/src/local-pool.ts @@ -1,7 +1,7 @@ import { adjust } from './pool/pool'; export function run(): void { - adjust({ poolSize: 1, type: 'ec2' }) + adjust({ poolSize: 1 }) .then() .catch((e) => { console.log(e); 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 90320be856..743068e00c 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 @@ -2,6 +2,7 @@ import type { Octokit } from '@octokit/rest'; import { RequestError } from '@octokit/request-error'; import moment from 'moment'; import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { defaultComputeProvider } from '@aws-github-runner/compute-providers/provider-types'; import { controlPlaneProviderRegistry } from '../control-plane-providers'; import * as ghAuth from '../github/auth'; @@ -33,13 +34,12 @@ const mockOctokit = { }; const mockComputeProvider = { - type: 'ec2', list: vi.fn(), bootTimeExceeded: vi.fn(), markOrphan: vi.fn(), unmarkOrphan: vi.fn(), terminate: vi.fn(), -} satisfies ScaleDownComputeProvider; +} satisfies Omit; const mockedResolveCapability = vi.spyOn(controlPlaneProviderRegistry, 'capability'); const mockedAppAuth = vi.mocked(ghAuth.createGithubAppAuth); @@ -177,7 +177,7 @@ describe('Scale down runners', () => { process.env.ENVIRONMENT = ENVIRONMENT; process.env.MINIMUM_RUNNING_TIME_IN_MINUTES = MINIMUM_TIME_RUNNING_IN_MINUTES.toString(); process.env.RUNNER_BOOT_TIME_IN_MINUTES = MINIMUM_BOOT_TIME.toString(); - process.env.COMPUTE_PROVIDER_TYPE = mockComputeProvider.type; + process.env.COMPUTE_PROVIDER_TYPE = defaultComputeProvider; vi.clearAllMocks(); githubCache.clients.clear(); diff --git a/lambdas/functions/control-plane/src/scale-runners/scale-up.test.ts b/lambdas/functions/control-plane/src/scale-runners/scale-up.test.ts index 9df79ceac1..cccab60a98 100644 --- a/lambdas/functions/control-plane/src/scale-runners/scale-up.test.ts +++ b/lambdas/functions/control-plane/src/scale-runners/scale-up.test.ts @@ -16,6 +16,7 @@ import type { CreateScaleUpRunnersInput, ScaleUpComputeProvider, } from './types'; +import { defaultComputeProvider } from '@aws-github-runner/compute-providers/provider-types'; import { getParameter } from '@aws-github-runner/aws-ssm-util'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import type { Octokit } from '@octokit/rest'; @@ -57,12 +58,11 @@ const mockSSMClient = mockClient(SSMClient); const mockSSMgetParameter = vi.mocked(getParameter); const mockPublishRetryMessage = vi.mocked(publishRetryMessage); const testProviderState = { provider: 'test' }; -const mockComputeProvider: ScaleUpComputeProvider = { - type: 'ec2', +const mockComputeProvider = { resolveLabelsForRunners: vi.fn(), getCurrentRunners: vi.fn(), createRunners: vi.fn(), -}; +} satisfies Omit; const mockResolveLabelsForRunners = vi.mocked(mockComputeProvider.resolveLabelsForRunners); const mockGetCurrentRunners = vi.mocked(mockComputeProvider.getCurrentRunners); const mockCreateRunners = vi.mocked(mockComputeProvider.createRunners); @@ -928,7 +928,7 @@ describe('scaleUp with GHES', () => { expect(rejectedMessages).toHaveLength(3); // All 3 messages should be rejected }); - it('Should handle partial EC2 instance creation failures', async () => { + it('handles partial runner creation failures', async () => { mockCreateRunner.mockImplementation(async () => createRunnerResult(['i-12345'], 2)); // Only creates 1 instead of requested 3 const messages = createTestMessages(3); @@ -938,7 +938,7 @@ describe('scaleUp with GHES', () => { expect(rejectedMessages).toEqual(['message-0', 'message-1']); }); - it('Should reject only retryable partial EC2 instance creation failures', async () => { + it('rejects only retryable partial runner creation failures', async () => { mockCreateRunner.mockResolvedValue(createRunnerResult(['i-12345'], 1, 1)); const messages = createTestMessages(3); @@ -947,7 +947,7 @@ describe('scaleUp with GHES', () => { expect(rejectedMessages).toEqual(['message-0']); }); - it('does not retry partial EC2 instance creation failures that are not retryable', async () => { + it('does not retry non-retryable partial runner creation failures', async () => { mockCreateRunner.mockImplementation(async () => createRunnerResult(['i-12345'], 0, 2)); const rejectedMessages = await scaleUpModule.scaleUp(createTestMessages(3)); @@ -1379,7 +1379,7 @@ describe('scaleUp with public GH', () => { expect(rejectedMessages).toHaveLength(3); // All 3 messages should be rejected }); - it('Should handle partial EC2 instance creation failures', async () => { + it('handles partial runner creation failures', async () => { mockCreateRunner.mockImplementation(async () => createRunnerResult(['i-12345'], 2)); // Only creates 1 instead of requested 3 const messages = createTestMessages(3); @@ -1857,7 +1857,7 @@ describe('scaleUp with Github Data Residency', () => { expect(rejectedMessages).toHaveLength(4); // 5 requested - 1 created = 4 rejected }); - it('Should handle partial EC2 instance creation failures', async () => { + it('handles partial runner creation failures', async () => { mockCreateRunner.mockImplementation(async () => createRunnerResult(['i-12345'], 2)); // Only creates 1 instead of requested 3 const messages = createTestMessages(3); @@ -2148,12 +2148,12 @@ describe('Retry mechanism tests', () => { }); describe('compute provider selection', () => { - it('defaults scale-up to EC2 when no compute provider is configured', async () => { + it('uses the default compute provider when none is configured', async () => { delete process.env.COMPUTE_PROVIDER_TYPE; await scaleUpModule.scaleUp(TEST_DATA); - expect(mockedResolveCapability).toHaveBeenCalledWith('ec2', 'scaleUp'); + expect(mockedResolveCapability).toHaveBeenCalledWith(defaultComputeProvider, 'scaleUp'); }); it('rejects unsupported scale-up provider types', async () => {