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

Adding test for network policy regex #517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Vincent056
Copy link

@Vincent056 Vincent056 commented May 10, 2024

Added e2e test for configure-network-policies-namespaces rule, test if whitelist-regex works as expected.

This works in-conjunction with ComplianceAsCode/content#11952

@openshift-ci openshift-ci bot requested review from jhrozek and mrogers950 May 10, 2024 00:22
Copy link

openshift-ci bot commented May 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Vincent056

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

tests/e2e/serial/main_test.go Show resolved Hide resolved
},
SetValues: []compv1alpha1.VariableValueSpec{
{
Name: "ocp4-var-network-policies-namespaces-whitelist-regex",
Copy link
Member

Choose a reason for hiding this comment

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

This test depends on certain variables and rules being available in the content.
Can we or should we add conditionals?
For example, only run this test if both the rule and the variable exist.

Copy link
Author

Choose a reason for hiding this comment

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

I think that's a good idea!

Copy link
Author

Choose a reason for hiding this comment

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

I was investigating on this, found out that tailoredprofile will error out if we can't find the variable

Copy link
Member

Choose a reason for hiding this comment

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

@Vincent056 Resulting in error is fine when creating a TP with a variable that doesn't exist.

But the point of this test is to ensure that the regex works, not that the rule and variable are present in the content, right?
So if for some reason the rule or variable are deprecated or missing, this test will error and block CI. And in this situation I think the test should just be skipped.

@Vincent056
Copy link
Author

/retest

Added e2e test for configure-network-policies-namespaces rule, test if whitelist-regex works as expected

err = f.AssertVariableExists(variableName, f.OperatorNamespace)
if err != nil {
t.Fatal(err)
Copy link
Member

@yuumasato yuumasato May 23, 2024

Choose a reason for hiding this comment

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

I think we should skip here

Suggested change
t.Fatal(err)
t.Skip("Content doesn't have variable '%s' required for testing", variableName)
return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants