Enable QIT to run performance tests with k6 locally.#315
Conversation
… as a temporary solution until actual tests are implemented.
|
Just to confirm this point @alopezari:
Does this mean we don't expect this to work in staging? |
Good question! It should work if you connect the QIT-CLI to staging and deploy this PR on staging. Haven't tested it though (I tend to work locally whenever possible, but that's a good call). |
|
Thanks for confirming! Wanted to check since I tried to run this on staging but the test got stuck in Doesn't look like it got picked up by an action workflow, so we might need to add that piece in (hadn't dug into the code changes yet). |
|
Yes! The CD PR includes the changes for communicating the local test run with the CD so, without it, we won't get any test updates in the CD. |
|
Hmm okay looks like it may not be quite working, since that PR is on staging and I pointed my CLI to it as well: |
|
Hmmm thanks for checking @zhongruige! I'll take a look after the call 👍 |
|
Hi @zhongruige! It worked on my local pointing to staging:
Out of curiosity, did you pull the latest change from 24a4007? |
|
Hm should have been the latest but I'll give it a go on it! |
|
Ah sorry @alopezari I realized what the issue was, I needed to build the binary to include these changes. Usually we'll build the binary as part of a PR introducing changes to the CLI, here's an example from a recent PR: https://github.com/woocommerce/qit-cli/pull/316/files I did get it to start, but then I hit this error: |
Oh TIL, thanks for letting me know!
Hmm interesting, it should run this file: Let me see if I can reproduce the error |
|
Hi @zhongruige! The issue was that the default test file wasn't bundled with the QIT binary and therefore QIT couldn't find that file when running directly the binary. I didn't spot this because I tend to run the QIT with I've updated the K6Runner class to generate the file dynamically (see 3580884). This is a temporary file until we create a proper test management system with proper tags, etc, similar to how custom tests work. This will be handled in QIT-707: Implement performance tests for WooCommerce Core. |
|
Nice, thanks @alopezari! Works great for me now:
HTML report looks good too:
I did notice these do store in my local home/woo-qit-cli directory, is that expected at this point? |
… tests implementation.
|
Good catch! I've updated it in 9255e2d. Now it will store the artifacts in the |
|
Also been getting some weird environment issues, it's possible mine was a bit messed up from the previous implementation but using QIT commands is giving me this all the time now: |
|
Ah yes! I also found this yesterday after switching to staging, but I thought it was a glitch on my end. I had to delete and clone again the project, couldn't find out why that happened 🤔 My guess is that it happened after switching from an environment where performance tests were defined (i.e. staging) to one where performance tests weren't available (staging after switching back to |
|
Hi @zhongruige!
I thought that was a glitch but it was actually caused by this PR. We've always had one environment type (e2e) and now we added a 2nd one (performance). Every time we run an activation or performance test, some data is persisted in the QIT cache ( I've fixed this in 434f472, in order to fallback to As a consequence, you might see these warnings when reproducing the issue to check that it was fixed: However, that's non-blocking, and I think it makes sense to show them in order to flag there is weird data in the cache. The reason why you will see it repeated multiple times it's because these are flagged by the environment_monitor and it's run multiple times during the execution. |
|
Ah yes! Bear in mind that if you try to replicate the issue to see if the fix works, it will likely fail unless you include the changes from 434f472 in the branch you switch to. |
MrJnrman
left a comment
There was a problem hiding this comment.
Great job here @alopezari! Tested and worked fine both locally and in staging. I see the point of this PR is to create the infra to be able to run locally, so I'll approve based on that notion instead of diving too deep into every bit of the code.
zhongruige
left a comment
There was a problem hiding this comment.
Went through this again and it's working great for me, excited to see this foundation work in place!


This PR introduces the initial performance testing infrastructure to QIT, enabling developers to run k6-based performance tests against WooCommerce extensions. The feature integrates with QIT's existing local testing infrastructure just like activation tests do. So far it runs a set of dummy tests and generate a simple HTML report over which we will iterate in upcoming tasks.
The implementation uses k6 running in Docker containers to perform HTTP-based performance tests against WordPress/WooCommerce sites with extensions installed. Tests can be configured with different load patterns, thresholds, and scenarios to validate extension performance under various conditions.
This implementation was built with QIT-CLI v1.0 in mind, making sure it is self contained for easier integration once we release v1.0. This is the main reason why you will see that this implementation uses the
QIT_ENVIRONMENT_TYPEenv variable for figuring out if we're running E2E or Performance environment, for example. This should make it easier to migrate the code to the new architecture once v1.0 is out.Changes added in this PR
Core Infrastructure
qit run:performancecommand to execute performance tests.PerformanceEnvironmentandPerformanceEnvInfoclasses with performance-specific optimizations.K6RunnerandK6DockerConfigfor k6 test execution and Docker container management.PerformanceTestManagerfor orchestrating test execution and result collection.Other non self-contained changes
bootstrap.phpto register the newRunPerformanceTestCommandwith the application.EnvConfigLoader.phpto detect performance environment type viaQIT_ENVIRONMENT_TYPEenvironment variable.EnvInfo.phpto support performance environment instantiation and domain configuration for performance tests.ThemeActivation.phpto handle both E2E and Performance environments with unified theme activation logic.LocalTestRunNotifier.phpto:k6/Dockerfilewith grafana/k6 base image and QIT helper integration for k6 test execution.E2EEnvInfo.phpto ensure compatibility with the expanded environment system.Testing instructions
qit switch local.qit run:performance automatewoo(you can use any plugin you'd like as long as it's available in your local environment).performanceand statussuccess.qit run:performance automatewoo.performanceand statusfailed.qit run:performance, etc).