Closed brandiqa closed 1 year ago
Hello,
Running the pub/sub test with options crashes the test. Below is the output:
./k6 run --duration 10s --vus 10 scripts/test.js ... execution: local script: scripts/test.js output: - scenarios: (100.00%) 1 scenario, 10 max VUs, 40s max duration (incl. graceful stop): * default: 10 looping VUs for 10s (gracefulStop: 30s) panic: TypeError: Not a function: [object Object] at file:///home/mike/projects/github/k6-nats-example/scripts/test.js:19:4(2) running (03.0s), 10/10 VUs, 10 complete and 0 interrupted iterations goroutine 159 [running]:-------------------------] 10 VUs 03.0s/10s github.com/dop251/goja.(*Runtime).wrapJSFunc.func1({0xc0021e9980, 0x1, 0x4}) github.com/dop251/goja@v0.0.0-20220110113543-261677941f3c/runtime.go:2161 +0x525 github.com/ydarias/xk6-nats.(*Nats).Subscribe.func1(0xc000b562a0) github.com/ydarias/xk6-nats@v0.0.0-20211125102117-532fa12d017c/nats.go:73 +0x47 github.com/nats-io/nats%2ego.(*Conn).waitForMsgs(0xc0005c3200, 0xc002233740) github.com/nats-io/nats.go@v1.13.1-0.20220121202836-972a071d373d/nats.go:2677 +0x442 created by github.com/nats-io/nats%2ego.(*Conn).subscribeLocked github.com/nats-io/nats.go@v1.13.1-0.20220121202836-972a071d373d/nats.go:3897 +0x3f1
I've tested this in Windows and Ubuntu WSL2 running the latest version go version go1.17.8 linux/amd64.
Here's the source code:
import { check, sleep } from "k6"; import { Nats } from "k6/x/nats"; const natsConfig = { servers: ["nats://localhost:4222"], unsafe: true, }; const publisher = new Nats(natsConfig); const subscriber = new Nats(natsConfig); // export const options = { // duration: "10s", // vus: 10, // }; export default function () { subscriber.subscribe("topic", (msg) => { check(msg, { "Is expected message": (m) => m.data === "the message", "Is expected topic": (m) => m.topic === "topic", }); }); sleep(1); publisher.publish("topic", "the message"); sleep(1); } export function teardown() { publisher.close(); subscriber.close(); }
Line 19 where it fails is where the check function has been declared.
check
Kindly assist.
Thank you @brandiqa
Right now I am busy with a project from my company, I will try to solve it as soon as possible.
Hello,
Running the pub/sub test with options crashes the test. Below is the output:
I've tested this in Windows and Ubuntu WSL2 running the latest version go version go1.17.8 linux/amd64.
Here's the source code:
Line 19 where it fails is where the
check
function has been declared.Kindly assist.