Repository: kubernetes-sigs/security-profiles-operator
Pull request #1161 (2022-09-12 09:58:47)

tests: Only check the worker nodes testCaseLongSeccompProfileName
<!--  Thanks for sending a pull request!  Here are some tips for you:

- If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
- Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. For reference on required PR/issue labels, read here:
https://git.k8s.io/community/contributors/devel/sig-release/release.md#issuepr-kind-label
- If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
- If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
-->

#### What type of PR is this?
/kind bug
/kind failing-test

<!--
Add one of the following kinds:
/kind cleanup
/kind documentation
/kind feature
/kind design

Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
The test testCaseLongSeccompProfileName was written with assumption that
the profile being tested is only deployed on worker nodes, probably
because the upstream test platforms only schedule spod there.

On clusters where spod is scheduled on all nodes (OCP), this assumption
breaks and the test would list node statuses of both controlplane and
worker nodes but compare that with the number of workers only.

Let's list nodestatuses on worker nodes only to work around that issue.


#### Which issue(s) this PR fixes:
N/A

<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.

Fixes #

or

None
-->

#### Does this PR have test?
implicit

<!--
If tests aren't applicable just write N/A.
-->

#### Special notes for your reviewer:
This was debugged as part of merging the latest upstream to OCP: https://github.com/openshift/security-profiles-operator/pull/3

#### Does this PR introduce a user-facing change?

<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note
NONE
```


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1161#" title="Author self-approved">jhrozek</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/main/OWNERS)~~ [jhrozek]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov-commenter: # [Codecov](https://codecov.io/gh/kubernetes-sigs/security-profiles-operator/pull/1161?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#1161](https://codecov.io/gh/kubernetes-sigs/security-profiles-operator/pull/1161?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (70d6b6b) into [main](https://codecov.io/gh/kubernetes-sigs/security-profiles-operator/commit/79ef484af4a9bbc63c7a7f51f2a28ef480d84258?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (79ef484) will **not change** coverage.
> The diff coverage is `n/a`.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #1161   +/-   ##
=======================================
  Coverage   48.65%   48.65%           
=======================================
  Files          43       43           
  Lines        4779     4779           
=======================================
  Hits         2325     2325           
  Misses       2358     2358           
  Partials       96       96           
```

</details>
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1161#pullrequestreview-1103825422" title="Approved">JAORMX</a>*, *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1161#" title="Author self-approved">jhrozek</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/main/OWNERS)~~ [JAORMX,jhrozek]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1161#pullrequestreview-1103825422" title="Approved">JAORMX</a>*, *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1161#" title="Author self-approved">jhrozek</a>*, *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1161#pullrequestreview-1103825764" title="Approved">saschagrunert</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/main/OWNERS)~~ [JAORMX,jhrozek,saschagrunert]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/hack/ci/install-cri-o.sh b/hack/ci/install-cri-o.sh
index b810f15c2..bd94591fa 100755
--- a/hack/ci/install-cri-o.sh
+++ b/hack/ci/install-cri-o.sh
@@ -15,7 +15,6 @@
 
 set -euo pipefail
 
-COMMIT_ID=315a0cb5b0abd15619384d7da7f3941714afcb8e
 TAG=v1.25.0
 
 export PATH=$PATH:/usr/local/go/bin
@@ -35,9 +34,8 @@ go install sigs.k8s.io/bom/cmd/bom@$BOM_VERSION
 cp "$GOBIN/bom" /usr/bin
 bom version
 
-# TODO: switch "$COMMIT_ID" back to "$TAG" when CRI-O v1.25.0 is released.
-curl -sSfL --retry 5 --retry-delay 3 "https://raw.githubusercontent.com/cri-o/cri-o/$COMMIT_ID/scripts/get" |
-    bash -s -- -t "$COMMIT_ID"
+curl -sSfL --retry 5 --retry-delay 3 "https://raw.githubusercontent.com/cri-o/cri-o/$TAG/scripts/get" |
+    bash -s -- -t "$TAG"
 
 . /etc/os-release
 


Test patch:
diff --git a/test/tc_long_profile_name_test.go b/test/tc_long_profile_name_test.go
index 7a20370aa..e1c3b1729 100644
--- a/test/tc_long_profile_name_test.go
+++ b/test/tc_long_profile_name_test.go
@@ -19,6 +19,7 @@ package e2e_test
 import (
 	"encoding/json"
 	"fmt"
+	"strings"
 	"time"
 
 	secprofnodestatusv1alpha1 "sigs.k8s.io/security-profiles-operator/api/secprofnodestatus/v1alpha1"
@@ -49,7 +50,9 @@ func (e *e2e) testCaseLongSeccompProfileName(nodes []string) {
 	e.logf("List all node statuses for policy by ID")
 	id := e.getSeccompPolicyID(policyName)
 	namespace := e.getCurrentContextNamespace(defaultNamespace)
-	selector := fmt.Sprintf("spo.x-k8s.io/profile-id=%s", id)
+	selector := fmt.Sprintf(
+		"spo.x-k8s.io/profile-id in (%s),spo.x-k8s.io/node-name in (%s)",
+		id, strings.Join(nodes, ","))
 
 	const maxTries = 10
 	for i := 0; i < maxTries; i++ {