From 257dba8787ee3b3d986cd5aa8a8633a98a3280dd Mon Sep 17 00:00:00 2001 From: hveldstra Date: Wed, 17 Jan 2024 16:16:16 +0000 Subject: [PATCH 1/3] fix(fargate): prevent race condition between leader and follower tasks --- packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker b/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker index 94953d3f32..5b08f05e92 100644 --- a/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker +++ b/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker @@ -137,7 +137,7 @@ check_dependencies () { sync_test_data () { mkdir "$TEST_DATA" pushd "$TEST_DATA" >/dev/null - aws s3 sync "$s3_test_data_path" . >/dev/null + aws s3 sync --exclude node_modules_stream.zip "$s3_test_data_path" . >/dev/null debug "$(pwd)" debug "$(ls -a)" From 614115f25981f322965454f5164fafa65d96914d Mon Sep 17 00:00:00 2001 From: hveldstra Date: Thu, 18 Jan 2024 12:13:17 +0000 Subject: [PATCH 2/3] feat(fargate): emit prepack_end message from leader task --- packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker b/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker index 5b08f05e92..3166a46316 100644 --- a/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker +++ b/packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker @@ -179,6 +179,7 @@ install_dependencies () { echo "Modules pre-packaged" aws s3 mv "$s3_test_data_path/node_modules_stream.zip" "$s3_test_data_path/node_modules.zip" send_message "leader npm prepack end `date +%s`" "debug" + send_message "prepack_end" "leader" else # wait until node_modules.zip is available and unzip, or timeout # TODO: use aws s3api wait object-exists with a custom timeout From f3ce7e841bd90b2abbda881e40e4184c67b7cfa8 Mon Sep 17 00:00:00 2001 From: hveldstra Date: Thu, 18 Jan 2024 13:07:10 +0000 Subject: [PATCH 3/3] feat(fargate): wait for prepack_end from leader task before continuing This allows the leader task to get ready before launching more tasks. The wait period is 60s so as not to increase the overall startup time for a test run with many workers. --- .../artillery/lib/platform/aws-ecs/legacy/run-cluster.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js b/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js index 98c7caec3e..739c67a374 100644 --- a/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js +++ b/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js @@ -1538,6 +1538,8 @@ async function launchLeadTask(context) { throw runErr; } + await awaitOnEE(context.reporterEvents, 'prepack_end', 1000 * 60 * 1); + return context; } @@ -1853,6 +1855,10 @@ async function listen(context, ee) { console.error('Error processing ensure directive'); } } + + if (body.type === 'leader' && body.msg === 'prepack_end') { + ee.emit('prepack_end'); + } }); r.on('stats', async (stats) => {