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

xk6it integration test runner for extensions #74

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

szkiba
Copy link
Contributor

@szkiba szkiba commented Nov 21, 2023

This pr adds xk6it.Run function for extension integration testing support.

xk6it.Run builds k6 in temporary location and run scripts matching the given pattern.
For the given integration script, it searches for the containing go module
and based on that, builds k6 binary for execution.
For a given go module, the k6 build is done only once.
The k6 binary is placed in a temporary directory belonging to the call,
which is automatically deleted by the go test runner at the end of the run.
In practice, the execution corresponds to the xk6 run script.js command,
but the xk6 binary is not necessary, because it uses xk6 as a library.
In case of any error, t.Error() is called.

@szkiba szkiba requested review from a team, oleiade, joanlopez and olegbespalov and removed request for a team November 21, 2023 16:46
Copy link

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, what's the rationale behind vendoring deps? Is that really needed?

// In practice, the execution corresponds to the "xk6 run script.js" command,
// but the xk6 binary is not necessary, because it uses xk6 as a library.
// In case of any error, t.Error() is called.
func Run(t *testing.T, pattern string) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see an example of how Run can/should be used.

Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few clarification questions I would also like to see an example of how this can be used.

In general, I'm not entirely sure I understand what this change brings to xk6 at the moment, and what it makes possible, and I think an example would be valuable 😸 🙇🏻

xk6it/xk6it.go Outdated Show resolved Hide resolved
)

// Run builds k6 in temporary location and run scripts matching the given pattern.
// For the given integration script, it searches for the containing go module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "integration script" referring to here ❓

Also, just for my understanding is that this function is a way to programmatically xk6 run a xk6 extension, based on the assumption it's structured in a way that it has a dedicated go module (the actual structure is not important, but I just want to double check my understanding 👍🏻):

my_extension/
register.go
go.mod
my_module/
  module.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right

Co-authored-by: Théo Crevon <oleiade@users.noreply.github.com>
@szkiba
Copy link
Contributor Author

szkiba commented Dec 12, 2023

Here is an example of usage: https://github.com/szkiba/tygor/blob/master/examples/examples_test.go#L25

It is possible that this feature is not yet mature enough, so I may close the PR and reopen it later.

@pablochacin
Copy link
Collaborator

@szkiba considering the ongoing reorganization of the xk6, k6x, k6tb, and supporting libraries, I think this PR should go elsewhere. Maybe k6tb?

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

Successfully merging this pull request may close these issues.

4 participants