Skip to content

Commit

Permalink
Merge branch 'main' into prevent-unused-var
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavid authored Jan 31, 2024
2 parents 4a72152 + 2ccc336 commit 75e3957
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 23 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/pre-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/qe-hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qe-ocp-413-intrusive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qe-ocp-413.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qe-ocp-414-intrusive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qe-ocp-414.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 10 additions & 3 deletions cnf-certification-test/platform/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 9 additions & 0 deletions pkg/provider/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
64 changes: 64 additions & 0 deletions pkg/provider/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

0 comments on commit 75e3957

Please sign in to comment.