Skip to content

Add basic workflow for automatic subcommand testing on Windows.#1393

Closed
aznashwan wants to merge 3 commits intocontainerd:mainfrom
aznashwan:windows-acceptance-basic
Closed

Add basic workflow for automatic subcommand testing on Windows.#1393
aznashwan wants to merge 3 commits intocontainerd:mainfrom
aznashwan:windows-acceptance-basic

Conversation

@aznashwan
Copy link
Copy Markdown
Contributor

@aznashwan aznashwan commented Sep 26, 2022

This PR adapts some existing command tests to run on both Linux and Windows, as well as add a simple GitHub action to run the command tests on Windows 2019/2022 automatically.

@aznashwan
Copy link
Copy Markdown
Contributor Author

It might be worth discussing whether nerdctl push should also be included in this workflow (and if so, to which public/private registry implementation), but considering the efforts to port BuildKit on Windows are still ongoing it is unlikely to be critical for users at this stage...

The rest of the failing commands currently being tested have clear causes for the most part (image encrypt/decrypt have keyfile encoding issues, pause/unpause/cp are not yet implemented, and rename errors out), and will be addressed in dedicated PRs.

CONTAINERD_REF: 'main'
TEST_CONTAINER_IMAGE: 'k8s.gcr.io/e2e-test-images/busybox:1.29-2'

jobs:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be better to have a test arg like docker.

go test -exec sudo -v ./cmd/nerdctl/... -args -test.target=docker

and if a test is windows compatible it will run automatically

@AkihiroSuda
Copy link
Copy Markdown
Member

AkihiroSuda commented Sep 27, 2022

Why not use the same test suite as Linux?

- go test -v ./cmd/...

@AkihiroSuda AkihiroSuda added area/ci e.g., CI failure platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2) labels Sep 27, 2022
@aznashwan aznashwan force-pushed the windows-acceptance-basic branch from d35f7c2 to 3ce3ad7 Compare October 11, 2022 14:47
@@ -0,0 +1,101 @@
# This workflow runs the command test suite on GitHub-based Windows Server runners.
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.

Could you explain pros/cons compared to the current Cirrus CI ?

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.

The main pro would be the fact the containerd repo has a workflow using the same GitHub runner images to run the integration tests, so we could crossref any errors we're seeing to any bugs which may have gotten into containerd without having to worry about differences in the runner's OS/patch number as much.

I don't think there are any cons to having both running in parallel, so I could also update the Cirrus config to run the tests on 2022 as well if needed. (currently looks like Cirrus only has images based on 2019 OOB so we'd have to setup a custom 2022 image for it though)

@aznashwan
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @manugupt1 thanks a lot for the pointers!
I was initially apprehensive on adapting the existing tests since they seem to have been mostly written with Linux in mind but it makes more sense to unify the *nix/Windows testing as much and as soon as possible!

I've updated this PR in the following ways:

  • made the workflow setup containerd and just run go test ./cmd/... on the GitHub Windows runners (we'd like to have it tested on both 2019 and 2022 on semi-up-to-date Windows images and containerd release so IMO having a per-PR GitHub workflow is more useful than Cirrus here)
  • enabled the image encryption/conversion tests on Windows (the commands just worked OOB)
  • adapted some tests which used to require image building during the test to work around this on Windows until BuildKit is ported too (namely re-tagging or converting the testutil.CommonImage)

There's like a dozen existing tests which are skipped on Windows since they unequivocally require BuildKit as part of the test itself (mostly all of those prefixed with TestBuild*), so I have left those as-is for now.

There's a couple of tests which outright fail and I'll be looking into next:

  • TestRename yields an internal OS error
  • TestRenameUpdate fails to start the test container (almost surely related to TestRename)
  • TestEncryptJWE (tests nerdctl image encrypt --jwe=...) needs a registry running during the test but the current test registry image is Linux-only

Lastly, some points I'd like to bring to your attention now (with separate PRs to work through these later):

@aznashwan aznashwan force-pushed the windows-acceptance-basic branch from 3ce3ad7 to e97def0 Compare October 11, 2022 14:55

defaults:
run:
shell: bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be bash or PowerShell?

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.

Good catch, the initial version of the workflow contained way more steps and mostly used bash in them but none do any more so I'll be updating the workflow to have PS as the default.

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.

Updated the PR to use PowerShell as the default shell FWIW.

Comment thread cmd/nerdctl/build_test.go
assert.Equal(t, string(data), testContent)
}

func createBuildContext(dockerfile string) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why remove this?

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 had moved it to image_testing_utils.go since it is also called in a couple of non-build-related tests.

"github.com/containerd/nerdctl/pkg/testutil"
)

func TestRename(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious: Why not have common tests in rename_test.go and platform specific tests in rename__test.go using build tags?

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.

As far as I could tell all the existing tests were laid out using the filename suffixes for build constraints so I strived to keep it that way.

I also needed to paraemtrize the test image since testutils.CommonImage is only defined on Linux/Windows/FreeBSD and that would prevent the tests from compiling on any other future platform we'd like to support.

We could alternatively set a default testutils.CommonImage for all platforms and thus have the TestRename* tests be 100% shared across all platforms.
I'd personally rather we move the CommonImage constants from testutils to here since it's only ever referenced in the ./cmd/nerdctl/... tests anyway...

@aznashwan
Copy link
Copy Markdown
Contributor Author

Superseded by #2418.

@aznashwan aznashwan closed this Aug 6, 2023
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 platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants