xk6-cognito verification -> Got errors and it didn't work

Tadashi Shigeoka ·  Tue, October 25, 2022

I tried to verify the k6 module xk6-cognito, but I’ll share the story of how it got errors and didn’t work.

k6 - load testing tool

tmieulet/xk6-cognito: An example module for https://k6.io/ to get a cognito access token using USER_SRP_AUTH flow.

Preparing k6 to use the xk6-cognito module

go version  

go version go1.19.3 darwin/arm64
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build master   --with github.com/tmieulet/xk6-cognito

Running xk6-cognito sample code

Conclusion: It didn’t work ❌

git clone [email protected]:tmieulet/xk6-cognito.git
./k6 run --vus 1 --duration 2s ~/works/xk6-cognito/examples/loadTest.js

          /      |‾‾| /‾‾/   /‾‾/   
     /  /       |  |/  /   /  /    
    /  /        |     (   /   ‾‾  
   /             |  |   |  (‾)  | 
  / __________   |__| __ _____/ .io

ERRO[0000] TypeError: could not convert function call parameter 0: could not convert eu-west-1 to context.Context
  at reflect.methodValueCall (native)
  at file:///Users/your_name/works/xk6-cognito/examples/auth-cognito.js:14:15(47)
  at go.k6.io/k6/js.(*InitContext).Require-fm (native)
  at file:///Users/your_name/works/xk6-cognito/examples/loadTest.js:7:0(42)
  at native  hint="script exception"

It seems this was already reported as an issue.

Could not connect to cognito service · Issue #1 · tmieulet/xk6-cognito

That’s all from the Gemba about trying to get Amazon Cognito access tokens with k6.