K6 with Azure Node SDK's

Hello,

Trying to run K6 tests by importing Azure Node.js SDK modules for event grid. Used Webpack to transpile the libraries into a bundle and it first seems like it hung for a while and then fails with the following error.

ERRO[0326] SyntaxError: file:///Users/prananth/example-project/build/app.bundle.js: Invalid regular expression (re2): \n[ 
                          ]{1,182220} (error parsing regexp: invalid repeat count: `{1,182220}`) at <eval>:2:28542(114)

I suspect some issues in compiling with webpack
A github repo with the example code to reproduce this problem is here:

We want to be able to use Azure SDK’s with K6.

Thanks for reporting this! I couldn’t reproduce this problem locally, I cloned your repo and built the script, but there is no 182220 in my app.bundle.js :confused: From the error, it sounds like this specific issue might be some incompatibility between JS regular expressions and the Go runtime we use to execute the scripts. Can you also push your generated app.bundle.js in the repo, so we can diagnose it?

In general though, unfortunately, k6 is never going to be able to execute all npm modules, especially ones that make external network requests. This wasn’t very well documented in our docs, so I’ve added an issue to fix it. Though even if this module somehow worked, another issue with it is that the resulting minified app.bundle.js on my machine was over 2MB in size! This is going to slow k6 to a crawl, that’s why it “hung for a while” when it tried to parse it. k6 is a load testing tool, so overloading it is not a great idea if you want to get good results out of it.

As an alternative, I’d suggest using the Event Grid REST API directly. Skimming the docs, it seems simple enough and very straightforward: Azure Event Grid REST API | Microsoft Learn

1 Like

Thanks for your response. Can we use Go SDK? Or is there a way to execute a JS script from inside of K6? Yes HTTP is an alternative, but I think K6 can make a good case if it enables SDK.
Also I take your point on how the tests should be lighter and not be taking time to load SDK’s.

No, at least not yet. This might change with the upcoming addition of plugin support in k6 (Plugin support · Issue #1353 · grafana/k6 · GitHub / https://github.com/loadimpact/k6/pull/1396), but even then it probably won’t be as easy as making plain HTTP requests, which is what k6 was made for, after all :wink:

k6 executes JS scripts, it just doesn’t execute all node.js scripts, simply because it isn’t node.js and is not built on top of node.js :smile: