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

test(e2e): add CLI test for pkg update #405

Merged
merged 1 commit into from
Apr 29, 2023
Merged

test(e2e): add CLI test for pkg update #405

merged 1 commit into from
Apr 29, 2023

Conversation

antoineco
Copy link
Contributor

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran make fmt on your commit series before opening this PR;
  • Updated relevant documentation.

Description of changes

Part of #370

Tests that, given an empty manifests directory, kraft pkg update retrieves the list of components, libraries and packages.
Also tests that the command can print its own help.

@antoineco antoineco requested a review from nderjung April 24, 2023 13:55
Copy link
Contributor Author

@antoineco antoineco left a comment

Choose a reason for hiding this comment

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

Holding until I add these unit tests.
Ready for review

test/e2e/framework/matchers/matchers.go Show resolved Hide resolved
@antoineco antoineco added kind/enhancement New feature or request area/test Issue or PR is related to test(s) labels Apr 26, 2023
Copy link
Member

@craciunoiuc craciunoiuc left a comment

Choose a reason for hiding this comment

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

All good here. Thanks!

Took a deep look and it seems fine + it seems that the test passed

Reviewed-by: Cezar Craciunoiu [email protected]

Comment on lines 59 to 60
Expect(manifestsPath).To(ContainFiles("index.yaml", "unikraft.yaml"))
Expect(manifestsPath).To(ContainDirectories("libs"))
Copy link
Member

@nderjung nderjung Apr 27, 2023

Choose a reason for hiding this comment

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

These checks are manifest-specific artifacts. Whilst the default functionality of kraftkit is to use manifest Package Manager, it can be configured to use a different ones which would result in alternative output artefacts from kraft pkg update. For example, after the introduction of OCI package manager, sourcing from unikraft.org does not actually produce any system artefacts.

Perhaps just for greater clarity of the test(s) itself the package manager should be indicated? The flag -m should then be used to specifically set the manifest manager and the test name also includes this.

I can then see additional tests that try out different providers, e.g., starting from a blank list of unikraft manifests:

# e2e test 1: GitHub provider
kraft pkg source https://github.com/unikraft/unikraft.git
kraft pkg update
# only a `unikraft.yaml` artefact

# e2e test 2: GitProvider
[...]

# e2e test N: ManifestIndexProvider
kraft pkg source https://manifests.kraftkit.sh/index.yaml
# `index.yaml` and any additional "symlinks"
[...]

The current functionality assumes (afaik) that the config will be populated with its default configuration and values, meaning that the manifest provider is an ManifestIndexProvider set to the default location.

Copy link
Contributor Author

@antoineco antoineco Apr 27, 2023

Choose a reason for hiding this comment

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

How about having both? Test with a default config, and test with selected manifests?

We want to catch any breaking user facing change, and a change of default is exactly that, that's why I prioritized the default case here.

I'll be busy with other topics for the next few weeks most likely, so we can either block this PR until all cases are added, or benefit from these initial tests and iterate on additional cases later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just nested the existing test cases inside a context block (see eedbbb1f..aa9bfc3b):

Context("implicitly using the default manager type (manifest)", { /* ... */ })

This should make it explicit that we are testing with plain defaults, and that future context blocks will contain manager-specific test cases, alongside the default case.

PTAL

Copy link
Member

@nderjung nderjung Apr 28, 2023

Choose a reason for hiding this comment

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

Your suggestion of updating the test context helps assure that this test is intended for "default" functionality and addresses my concern. Thanks a tonne!

I will open up a separate issue addressing the permutations that can be made by the --manager flag which is out-of-scope for this initial e2e of kraft pkg update.

@antoineco antoineco requested a review from nderjung April 27, 2023 17:15
// The help subsystem is managed by cobra and fails when top-level flags
// are passed, so we ensure to keep only the command name and subcommand
// from the original cmd.
cmd.Args = []string{cmd.Args[0], cmd.Args[len(cmd.Args)-2], cmd.Args[len(cmd.Args)-1], "--help"}
Copy link
Member

@nderjung nderjung Apr 28, 2023

Choose a reason for hiding this comment

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

Non-blocking but this seems quite convoluted approach of injecting the --help flag (though the comment preamble does help) and will not scale if the parent BeforeEach includes any additional positional arguments or flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fully agree, this is based on the assumption that we are using a subcommand that is n-deep exactly. Mostly a workaround, the fact that we even need to avoid passing any other flag is a bug. I'll open an issue.

Copy link
Contributor Author

@antoineco antoineco Apr 28, 2023

Choose a reason for hiding this comment

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

I removed that hack entirely from here and it works.
The --config-dir flag doesn't cause any issue with kraft pkg update --help, but it still does with kraft version --help 🤔

Created #430

Copy link
Member

@nderjung nderjung left a comment

Choose a reason for hiding this comment

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

Awesome! Looks good!

Reviewed-by: Alexander Jung [email protected]
Approved-by: Alexander Jung [email protected]

@nderjung nderjung merged commit 9f4ff05 into unikraft:staging Apr 29, 2023
@antoineco antoineco deleted the cli-e2e-pkg branch April 29, 2023 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test Issue or PR is related to test(s) kind/enhancement New feature or request
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

3 participants