diff --git a/src/lib/test-outbound/TestCaseRunner.js b/src/lib/test-outbound/TestCaseRunner.js index 0bf1da94..8a76df80 100644 --- a/src/lib/test-outbound/TestCaseRunner.js +++ b/src/lib/test-outbound/TestCaseRunner.js @@ -40,12 +40,17 @@ const SKIP_EMPTY_EXECUTION_ORDER = false // skip testCases without executionOrde class TestCaseRunner { constructor (config, logger) { this.config = config - this.logger = logger || loggerFactory('TestCaseRunner') + this.logger = logger || loggerFactory({ context: 'TTK', system: 'TestCaseRunner' }) } + static lib = inputTemplate => inputTemplate.test_cases.reduce((acc, testCase) => + testCase.options?.lib ? testCase.requests.reduce((acc, request) => ({ ...acc, [`${testCase.id}.${request.id}`]: request }), acc) : acc + , {}) + async runAll ({ processTestCase, inputTemplate, traceID, variableData, dfspId, globalConfig, metrics }) { + const lib = TestCaseRunner.lib(inputTemplate) const runOneTestCase = (testCase, index) => () => { globalConfig.totalProgress.testCasesProcessed++ return processTestCase( @@ -59,7 +64,8 @@ class TestCaseRunner { metrics, inputTemplate.name, inputTemplate.saveReport, - index + index, + lib ) } diff --git a/src/lib/test-outbound/outbound-initiator.js b/src/lib/test-outbound/outbound-initiator.js index deb0411a..775d95f3 100644 --- a/src/lib/test-outbound/outbound-initiator.js +++ b/src/lib/test-outbound/outbound-initiator.js @@ -181,6 +181,7 @@ const OutboundSendLoop = async (inputTemplate, traceID, dfspId, iterations, metr const startedTimeStamp = new Date() // Deep copy the template const tmpTemplate = JSON.parse(JSON.stringify(inputTemplate)) + const lib = TestCaseRunner.lib(tmpTemplate) // Execute all the test cases in the template for (const i in tmpTemplate.test_cases) { await processTestCase( @@ -194,7 +195,8 @@ const OutboundSendLoop = async (inputTemplate, traceID, dfspId, iterations, metr metrics, tmpTemplate.name, tmpTemplate.saveReport, - i + i, + lib ) } const completedTimeStamp = new Date() @@ -254,7 +256,8 @@ const processTestCase = async ( metrics, templateName, saveReport, - testCaseIndex + testCaseIndex, + lib ) => { const tracing = getTracing(traceID) const testCaseStartedTime = new Date() @@ -264,6 +267,12 @@ const processTestCase = async ( // Store the request ids into a new array const templateIDArr = [] for (const i in testCase.requests) { + if (testCase.requests[i].call) { + testCase.requests[i] = _.merge( + structuredClone(requestsObj[testCase.requests[i].call] ?? lib[testCase.requests[i].call]), + testCase.requests[i] + ) + } requestsObj[testCase.requests[i].id] = testCase.requests[i] templateIDArr.push(testCase.requests[i].id) }