grafana / k6-jslib-aws

Javascript Library allowing to interact with AWS resources from k6 scripts
Apache License 2.0
18 stars 29 forks source link

Unable to get example to work #4

Closed depak-0302 closed 1 year ago

depak-0302 commented 2 years ago

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):

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 *+)$ `

mstoykov commented 2 years ago

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 commented 2 years ago

It does not work. There is no error and nothing uploaded to the s3 bucket.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Mihail Stoykov @.> Sent: Wednesday, May 25, 2022 4:01:38 AM To: grafana/k6-jslib-aws @.> Cc: depak-0302 @.>; Mention @.> Subject: Re: [grafana/k6-jslib-aws] Unable to get example to work (Issue #4)

Hi @depak-0302https://github.com/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?

— Reply to this email directly, view it on GitHubhttps://github.com/grafana/k6-jslib-aws/issues/4#issuecomment-1136919453, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATMQHZT5ZVUGHSIAFVFJS5TVLXM6FANCNFSM5WWVSUGQ. You are receiving this because you were mentioned.Message ID: @.***>

mstoykov commented 2 years ago

@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.

oleiade commented 2 years ago

Hi @depak-0302,

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

depak-0302 commented 2 years ago

No we did not get it to work. We were able to use AWS Codebuild to put the k6 report into S3 bucket.


From: Théo Crevon @.> Sent: Friday, June 10, 2022 5:15 AM To: grafana/k6-jslib-aws @.> Cc: depak-0302 @.>; Mention @.> Subject: Re: [grafana/k6-jslib-aws] Unable to get example to work (Issue #4)

Hi @depak-0302https://github.com/depak-0302,

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

— Reply to this email directly, view it on GitHubhttps://github.com/grafana/k6-jslib-aws/issues/4#issuecomment-1152153995, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATMQHZXBTWSPE56D3RFEDWDVOMBU5ANCNFSM5WWVSUGQ. You are receiving this because you were mentioned.Message ID: @.***>

oleiade commented 2 years ago

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 👍🏻

depak-0302 commented 1 year ago

It gives following error: The AWS Access Key Id you provided does not exist in our records

However it is the correct Access key Id as I am able to run aws s3 ls​ command immediately after the k6 command as can be seen below.

INFO[0010] Request: PUT /K6LoadTestResults-1653488328470.html HTTP/1.1 Host: cds-consumer-demographic-api-non-prod.s3.us-east-1.amazonaws.com User-Agent: k6/0.38.3 (https://k6.io/) Transfer-Encoding: chunked Authorization: AWS4-HMAC-SHA256 Credential=ASIAR***ZJMFMOT/20220525/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=a3239215d99da0b0893769a058d7b642b89da23d31552092a44767dbb6a4e404 Content-Type: application/x-www-form-urlencoded X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 X-Amz-Date: 20220525T141848Z Accept-Encoding: gzip

0

iter=0 request_id=47638284-533b-449b-4961-8b607fa66efb source=http-debug vu=0 INFO[0011] Response: HTTP/1.1 403 Forbidden Connection: close Transfer-Encoding: chunked Content-Type: application/xml Date: Wed, 25 May 2022 14:18:48 GMT Server: AmazonS3 X-Amz-Id-2: RE8itJGsJXHCRwbOBmZ4mh0xrN2rxcmEklRe75nn2+dj3TH8hcZxSdJAqipvXjhOLSMgYAsB06M= X-Amz-Request-Id: J5E40050ZTTQMXHN

162 <?xml version="1.0" encoding="UTF-8"?>

InvalidAccessKeyIdThe AWS Access Key Id you provided does not exist in our records.ASIAR********ZJMFMOTJ5E40050ZTTQMXHNRE8itJGsJXHCRwbOBmZ4mh0xrN2rxcmEklRe75nn2+dj3TH8hcZxSdJAqipvXjhOLSMgYAsB06M=

0

iter=0 request_id=47638284-533b-449b-4961-8b607fa66efb source=http-debug vu=0 INFO[0011] [k6-reporter v2.3.0] Generating HTML summary report source=console

LATLmacJ5QTMD6R:k6 (depak/us699393_loadtesting *+)$ aws s3 ls 2020-07-24 09:24:17 071633014771-splunk-failed-us-east-1 2021-08-18 08:15:38 aws-emr-resources-071633014771-us-east-1 2020-10-26 18:30:20 aws-glue-scripts-071633014771-us-east-1 2020-10-26 18:30:21 aws-glue-temporary-071633014771-us-east-1 2021-06-15 13:51:35 aws-logs-071633014771-us-east-1 020-10-19 20:14:46 build-assets-awsconsumerdatanp-us-east-1 2022-01-21 13:59:50 build-assets-awsconsumerdatanp-us-west-2 2022-04-28 12:17:27 cdk-hnb659fds-assets-071633014771-us-east-1 2021-08-04 15:30:19 cdktoolkit-stagingbucket-1akdluvnu9l36 2021-07-29 09:39:25 cdktoolkit-stagingbucket-dcpz6ocgonkf 2022-04-04 14:41:54 cds-code-pipeline-artifacts-bucket-071633014771-us-east-1 2022-05-20 16:37:07 cds-consumer-demographic-api-non-prod 2020-11-19 13:39:15 cds-idg-gcid-loader-logs-non-prod 2020-11-19 13:39:15 cds-idg-gcid-loader-non-prod 2020-12-02 14:43:58 cds-idg-iph-loader-logs-non-prod 2020-12-02 14:43:58 cds-idg-iph-loader-non-prod


From: Mihail Stoykov @.> Sent: Wednesday, May 25, 2022 8:48 AM To: grafana/k6-jslib-aws @.> Cc: depak-0302 @.>; Mention @.> Subject: Re: [grafana/k6-jslib-aws] Unable to get example to work (Issue #4)

@depak-0302https://github.com/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.

— Reply to this email directly, view it on GitHubhttps://github.com/grafana/k6-jslib-aws/issues/4#issuecomment-1137197225, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATMQHZRJT4L5W6UGXJGSV6LVLYOSVANCNFSM5WWVSUGQ. You are receiving this because you were mentioned.Message ID: @.***>

oleiade commented 1 year ago

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.