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 helpers to read/write from/to config #396

Merged
merged 2 commits into from
Apr 24, 2023
Merged

test(e2e): add helpers to read/write from/to config #396

merged 2 commits into from
Apr 24, 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 to #370

Allows each test case to have its own ephemeral configuration file, with which it can conveniently interact by reading/writing arbitrary values before executing kraft commands.

The included tests should be self-explanatory.
(I wrote tests for the test framework, and am currently resisting the urge to post a "yo dawg" meme about it.)


Notes

  1. I originally wanted the Write() method to accept a YAML path and a Go value, but figured that avoiding conversions between the Go and YAML type systems was both:

    • simpler to implement, especially due to potentially nested YAML nodes
    • more appropriate for arbitrary manipulations of the YAML config, for example to set multiple values in a single write

    The downside is that test authors need to understand how to use yaml.Filters and how they are executed in a yaml.Pipe.

    As the number of CLI tests grows, we hopefully will see some patterns emerge and decide to revisit that approach.

  2. I usually advocate for writing unit tests using Go's bare testing package, and reserve ginkgo for the more complex behaviour-driven things that require setup and teardown.

    In this case though, I used ginkgo for the unit tests as well. The reason is that the helpers included in the test framework embed a few ginkgo functions, so it's easier to test them in the context of ginkgo runs.

@antoineco antoineco requested a review from nderjung April 21, 2023 17:11
@antoineco antoineco changed the title test(e2e): add helpers to read/write to/from config test(e2e): add helpers to read/write from/to config Apr 21, 2023
antoineco and others added 2 commits April 24, 2023 12:13
Signed-off-by: Antoine Cotten <[email protected]>
Co-Authored-by: Alexander Jung <[email protected]>
Allows each test case to have its own ephemeral configuration file, with
which it can conveniently interact by reading/writing arbitrary values
before executing kraft commands.

Signed-off-by: Antoine Cotten <[email protected]>
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! Thanks a lot!

Approved-by: Alexander Jung [email protected]

@nderjung nderjung merged commit 1ada311 into unikraft:staging Apr 24, 2023
@antoineco antoineco deleted the cli-e2e-cfg branch April 24, 2023 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

2 participants