genpolicy: add crate-scoped integration test #309
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge Checklist
upstream/missing
label (orupstream/not-needed
) has been set on the PR.Summary
The goal of this PR is to add a testing framework for policy. Compared with current ways of testing policy changes, these tests run fast and are self-contained, so no cluster is needed to run the tests. We also expect to improve test coverage by being able to test very specific request inputs that should be allowed or denied by the policy.
Cherry pick from kata-containers#10068
These tests will:
Same as upstream PR, the initial set of test cases is mostly for illustration and will be expanded incrementally.
We are also modifying the genpolicy makefile such that
make test
runs these tests. And our CI is already wired to runmake test
for genpolicy. So these tests will run automatically on every PR and will be required to pass before merging. See test methodology below.It is worth noting currently these requests are not going through the agent. So, there's some requests we can't test currently such as CreateContainerRequest, which require state handling from the agent, or CopyFileRequest, which the agent transforms to a PolicyCopyFileRequest. I'll address that by down streaming kata-containers#10613 in a separate PR. This change will make the request go through the agent.
Test Methodology
required
make test
for genpolicy passing https://github.com/microsoft/kata-containers/actions/runs/13397404971/job/37419817822?pr=309#step:11:445