Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error whan calling the mock outside of the k6 code #6

Open
duarnad opened this issue Jan 25, 2024 · 1 comment
Open

Error whan calling the mock outside of the k6 code #6

duarnad opened this issue Jan 25, 2024 · 1 comment

Comments

@duarnad
Copy link

duarnad commented Jan 25, 2024

Hello,

We have a use case where we would like our k6 test to react to be the target of a webhook : k6 makes a call to the service under test, and the service under test signals the end.
To test this use case, we are using curl to send a request to the mock. However, in this case we have the following error:

INFO[0015] 2024/01/25 10:46:36 http: panic serving 10.193.201.116:35838: context canceled at file:///home/raptor/PROJECTS/om-b2w/performance-b2w-g4/k6-scripts/test_xk6-mock.js:7:14(0)
INFO[0015] goroutine 197 [running]:
INFO[0015] net/http.(*conn).serve.func1()
INFO[0015]      net/http/server.go:1854 +0xbf
INFO[0015] panic({0x19154e0, 0xc00182be80})
INFO[0015]      runtime/panic.go:890 +0x263
INFO[0015] github.com/dop251/goja.(*Runtime).wrapJSFunc.func1({0xc00046b810, 0x3, 0x4?})
INFO[0015]      github.com/dop251/goja@v0.0.0-20231027120936-b396bb4c349d/runtime.go:2234 +0x647
INFO[0015] github.com/szkiba/muxpress.middlewareChain.callOne({0x12c1f96?, 0xc002e50250?, 0x18?}, 0xc001e9c200?, 0xc00179e660?, 0xc000e2b950)
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:23 +0x88
INFO[0015] github.com/szkiba/muxpress.middlewareChain.call({0x2d636f8, 0x0, 0x0}, 0x0?, 0xc0021222a0?, {0xc001e9c200, 0x1, 0xc0021222a0?})
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:39 +0xf3
INFO[0015] github.com/szkiba/muxpress.(*router).handle.func1()
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:84 +0x105
INFO[0015] github.com/szkiba/muxpress.(*router).runSync.func1()
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:70 +0x26
INFO[0015] github.com/szkiba/muxpress.syncRunner.func1(0x48?)
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/options.go:130 +0x8b
INFO[0015] github.com/szkiba/muxpress.(*router).runSync(0xc0018d0940, 0xc00046b7c0)
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:69 +0x96
INFO[0015] github.com/szkiba/muxpress.(*router).handle(0xc0018d0940, 0xc0027b0c00, {0x1dc9540?, 0xc000c11880}, 0xc002670100, {0xc001e9c200, 0x1, 0x1})
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:81 +0x115
INFO[0015] github.com/szkiba/muxpress.(*router).handleMethod.func1({0x1dc9540?, 0xc000c11880?}, 0x2d65aa0?)
INFO[0015]      github.com/szkiba/muxpress@v0.1.0/router.go:92 +0x46
INFO[0015] net/http.HandlerFunc.ServeHTTP(0xc00182bcc0?, {0x1dc9540?, 0xc000c11880?}, 0x191f6c0?)
INFO[0015]      net/http/server.go:2122 +0x2f
INFO[0015] github.com/julienschmidt/httprouter.(*Router).Handler.func1({0x1dc9540?, 0xc000c11880?}, 0xc002129230?, {0x0?, 0x0?, 0x0?})
INFO[0015]      github.com/julienschmidt/httprouter@v1.3.0/router.go:275 +0x196
INFO[0015] github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc0007c5aa0, {0x1dc9540, 0xc000c11880}, 0xc002670100)
INFO[0015]      github.com/julienschmidt/httprouter@v1.3.0/router.go:387 +0x81c
INFO[0015] net/http.serverHandler.ServeHTTP({0xc002122210?}, {0x1dc9540, 0xc000c11880}, 0xc002670100)
INFO[0015]      net/http/server.go:2936 +0x316
INFO[0015] net/http.(*conn).serve(0xc002367200, {0x1dca298, 0xc0027fe0f0})
INFO[0015]      net/http/server.go:1995 +0x612
INFO[0015] created by net/http.(*Server).Serve
INFO[0015]      net/http/server.go:3089 +0x5ed

Is this is a feature that would be possible to implement ? This could be a nice way to manage such asynchronous flows.

Regards,
Arnaud

@duarnad
Copy link
Author

duarnad commented Jan 30, 2024

Hello, in fact we understood the problem. As we were requesting the mock from outside, we needed a port. However, we put our code to get the port in the setup method, as we thought that there was a kind of global server. So it happens that there in fact a "mock server" per VU, with its own port, but also a global instance with its own port. When we use one of the ports assigned to a vu, it works well. The "global" one is the one giving the error in my previous comment, maybe in did because there is no VU context.

Regards,
Arnaud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant