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

[gator test] Support referential constraints #1574

Merged

Conversation

willbeason
Copy link
Member

@willbeason willbeason commented Sep 23, 2021

Support gator test for referential constraints.

To keep tests hermetic, we now instantiate a new OPA client for each test case. Otherwise, we risk crosstalk between tests if resetting Data in the OPA client fails.

Other minor changes:

  • Make tests run in parallel
  • Require Runner to be instantiated with builder method to ensure required dependencies are passed

@willbeason willbeason added the authorship-tooling Tools for authors of Gatekeeper Constraints, Templates, Mutators label Sep 23, 2021
@willbeason willbeason added this to the gk-test cli alpha milestone Sep 23, 2021
@willbeason willbeason self-assigned this Sep 23, 2021
@willbeason willbeason force-pushed the referential-constraints branch from 5b27600 to 98d1b6b Compare September 23, 2021 21:19
@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2021

Codecov Report

Merging #1574 (380ba92) into master (0b663ca) will increase coverage by 0.36%.
The diff coverage is 95.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1574      +/-   ##
==========================================
+ Coverage   53.67%   54.03%   +0.36%     
==========================================
  Files          93       93              
  Lines        7995     8080      +85     
==========================================
+ Hits         4291     4366      +75     
- Misses       3364     3371       +7     
- Partials      340      343       +3     
Flag Coverage Δ
unittests 54.03% <95.61%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/gktest/read_constraints.go 86.31% <94.59%> (+6.62%) ⬆️
pkg/gktest/runner.go 96.79% <96.10%> (-3.21%) ⬇️
pkg/watch/replay.go 78.97% <0.00%> (-2.28%) ⬇️
...onstrainttemplate/constrainttemplate_controller.go 55.13% <0.00%> (-0.96%) ⬇️
pkg/readiness/list.go 91.17% <0.00%> (+11.76%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b663ca...380ba92. Read the comment docs.

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM, 1 nit

@willbeason willbeason force-pushed the referential-constraints branch 2 times, most recently from 2eb0ea4 to 0d01cac Compare September 28, 2021 17:53
@julianKatz
Copy link
Contributor

Otherwise, we risk

Could you fill out the rest of the description?

@willbeason
Copy link
Member Author

Otherwise, we risk

Could you fill out the rest of the description?

Done.

@willbeason willbeason requested a review from sozercan September 28, 2021 20:11
@willbeason willbeason force-pushed the referential-constraints branch 2 times, most recently from 4519e76 to 380ba92 Compare September 29, 2021 15:56
Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

LGTM

Will Beason added 6 commits September 29, 2021 13:03
Signed-off-by: Will Beason <willbeason@google.com>
Signed-off-by: Will Beason <willbeason@google.com>
This reduces test runtime from 7s to ~0.8s on my machine.

Block usage of ToVersionless() behind mutex since it isn't yet
threadsafe.

Allow caller to pass scheme into test runner. This makes the test runner
more extensible and prevents tests which need to manipulate scheme from
having data races.

Signed-off-by: Will Beason <willbeason@google.com>
Signed-off-by: Will Beason <willbeason@google.com>
Make Test.Cases a slice of pointers to avoid copying.

Signed-off-by: Will Beason <willbeason@google.com>
Signed-off-by: Will Beason <willbeason@google.com>
@willbeason willbeason force-pushed the referential-constraints branch from 380ba92 to 9de100e Compare September 29, 2021 20:03
@willbeason willbeason merged commit 623a1be into open-policy-agent:master Sep 29, 2021
@willbeason willbeason deleted the referential-constraints branch September 29, 2021 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authorship-tooling Tools for authors of Gatekeeper Constraints, Templates, Mutators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants