Skip to content

Commit

Permalink
e2e: topomgr: better check for AffinityError
Browse files Browse the repository at this point in the history
Add a helper function to check if a Pod failed
admission for Topology Affinity Error.
So far we only check the Status.Reason.

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Feb 10, 2020
1 parent 512a4e8 commit 83c3446
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/e2e_node/topology_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ import (
)

const (
numalignCmd = `export CPULIST_ALLOWED=$( awk -F":\t*" '/Cpus_allowed_list/ { print $2 }' /proc/self/status); env; sleep 1d`
topologyError = "Topology Affinity Error" // XXX do we have a proper constant?
numalignCmd = `export CPULIST_ALLOWED=$( awk -F":\t*" '/Cpus_allowed_list/ { print $2 }' /proc/self/status); env; sleep 1d`
)

// Helper for makeTopologyManagerPod().
Expand Down Expand Up @@ -570,13 +569,18 @@ func runTopologyManagerNegativeTest(f *framework.Framework, numaNodes, numPods i
if pod.Status.Phase != v1.PodFailed {
framework.Failf("pod %s not failed: %v", pod.Name, pod.Status)
}
if pod.Status.Reason != topologyError {
framework.Failf("pod %s failed for wrong reason: %v", pod.Name, pod.Status)
if !isTopologyAffinityError(pod) {
framework.Failf("pod %s failed for wrong reason: %q", pod.Name, pod.Status.Reason)
}

deletePods(f, []string{pod.Name})
}

func isTopologyAffinityError(pod *v1.Pod) bool {
re := regexp.MustCompile(`Topology.*Affinity.*Error`)
return re.MatchString(pod.Status.Reason)
}

func getSRIOVDevicePluginConfigMap(cmFile string) *v1.ConfigMap {
cmData := testfiles.ReadOrDie(SRIOVDevicePluginCMYAML)
var err error
Expand Down

0 comments on commit 83c3446

Please sign in to comment.