Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(layers): add arm64 to integration test matrix #1720

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_dispatch:
inputs:
prNumber:
description: "(Optional) PR Number. If you specify a value the value of the branch field will be ignored."
description: '(Optional) PR Number. If you specify a value the value of the branch field will be ignored.'
required: false
default: ""
default: ''

jobs:
run-e2e-tests-on-utils:
Expand All @@ -19,12 +19,21 @@ jobs:
contents: read
strategy:
matrix:
package: [layers, packages/logger, packages/metrics, packages/tracer, packages/parameters, packages/idempotency]
package:
[
layers,
packages/logger,
packages/metrics,
packages/tracer,
packages/parameters,
packages/idempotency,
]
version: [14, 16, 18]
arch: [x86_64, arm64]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
# If we pass a PR Number when triggering the workflow we will retrieve the PR info and get its headSHA
- name: Extract PR details
id: extract_PR_details
Expand All @@ -38,7 +47,7 @@ jobs:
# we checkout the PR at that point in time
- name: Checkout PR code
if: ${{ inputs.prNumber != '' }}
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ steps.extract_PR_details.outputs.headSHA }}
- name: Setup NodeJS
Expand All @@ -59,5 +68,6 @@ jobs:
env:
RUNTIME: nodejs${{ matrix.version }}x
CI: true
ARCH: ${{ matrix.arch }}
JSII_SILENCE_WARNING_DEPRECATED_NODE_VERSION: true
run: npm run test:e2e -w ${{ matrix.package }}
2 changes: 1 addition & 1 deletion packages/idempotency/tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const RESOURCE_NAME_PREFIX = 'Idempotency-E2E';
export const RESOURCE_NAME_PREFIX = 'Idempotency';

export const ONE_MINUTE = 60 * 1_000;
export const TEARDOWN_TIMEOUT = 5 * ONE_MINUTE;
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomUUID } from 'node:crypto';

const RESOURCE_NAME_PREFIX = 'Logger-E2E';
const RESOURCE_NAME_PREFIX = 'Logger';
const ONE_MINUTE = 60 * 1000;
const TEST_CASE_TIMEOUT = ONE_MINUTE;
const SETUP_TIMEOUT = 5 * ONE_MINUTE;
Expand Down
2 changes: 1 addition & 1 deletion packages/metrics/tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomUUID } from 'node:crypto';
import { MetricUnits } from '../../src';

const RESOURCE_NAME_PREFIX = 'Metrics-E2E';
const RESOURCE_NAME_PREFIX = 'Metrics';
const ONE_MINUTE = 60 * 1000;
const TEST_CASE_TIMEOUT = 3 * ONE_MINUTE;
const SETUP_TIMEOUT = 5 * ONE_MINUTE;
Expand Down
2 changes: 1 addition & 1 deletion packages/parameters/tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const RESOURCE_NAME_PREFIX = 'Parameters-E2E';
export const RESOURCE_NAME_PREFIX = 'Parameters';
export const ONE_MINUTE = 60 * 1000;
export const TEST_CASE_TIMEOUT = 3 * ONE_MINUTE;
export const SETUP_TIMEOUT = 5 * ONE_MINUTE;
Expand Down
3 changes: 2 additions & 1 deletion packages/parameters/tests/helpers/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
import {
concatenateResourceName,
getRuntimeKey,
getArchitectureKey,
TestDynamodbTable,
TestNodejsFunction,
} from '@aws-lambda-powertools/testing-utils';
Expand Down Expand Up @@ -58,7 +59,7 @@ class TestSecureStringParameter extends Construct {

const { value } = props;

const name = `/secure/${getRuntimeKey()}/${randomUUID()}`;
const name = `/secure/${getRuntimeKey()}/${getArchitectureKey()}/${randomUUID()}`;
const secureStringCreator = new AwsCustomResource(
testStack.stack,
`create-${randomUUID()}`,
Expand Down
22 changes: 20 additions & 2 deletions packages/testing/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Runtime } from 'aws-cdk-lib/aws-lambda';
import { Runtime, Architecture } from 'aws-cdk-lib/aws-lambda';

/**
* The default AWS Lambda runtime to use when none is provided.
Expand All @@ -14,4 +14,22 @@ const TEST_RUNTIMES = {
[defaultRuntime]: Runtime.NODEJS_18_X,
} as const;

export { TEST_RUNTIMES, defaultRuntime };
/**
* The default AWS Lambda architecture to use when none is provided.
*/
const defaultArchitecture = 'x86_64';

/**
* The AWS Lambda architectures that are supported by the project.
*/
const TEST_ARCHITECTURES = {
[defaultArchitecture]: Architecture.X86_64,
arm64: Architecture.ARM_64,
} as const;

export {
TEST_RUNTIMES,
defaultRuntime,
TEST_ARCHITECTURES,
defaultArchitecture,
};
31 changes: 27 additions & 4 deletions packages/testing/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { randomUUID } from 'node:crypto';
import { TEST_RUNTIMES, defaultRuntime } from './constants';
import {
TEST_RUNTIMES,
defaultRuntime,
TEST_ARCHITECTURES,
defaultArchitecture,
} from './constants';

const isValidRuntimeKey = (
runtime: string
Expand All @@ -15,6 +20,21 @@ const getRuntimeKey = (): keyof typeof TEST_RUNTIMES => {
return runtime;
};

const isValidArchitectureKey = (
architecture: string
): architecture is keyof typeof TEST_ARCHITECTURES =>
architecture in TEST_ARCHITECTURES;

const getArchitectureKey = (): keyof typeof TEST_ARCHITECTURES => {
const architecture: string = process.env.ARCH || defaultArchitecture;

if (!isValidArchitectureKey(architecture)) {
throw new Error(`Invalid architecture key value: ${architecture}`);
}

return architecture;
};

/**
* Generate a unique name for a test.
*
Expand All @@ -23,10 +43,11 @@ const getRuntimeKey = (): keyof typeof TEST_RUNTIMES => {
* @example
* ```ts
* process.env.RUNTIME = 'nodejs18x';
* const testPrefix = 'E2E-TRACER';
* process.env.ARCH = 'x86_64';
* const testPrefix = 'TRACER';
* const testName = 'someFeature';
* const uniqueName = generateTestUniqueName({ testPrefix, testName });
* // uniqueName = 'E2E-TRACER-node18-12345-someFeature'
* // uniqueName = 'TRACER-18-x86-12345-someFeature'
* ```
*/
const generateTestUniqueName = ({
Expand All @@ -38,7 +59,8 @@ const generateTestUniqueName = ({
}): string =>
[
testPrefix,
getRuntimeKey().replace(/[jsx]/g, ''),
getRuntimeKey().replace(/[nodejsx]/g, ''),
getArchitectureKey().replace(/_64/g, ''),
randomUUID().toString().substring(0, 5),
testName,
]
Expand Down Expand Up @@ -81,4 +103,5 @@ export {
generateTestUniqueName,
concatenateResourceName,
findAndGetStackOutputValue,
getArchitectureKey,
};
9 changes: 7 additions & 2 deletions packages/testing/src/resources/TestNodejsFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { Tracing } from 'aws-cdk-lib/aws-lambda';
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
import { randomUUID } from 'node:crypto';
import { TEST_RUNTIMES } from '../constants';
import { concatenateResourceName, getRuntimeKey } from '../helpers';
import { TEST_RUNTIMES, TEST_ARCHITECTURES } from '../constants';
import {
concatenateResourceName,
getRuntimeKey,
getArchitectureKey,
} from '../helpers';
import type { TestStack } from '../TestStack';
import type { ExtraTestProps, TestNodejsFunctionProps } from './types';

Expand All @@ -29,6 +33,7 @@ class TestNodejsFunction extends NodejsFunction {
resourceName: extraProps.nameSuffix,
}),
runtime: TEST_RUNTIMES[getRuntimeKey()],
architecture: TEST_ARCHITECTURES[getArchitectureKey()],
logRetention: RetentionDays.ONE_DAY,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/tracer/tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Prefix for all resources created by the E2E tests
const RESOURCE_NAME_PREFIX = 'Tracer-E2E';
const RESOURCE_NAME_PREFIX = 'Tracer';
// Constants relating time to be used in the tests
const ONE_MINUTE = 60 * 1_000;
const TEST_CASE_TIMEOUT = 5 * ONE_MINUTE;
Expand Down
Loading