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

feat(e2e): Add 'pkg source/unsource' tests #817

Merged

Conversation

craciunoiuc
Copy link
Member

@craciunoiuc craciunoiuc commented Sep 15, 2023

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

GitHub-Fixes: #735

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
@craciunoiuc craciunoiuc added kind/enhancement New feature or request kind/fix This PR fixes an issue or bug area/test Issue or PR is related to test(s) labels Sep 15, 2023
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/test-e2e-source-unsource branch 3 times, most recently from 4c41358 to 8289757 Compare September 15, 2023 11:23
test/e2e/cli/version_test.go Outdated Show resolved Hide resolved
// https://www.regular-expressions.info/nonprint.html
// https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
Expect(stdout.String()).To(MatchRegexp(`\x1b\[2K\[\+\] Updating\.\.\. \[\d+\.\d+s\]\r\n`), "Quoted output: %q", stdout)
Expect(stdout.String()).To(MatchRegexp(`^{"level":"info","msg":"Updating..."}\n$`))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could as well use Equal() here if we are gating the string between ^$.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nit rejected, it makes the test fail with a strange error (the strings are equal), probably whitespace related, but let's just leave it like this

Same for the others

@@ -67,7 +67,7 @@ var _ = Describe("kraft version", func() {

Expect(stderr.String()).To(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(
`^(level=error msg="unknown command "some-arg" for "kraft version"")|(unknown command "some-arg" for "kraft version")\n$`,
`^{"level":"error","msg":"unknown command \\"some-arg\\" for \\"kraft version\\""}\n$`,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could as well use Equal() here if we are gating the string between ^$.

Expect(stderr.String()).To(BeEmpty())

// Check warning message exists in stdout
Expect(stdout.String()).To(MatchRegexp(`^{"level":"warning","msg":"manifest already saved: https://manifests\.kraftkit\.sh/index\.yaml"}\n$`))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could as well use Equal() here if we are gating the string between ^$.

Expect(cfgMapUnikernelManifests[1]).To(Equal("https://example.com"))

// Check if stdout contains the warning message
Expect(stdout.String()).To(MatchRegexp(`^{"level":"warning","msg":"manifest already saved: https://example\.com"}\n$`))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could as well use Equal() here if we are gating the string between ^$.

Expect(cfgMapUnikernelManifests[0]).To(Equal("https://manifests.kraftkit.sh/index.yaml"))

// Check if stdout contains the warning
Expect(stdout.String()).To(MatchRegexp(`^{"level":"warning","msg":"manifest not found: https://example\.com"}\n$`))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could as well use Equal() here if we are gating the string between ^$.

Expect(cfgMapUnikernelManifests[1]).To(Equal("https://example3.com"))

// Check if stdout has a warning
Expect(stdout.String()).To(MatchRegexp(`^{"level":"warning","msg":"manifest not found: https://example2\.com"}\n$`))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could as well use Equal() here if we are gating the string between ^$.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
@antoineco antoineco merged commit 0cebf59 into unikraft:staging Sep 15, 2023
4 checks passed
@craciunoiuc craciunoiuc deleted the craciunoiuc/test-e2e-source-unsource branch October 17, 2023 10:03
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 kind/fix This PR fixes an issue or bug
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

Possible test flake in /test/e2e/cli/pkg_test.go
2 participants