From 8ebf25b08762f6eb83d793b08b34a20c23772a61 Mon Sep 17 00:00:00 2001 From: Bernardo Guerreiro Date: Thu, 11 Jan 2024 18:23:12 +0000 Subject: [PATCH 1/3] test(lambda): use zx to improve logging --- .../test/cloud-e2e/lambda/run-lambda.test.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js b/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js index 9c9f47eeaf..bc5c2fe9e7 100644 --- a/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js +++ b/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js @@ -1,19 +1,14 @@ const tap = require('tap'); -const { execute } = require('../../cli/_helpers.js'); +const { $ } = require('zx'); tap.test('Run a test on AWS Lambda', async (t) => { - const [exitCode, output] = await execute([ - 'run:lambda', - '--count', - '10', - '--region', - 'eu-west-1', - '--config', - './test/cloud-e2e/lambda/fixtures/quick-loop-with-csv/config.yml', - './test/cloud-e2e/lambda/fixtures/quick-loop-with-csv/blitz.yml' - ]); + const configPath = `${__dirname}/fixtures/quick-loop-with-csv/config.yml`; + const scenarioPath = `${__dirname}/fixtures/quick-loop-with-csv/blitz.yml`; - t.equal(exitCode, 0, 'CLI should exit with code 0'); + const output = + await $`artillery run-lambda --count 10 --region eu-west-1 --config ${configPath} ${scenarioPath}`; + + t.equal(output.exitCode, 0, 'CLI should exit with code 0'); t.ok( output.stdout.indexOf('Summary report') > 0, From 2760ec0fccbe6acdd55179fbc129fcd8baa31895 Mon Sep 17 00:00:00 2001 From: Bernardo Guerreiro Date: Thu, 11 Jan 2024 18:24:17 +0000 Subject: [PATCH 2/3] ci(test): make cloud and github vars available for aws tests to use --- .github/workflows/run-aws-tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-aws-tests.yml b/.github/workflows/run-aws-tests.yml index 9a56ec5c80..4a049aef9f 100644 --- a/.github/workflows/run-aws-tests.yml +++ b/.github/workflows/run-aws-tests.yml @@ -68,4 +68,8 @@ jobs: - run: npm run test:aws --workspace artillery env: FORCE_COLOR: 1 - ECR_IMAGE_VERSION: ${{ github.sha }} # the image is published with the sha of the commit within this repo \ No newline at end of file + ECR_IMAGE_VERSION: ${{ github.sha }} # the image is published with the sha of the commit within this repo + ARTILLERY_CLOUD_ENDPOINT: ${{ secrets.ARTILLERY_CLOUD_ENDPOINT_TEST }} + ARTILLERY_CLOUD_API_KEY: ${{ secrets.ARTILLERY_CLOUD_API_KEY_TEST }} + GITHUB_REPO: ${{ github.repository }} + GITHUB_ACTOR: ${{ github.actor }} \ No newline at end of file From 8cf57414afd9687de4c729da9bdc22881c0141f6 Mon Sep 17 00:00:00 2001 From: Bernardo Guerreiro Date: Thu, 11 Jan 2024 18:25:52 +0000 Subject: [PATCH 3/3] test(lambda): make lambda test report to cloud with tags --- packages/artillery/test/cli/_helpers.js | 16 +++++++++++++++- .../test/cloud-e2e/lambda/run-lambda.test.js | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/artillery/test/cli/_helpers.js b/packages/artillery/test/cli/_helpers.js index c2d0c9299c..7c63fb6f80 100644 --- a/packages/artillery/test/cli/_helpers.js +++ b/packages/artillery/test/cli/_helpers.js @@ -30,4 +30,18 @@ async function getRootPath(filename) { return path.resolve(__dirname, '..', '..', filename); } -module.exports = { execute, deleteFile, getRootPath, returnTmpPath }; +function getTestTags(additionalTags) { + const actorTag = `actor:${process.env.GITHUB_ACTOR || 'localhost'}`; + const repoTag = `repo:${process.env.GITHUB_REPO || 'artilleryio/artillery'}`; + const ciTag = `ci:${process.env.GITHUB_ACTIONS ? 'true' : 'false'}`; + + return `${repoTag},${actorTag},${ciTag},${additionalTags.join(',')}`; +} + +module.exports = { + execute, + deleteFile, + getRootPath, + returnTmpPath, + getTestTags +}; diff --git a/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js b/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js index bc5c2fe9e7..fb0cba6505 100644 --- a/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js +++ b/packages/artillery/test/cloud-e2e/lambda/run-lambda.test.js @@ -1,12 +1,14 @@ const tap = require('tap'); const { $ } = require('zx'); +const { getTestTags } = require('../../cli/_helpers.js'); tap.test('Run a test on AWS Lambda', async (t) => { + const tags = getTestTags(['type:acceptance']); const configPath = `${__dirname}/fixtures/quick-loop-with-csv/config.yml`; const scenarioPath = `${__dirname}/fixtures/quick-loop-with-csv/blitz.yml`; const output = - await $`artillery run-lambda --count 10 --region eu-west-1 --config ${configPath} ${scenarioPath}`; + await $`artillery run-lambda --count 10 --region eu-west-1 --config ${configPath} --record --tags ${tags} ${scenarioPath}`; t.equal(output.exitCode, 0, 'CLI should exit with code 0');