diff --git a/.github/workflows/pre-main.yaml b/.github/workflows/pre-main.yaml index 3857ab233..7f672d5ae 100644 --- a/.github/workflows/pre-main.yaml +++ b/.github/workflows/pre-main.yaml @@ -226,21 +226,21 @@ jobs: path: cnf-certification-test-partner - name: Bootstrap cluster, docker, and python - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 command: cd ${GITHUB_WORKSPACE}/cnf-certification-test-partner && make bootstrap-cluster && make bootstrap-docker-ubuntu-local && make bootstrap-python-ubuntu-local && pip3 install pyyaml - name: Run 'make rebuild-cluster' - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 command: cd ${GITHUB_WORKSPACE}/cnf-certification-test-partner && make rebuild-cluster - name: Run 'make install' - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -321,21 +321,21 @@ jobs: path: cnf-certification-test-partner - name: Bootstrap cluster, docker, and python - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 command: cd ${GITHUB_WORKSPACE}/cnf-certification-test-partner && make bootstrap-cluster && make bootstrap-docker-ubuntu-local && make bootstrap-python-ubuntu-local && pip3 install pyyaml - name: Run 'make rebuild-cluster' - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 command: cd ${GITHUB_WORKSPACE}/cnf-certification-test-partner && make rebuild-cluster - name: Run 'make install' - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -359,7 +359,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Build the `cnf-certification-test` image - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 diff --git a/.github/workflows/qe-hosted.yml b/.github/workflows/qe-hosted.yml index 2f8020ada..eb845dcb9 100644 --- a/.github/workflows/qe-hosted.yml +++ b/.github/workflows/qe-hosted.yml @@ -44,7 +44,7 @@ jobs: sudo pip3 install j2cli - name: Build the test image - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -58,21 +58,21 @@ jobs: path: cnf-certification-test-partner - name: Bootstrap cluster, docker, and python - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 command: cd ${GITHUB_WORKSPACE}/cnf-certification-test-partner; make bootstrap-cluster; make make bootstrap-docker-ubuntu-local; make bootstrap-python-ubuntu-local; pip3 install pyyaml - name: Run 'make rebuild-cluster' - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 command: cd ${GITHUB_WORKSPACE}/cnf-certification-test-partner; make rebuild-cluster - name: Install partner resources - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -101,7 +101,7 @@ jobs: run: make build-image-local # quay.io/testnetworkfunction/cnf-certification-test:localtest - name: Run the tests - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 60 max_attempts: 3 diff --git a/.github/workflows/qe-ocp-413-intrusive.yaml b/.github/workflows/qe-ocp-413-intrusive.yaml index 1ef52b05f..f8967f6a2 100644 --- a/.github/workflows/qe-ocp-413-intrusive.yaml +++ b/.github/workflows/qe-ocp-413-intrusive.yaml @@ -41,7 +41,7 @@ jobs: run: docker system prune -f --volumes - name: Build the test image - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -67,7 +67,7 @@ jobs: sudo rm -rf ${{env.TNF_REPORT_DIR}} - name: Run the tests - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 60 max_attempts: 3 diff --git a/.github/workflows/qe-ocp-413.yaml b/.github/workflows/qe-ocp-413.yaml index e1aa4f8a0..17bdadda6 100644 --- a/.github/workflows/qe-ocp-413.yaml +++ b/.github/workflows/qe-ocp-413.yaml @@ -40,7 +40,7 @@ jobs: run: docker system prune -f --volumes - name: Build the test image - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -66,7 +66,7 @@ jobs: sudo rm -rf ${{env.TNF_REPORT_DIR}} - name: Run the tests - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 60 max_attempts: 3 diff --git a/.github/workflows/qe-ocp-414-intrusive.yaml b/.github/workflows/qe-ocp-414-intrusive.yaml index eb1d8f40e..dff2d1e6c 100644 --- a/.github/workflows/qe-ocp-414-intrusive.yaml +++ b/.github/workflows/qe-ocp-414-intrusive.yaml @@ -41,7 +41,7 @@ jobs: run: docker system prune -f --volumes - name: Build the test image - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -67,7 +67,7 @@ jobs: sudo rm -rf ${{env.TNF_REPORT_DIR}} - name: Run the tests - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 60 max_attempts: 3 diff --git a/.github/workflows/qe-ocp-414.yaml b/.github/workflows/qe-ocp-414.yaml index 6c3ae0909..3b38b152b 100644 --- a/.github/workflows/qe-ocp-414.yaml +++ b/.github/workflows/qe-ocp-414.yaml @@ -40,7 +40,7 @@ jobs: run: docker system prune -f --volumes - name: Build the test image - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 90 max_attempts: 3 @@ -66,7 +66,7 @@ jobs: sudo rm -rf ${{env.TNF_REPORT_DIR}} - name: Run the tests - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 60 max_attempts: 3 diff --git a/cnf-certification-test/platform/suite.go b/cnf-certification-test/platform/suite.go index 82f77efea..970e42b21 100644 --- a/cnf-certification-test/platform/suite.go +++ b/cnf-certification-test/platform/suite.go @@ -270,11 +270,18 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { } // Loop through the debug pods that are tied to each node. - for _, dp := range env.DebugPods { - nodeName := dp.Spec.NodeName - + for _, n := range env.Nodes { + nodeName := n.Data.Name check.LogInfo("Testing node %q", nodeName) + // Ensure we are only testing nodes that have CNF workload deployed on them. + if !n.HasWorkloadDeployed(env.Pods) { + check.LogInfo("Node %q has no workload deployed on it. Skipping tainted kernel check.", nodeName) + continue + } + + dp := env.DebugPods[nodeName] + ocpContext := clientsholder.NewContext(dp.Namespace, dp.Name, dp.Spec.Containers[0].Name) tf := nodetainted.NewNodeTaintedTester(&ocpContext, nodeName) diff --git a/pkg/provider/nodes.go b/pkg/provider/nodes.go index c47cd9d29..ea084c765 100644 --- a/pkg/provider/nodes.go +++ b/pkg/provider/nodes.go @@ -147,3 +147,12 @@ func (node *Node) IsHyperThreadNode(env *TestEnvironment) (bool, error) { } return num > 1, nil } + +func (node *Node) HasWorkloadDeployed(podsUnderTest []*Pod) bool { + for _, pod := range podsUnderTest { + if pod.Spec.NodeName == node.Data.Name { + return true + } + } + return false +} diff --git a/pkg/provider/nodes_test.go b/pkg/provider/nodes_test.go index f1c53fc3c..f872860de 100644 --- a/pkg/provider/nodes_test.go +++ b/pkg/provider/nodes_test.go @@ -15,3 +15,67 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. package provider + +import ( + "testing" + + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestHasWorkloadDeployed(t *testing.T) { + generateNode := func(nodeName string) *Node { + return &Node{ + Data: &corev1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: nodeName, + }, + }, + } + } + + testCases := []struct { + testNodeName string + testPods []*Pod + expected bool + }{ + { + testNodeName: "node1", + testPods: []*Pod{ + { + Pod: &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "pod1", + }, + Spec: corev1.PodSpec{ + NodeName: "node1", + }, + }, + }, + }, + expected: true, + }, + { + testNodeName: "node1", + testPods: []*Pod{ + { + Pod: &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "pod1", + }, + Spec: corev1.PodSpec{ + NodeName: "node2", + }, + }, + }, + }, + expected: false, + }, + } + + for _, testCase := range testCases { + n := generateNode(testCase.testNodeName) + assert.Equal(t, testCase.expected, n.HasWorkloadDeployed(testCase.testPods)) + } +}