Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Conversation

henninggross
Copy link
Member

This PR introduces running the Tekton tasks tests in parallel.
Due to the fact that the test outputs of the different test cases are interleaved we came up with a solution to log the outputs of each test case to their respective log file inside test/testdata/test-results.
This directory will be uploaded as an artifact after the test steps for the developer to be able to check the logs conveniently.

Ref #401
Closes #14

Tasks:

  • Updated design documents in docs/design directory or not applicable
  • Updated user-facing documentation in docs directory or not applicable
  • Ran tests (e.g. make test) or not applicable
  • Updated changelog or not applicable

@henninggross
Copy link
Member Author

Now that the tests have successfully run through we calculated that the test duration was cut down to 19m54s from 23m38s (only comparing one test run with another, though).

Copy link
Member

@henrjk henrjk left a comment

Choose a reason for hiding this comment

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

Looks awesome to me. I am curious what you say to my previous comments.

Could this change be in the way to introduce caching (see proposal PR #412 ) as there might be concurrent access to the cache which could potentially cause flaky tests.

return fmt.Errorf("failed to create directory: %w", err)
}

f, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
Copy link
Member

Choose a reason for hiding this comment

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

I am curious did you need this file flags and permissions? Have you different flags/permissions first - perhaps os.Create() and it did not work?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch, we'll check os.Create() instead, looks like this is a convenience wrapper around os.OpenFile()

fileHandles[event.Test] = f
case "pause", "cont", "skip": // do nothing
case "pass", "fail":
f, ok := fileHandles[event.Test]
Copy link
Member

Choose a reason for hiding this comment

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

Should there be some error reporting if it is not ok?

case "pass", "fail":
f, ok := fileHandles[event.Test]
if ok {
err := f.Close()
Copy link
Member

Choose a reason for hiding this comment

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

I assume test pass and fail is typically captured in prior output. Perhaps its worthwhile to nonetheless write this explicitly in the log.

Copy link
Collaborator

@kuebler kuebler Feb 7, 2022

Choose a reason for hiding this comment

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

@henrjk you're spot-on, go test actually does write a pass/fail marker with an "bench"/"output" event.Action.

Copy link
Member Author

@henninggross henninggross Feb 7, 2022

Choose a reason for hiding this comment

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

The object for events of type pass and fail do not have any output. The output is captured in the prior object with event type output like this:

--- PASS: TestTaskODSBuildGradle/ods-build-gradle/task_should_build_gradle_app (70.27s)

So the only additional log that we could provide reacting on pass and fail would be a duplicate of this one and that's why @kuebler and I decided to do nothing but closing the file on those.

return fmt.Errorf("failed to open output file: %w", err)
}
fileHandles[event.Test] = f
case "pause", "cont", "skip": // do nothing
Copy link
Member

Choose a reason for hiding this comment

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

Is skip of interest in the log?

Copy link
Member Author

Choose a reason for hiding this comment

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

Similarly to #432 (comment) the output for a skipped test would be captured in the prior output so it would only lead to us printing information twice if we react on skip, pause or cont.

@michaelsauter
Copy link
Member

michaelsauter commented Feb 4, 2022

Really, really great work!

I have not looked into the details, but I have two more general questions:

  1. Would you think it makes sense to provide a parallel and a non-parallel execution of the tests?
  2. The test time savings are not bad, but I hoped for more tbh. I realise this is likely because the test files still run sequentially, only the test cases within one test func run in parallel. Have you thought about structuring this differently so that you can basically pick and choose how many tests of the overall set of tests you can run in parallel? Not sure how many in parallel GitHub Actions would support but maybe we are not pushing the limits here yet ;)

@kuebler
Copy link
Collaborator

kuebler commented Feb 4, 2022

  1. Would you think it makes sense to provide a parallel and a non-parallel execution of the tests?

Good idea, probably the tests read an ENV variable and based on that decide whether to execute the tests in parallel or not.

  1. The test time savings are not bad, but I hoped for more tbh. I realise this is likely because the test files still run sequentially, only the test cases within one test func run in parallel. Have you thought about structuring this differently so that you can basically pick and choose how many tests of the overall set of tests you can run in parallel? Not sure how many in parallel GitHub Actions would support but maybe we are not pushing the limits here yet ;)

Good catch, let's try and put t.Parallel() in the test functions as well and see if that improves the execution time. In addition, we could also take a look whether we can squeeze out a bit of time out of the ODS image builds. E.g. the helm image installs sops and age using go install, however, both also publish binary releases on Github which we could just download and copy like we do for helm itself.

@michaelsauter
Copy link
Member

E.g. the helm image installs sops and age using go install, however, both also publish binary releases on Github which we could just download and copy like we do for helm itself.

Careful, this is on purpose: #364 (though we can also change the approach if we find a good alternative). Different topic than parallel testing anyway ;)

@kuebler
Copy link
Collaborator

kuebler commented Feb 4, 2022

Careful, this is on purpose: #364 (though we can also change the approach if we find a good alternative). Different topic than parallel testing anyway ;)

age, however, in contrast to sops does release arm64 builds as well; we could at least download the binaries for age? But you're right: This is more about #401 than #14 😄

- previously, only table tests were run in parallel
- in addition, check whether running the parent tasks themselves in parallel further improves overall test execution time
- looks like it doesn't have possitive effect on test execution time
- makes tests flaky as they're now running into all kinds of timeouts due to concurrent execution
@michaelsauter
Copy link
Member

Closing as a consequence of #722. The tests are way faster now because there is less to test in this repo, hence the need for parallel tests is less.

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

Successfully merging this pull request may close these issues.

Run Tekton tests in parallel
4 participants