Skip to content

Testing-rig fixes - #3384

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
apostasie:dev-testing-fix
Sep 1, 2024
Merged

AkihiroSuda merged 1 commit into
containerd:mainfrom
apostasie:dev-testing-fix

Conversation

@apostasie

@apostasie apostasie commented Aug 31, 2024 •

Copy link
Copy Markdown
Contributor

In preparation for #3379

Couple of things:

  1. by default, go test will parallelize sub-packages testing - once we move to ./cmd/nerdctl/... this will break on us. To prevent this, pass along -p 1 which will instruct go test to only test one sub-package at a time. Note that this is not the same as parallelized tests - tests calling t.Parallel will still be run in parallel with others (and this is controlled by -parallel)
  2. rootless tests did use a different stance altogether to test (first build a test binary, then call go tool). I do not know for sure why this was done (maybe @AkihiroSuda would know). My hunch is that this was motivated by the fact we ssh back into the container - which does lose both cwd and PATH. I did fix that in test-integration-rootless.sh instead, so that rootless can just use the familiar, normal go test routine

This is on-top of #3385 which should be merged first.

@apostasie
apostasie marked this pull request as ready for review August 31, 2024 01:56
@apostasie
apostasie marked this pull request as draft August 31, 2024 01:56
@apostasie apostasie changed the title Testing fixes Testing-rig fixes Aug 31, 2024
@apostasie apostasie changed the title Testing-rig fixes [WIP] Testing-rig fixes Aug 31, 2024
@apostasie apostasie mentioned this pull request Aug 31, 2024
func TestRunVolumeRelativePath(t *testing.T) {
t.Parallel()
base := testutil.NewBase(t)
base.Dir = t.TempDir()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tests should not create temporary resources outside of temp directories (this is failing locally for me)

@apostasie apostasie changed the title [WIP] Testing-rig fixes Testing-rig fixes Aug 31, 2024
@apostasie
apostasie marked this pull request as ready for review August 31, 2024 20:57
@apostasie

Copy link
Copy Markdown
Contributor Author

@AkihiroSuda this is ready.
PTAL at your convenience.

CI is (mostly) green (failure is the usual TestIPFSComposeUp/stargz).

Should be merged after #3385.

@apostasie
apostasie marked this pull request as draft September 1, 2024 05:15
@apostasie apostasie changed the title Testing-rig fixes [WIP] Testing-rig fixes Sep 1, 2024
@apostasie apostasie changed the title [WIP] Testing-rig fixes Testing-rig fixes Sep 1, 2024
@apostasie
apostasie marked this pull request as ready for review September 1, 2024 05:20
Comment thread docs/testing.md
```bash
# Test all with nerdctl (rootless mode, if running go as a non-root user)
go test ./cmd/nerdctl/...
go test -p 1 ./cmd/nerdctl/...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I think this is the reason why we have failed to split *_test.go.

In the document could you explain what is -p and how it differs from -parallel?
The explanation should be copied to GHA yamls too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also wonder if we can print a human-readable error when -p 1 is not specified.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also wonder how this affects the run-time of the CI

@apostasie apostasie Sep 1, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also wonder how this affects the run-time of the CI

Theoretically, this MAY impact our run-time.

Currently, we first run sequentially any test that is not parallel. Then we run all tests that can be parallelized together, with parallelization at GOMAXPROCS.

With the new model, the tests that can be parallelized are run together, but only inside the subpackage (and each subpackage is run sequentially).

But then, how many cores do we have on github actions? 4?

Back of the envelop:

  • 15 subpackages
  • about 1000 tests -> ~70 tests per package
  • 160 calls to t.Parallel (but then, for loops, so, let's say 300) -> ~20 tests marked parallel

If we do indead have a small number of cores (<=4), then it is likely close to zero impact...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also wonder if we can print a human-readable error when -p 1 is not specified.

Maybe?

We could have the test initialization method to check the status of an flock and bail-out with an error if it is in use?
A bit heavy-handed, but then, it might work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I think this is the reason why we have failed to split *_test.go.

In the document could you explain what is -p and how it differs from -parallel? The explanation should be copied to GHA yamls too.

Yes.
This is not fully trivial knowledge.

Done with latest push.

@AkihiroSuda
AkihiroSuda requested a review from Zheaoli September 1, 2024 05:40

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda
AkihiroSuda merged commit d340ab0 into containerd:main Sep 1, 2024
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Sep 1, 2024
@AkihiroSuda AkihiroSuda added the area/ci e.g., CI failure label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci e.g., CI failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants