Skip to content

Commit

Permalink
refactor(test): move getTesId helper to artillery test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi committed Jul 18, 2024
1 parent 92293f0 commit df0d19f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions packages/artillery/test/cloud-e2e/fargate/cw-adot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const fs = require('fs');
const {
generateTmpReportPath,
deleteFile,
getTestTags
getTestTags,
getTestId
} = require('../../helpers');
const { getTestId, getXRayTraces } = require('./fixtures/adot/helpers.js');
const { getXRayTraces } = require('./fixtures/adot/helpers.js');
const {
checkForNegativeValues,
checkAggregateCounterSums
Expand Down
5 changes: 3 additions & 2 deletions packages/artillery/test/cloud-e2e/fargate/dd-adot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ const fs = require('fs');
const {
generateTmpReportPath,
deleteFile,
getTestTags
getTestTags,
getTestId
} = require('../../helpers');
const {
checkForNegativeValues,
checkAggregateCounterSums
} = require('../../helpers/expectations');
const { getDatadogSpans, getTestId } = require('./fixtures/adot/helpers.js');
const { getDatadogSpans } = require('./fixtures/adot/helpers.js');

const A9_PATH = process.env.A9_PATH || 'artillery';
//NOTE: This test reports to Artillery Dashboard to dogfood and improve visibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ const AWS = require('aws-sdk');
const xray = new AWS.XRay({ region: 'us-east-1' });

module.exports = {
getTestId,
getDatadogSpans,
getXRayTraces
};

function getTestId(outputString) {
const regex = /Test run ID: \S+/;
const match = outputString.match(regex);
return match[0].replace('Test run ID: ', '');
}

async function getDatadogSpans(apiKey, appKey, testId, expectedTotalSpans) {
const url = 'https://api.datadoghq.com/api/v2/spans/events/search';
const headers = {
Expand Down
9 changes: 8 additions & 1 deletion packages/artillery/test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,19 @@ const getImageArchitecture = () => {
return process.env.HAS_ARM64_BUILD === 'true' ? 'arm64' : 'x86_64';
};

function getTestId(outputString) {
const regex = /Test run ID: \S+/i;
const match = outputString.match(regex);
return match[0].replace('Test run ID: ', '');
}

module.exports = {
execute,
deleteFile,
getRootPath,
returnTmpPath,
generateTmpReportPath,
getTestTags,
getImageArchitecture
getImageArchitecture,
getTestId
};

0 comments on commit df0d19f

Please sign in to comment.