grafana / k6-jslib-aws

Javascript Library allowing to interact with AWS resources from k6 scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to get example to work

depak-0302 opened this issue · comments

I'm trying to get simple example to upload data to s3 bucket but it is not working. It does get any error message.

import http from "k6/http";
import { check } from "k6";
import { AWSConfig, S3Client } from "https://jslib.k6.io/aws/0.3.0/s3.js";

const awsConfig = new AWSConfig(
  __ENV.AWS_REGION,
  __ENV.AWS_ACCESS_KEY_ID,
  __ENV.AWS_SECRET_ACCESS_KEY
);

const s3 = new S3Client(awsConfig);

export default function () {
  let res = http.get("https://test-api.k6.io");
  check(res, { "is status 200": (r) => r.status === 200 });
}

export function handleSummary(data) {
  s3.putObject("myBucket", "myResultsKey", JSON.stringify(data));
}

When I run the above, output is as follows:

`LATLmacJ5QTMD6R:examples (main *+)$ k6 run s3_test.js

      /\      |‾‾| /‾‾/   /‾‾/   
 /\  /  \     |  |/  /   /  /    
/  \/    \    |     (   /   ‾‾\  

/ \ | |\ \ | (‾) |
/ __________ \ |__| _\ ____/ .io

execution: local
script: s3_test.js
output: -

scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

running (00m00.1s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m00.1s/10m0s 1/1 iters, 1 per VU
LATLmacJ5QTMD6R:examples (main *+)$ `

Hi @depak-0302,

It does get any error message.

do you mean it doesn't ?
From the looks of it - it works, otherwise an error would've been printed.

Can you please double check that there isn't an object uploaded to the configured S3 bucket?

@depak-0302 can you run with --http-debug=full and see what the requests are, potentially copypasting the result here after some sanytization as it will likely include some sensitive information about your AWS account.

Hi @depak-0302,

Sorry to hear you're experiencing issues with uploading files to S3 buckets. Did you manage to solve your issue already?

Glad to read you've found a solution to your issue.

I don't think we'll be able to do more potential bug hunting without more input from your side, so I'll close for now. Please don't hesitate to reopen if you ever find the time to provide us more context, as requested before 👍🏻

Hi @depak-0302 👋🏻

Thanks for coming back to us. I see you are using an older version of k6, can you please confirm which version of the AWS jslib you're using? We've addressed some existing issues with S3 and Authentication in more recent releases, the latest being v0.6.0, and I just want to confirm that you're still experiencing this issue with the latest version.