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

[Enhancement]: Add example test to the K6 module docs #8780

Open
FieteO opened this issue Jun 17, 2024 · 0 comments
Open

[Enhancement]: Add example test to the K6 module docs #8780

FieteO opened this issue Jun 17, 2024 · 0 comments

Comments

@FieteO
Copy link

FieteO commented Jun 17, 2024

Module

K6

Proposal

I am currently trying to setup a k6 integration test and have a hard time figuring out, how tests are supposed to be written with the module.
When googling for solutions, I primarily found an example repository for go and the docs page.
I then looked at the code and found the test case that is provided for the feature:

public class K6ContainerTests {

    @Test
    public void k6StandardTest() throws Exception {
        try (
            // standard_k6 {
            K6Container container = new K6Container("grafana/k6:0.49.0")
                .withTestScript(MountableFile.forClasspathResource("scripts/test.js"))
                .withScriptVar("MY_SCRIPT_VAR", "are cool!")
                .withScriptVar("AN_UNUSED_VAR", "unused")
                .withCmdOptions("--quiet", "--no-usage-report")
            // }
        ) {
            container.start();

            WaitingConsumer consumer = new WaitingConsumer();
            container.followOutput(consumer);

            // Wait for test script results to be collected
            consumer.waitUntil(
                frame -> {
                    return frame.getUtf8String().contains("iteration_duration");
                },
                3,
                TimeUnit.SECONDS
            );

            assertThat(container.getLogs()).contains("k6 tests are cool!");
        }
    }
}

The docs page however, is not stating how a test case would look like and the provided test case does not look like the typical syntax I am used to from testcontainers. I would have expected something similar to the quick start examples to get started quickly.
Either way, I think it would be a good idea to provide an example test in the docs.

(@javaducky @eddumelendez I think you were involved in contributing the module)

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

No branches or pull requests

1 participant