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

Lifecycle ts: fix to avoid some checks to be skipped. #1655

Conversation

greyerof
Copy link
Contributor

The WithSkipCheckFn works doing OR (default behaviour) or AND operations with all the skip functions that have been passed. It's not possible to mix them, so I had to create a helper function to check whether both the env.Deployments and env.StatefulSets slices are empty.

Examples:

check1.WithSkipCheckFn(skipFn1, skipFn2)

check1 will be skipped if any of those skip functions return true (OR op because check.SkipMode=SkipModeAny by default).

check2.WithSkipCheckFn(skipFn1, skipFn2).
       WithSkipModeAll()

check2 will be skipped if both skipFn1 and skipFn2 return true (AND op = check.SkipMode=SkipModeAll).

Also:

  • Some refactor was done in the lifecycle-pod-recreation check to create deployments and statefulsets compliant/nonCompliant objects lists.
  • Added skip functions for the lifecycle-storage-provisioner and set pod as compliant if it's not using any pvc/storageclass. This is a non-backward-compatible change as now the check will be skipped instead of passed in those cases.
  • Added passing checks from lifecycle and networking test suites to the gradetool's policy json.

ToDos:

  • refactor the testPodsRecreation() check function to avoid the cyclomatic complexity linting issue.
  • refactor the testStorageProvisioner() check function to add some short-circuits to avoid the for-if-for-if-for-if... pattern.

The WithSkipCheckFn works doing OR (default behaviour) or AND operations
with **all** the skip functions that have been passed. It's not possible to mix
them, so I had to create a helper function to check whether both the
env.Deployments and env.StatefulSets slices are empty.

Examples:
check1.WithSkipCheckFn(skipFn1, skipFn2)
check1 will be skipped if **any** of those skip functions return true (OR op
because check.SkipMode=SkipModeAny by default).

check2.WithSkipCheckFn(skipFn1, skipFn2).
       WithSkipModeAll()
check2 will be skipped if **both** skipFn1 and skipFn2 return true (AND op =
check.SkipMode=SkipModeAll).

Also:
- Some refactor was done in the lifecycle-pod-recreation check to
  create deployments and statefulsets compliant/nonCompliant objects
  lists.
- Added skip functions for the lifecycle-storage-provisioner and set pod
  as compliant if it's not using any pvc/storageclass.
- Added passing checks from lifecycle and networking test suites to the
  gradetool's policy json.

ToDos:
- refactor the testPodsRecreation() check function to avoid the
  cyclomatic complexity linting issue.
- refactor the testStorageProvisioner() check function to add some
  short-circuits to avoid the for-if-for-if-for-if... pattern.
@greyerof greyerof added non backward compatible PR makes any NBC change in some TC, including removal or test ID changes. ginkgoless labels Nov 22, 2023
@sebrandon1 sebrandon1 merged commit 6e1d41b into redhat-best-practices-for-k8s:ginkgo_removal Nov 27, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ginkgoless non backward compatible PR makes any NBC change in some TC, including removal or test ID changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants