From 538a539c46726d41526cc4711e55594ea19d2ab9 Mon Sep 17 00:00:00 2001 From: Fabricio C Zuardi Date: Tue, 14 Nov 2023 17:00:35 -0300 Subject: [PATCH] fix(test-setup):interrupt test when test setup fails --- src/k6/utils/test-bucket.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/k6/utils/test-bucket.js b/src/k6/utils/test-bucket.js index 10830b3..e757e2b 100644 --- a/src/k6/utils/test-bucket.js +++ b/src/k6/utils/test-bucket.js @@ -1,10 +1,10 @@ -import { check } from 'k6' +import { check, fail } from 'k6' import { crypto } from "k6/experimental/webcrypto" import { aws } from "./clis.js" import tags from "./tags.js" export function bucketSetup(s3Config) { - const bucketName = `test-k6-jslib-aws-${crypto.randomUUID()}` + const bucketName = `test-${crypto.randomUUID()}` const createBucketResult = aws(s3Config, "s3", ["mb", `s3://${bucketName}`]) console.log(createBucketResult) const checkTags = { @@ -13,7 +13,11 @@ export function bucketSetup(s3Config) { command: tags.commands.CLI_AWS_S3_MB, } check(createBucketResult, { - [checkTags.command]: out => out.includes(bucketName)}, checkTags) + [checkTags.command]: out => !out.includes("exit status") && out.includes(bucketName) + }, checkTags) + if (createBucketResult.includes("exit status")) { + fail("Failed `s3 mb` during test setup") + } return {bucketName, s3Config} }