Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
fix(test-setup):interrupt test when test setup fails
Browse files Browse the repository at this point in the history
  • Loading branch information
fczuardi committed Nov 16, 2023
1 parent 7f720a3 commit 538a539
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/k6/utils/test-bucket.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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}
}

Expand Down

0 comments on commit 538a539

Please sign in to comment.