e2e: topomgr: get and use topology hints from conf

TO properly implement some e2e tests, we need to know
some basic topology facts about the system running the tests.
The bare minimum we need to know is how many PCI SRIOV devices
are attached to which NUMA node.

This way we know which core we can reserve for kube services,
and which NUMA socket we can take to test full socket reservation.

To let the tests know the PCI device topology, we use annotations
in the SRIOV device plugin ConfigMap we need anyway.
The format is

```yaml
  metadata:
    annotations:
      pcidevice_node0: "2"
      pcidevice_node1: "0"
```

with one annotation per NUMA node in the system.

Signed-off-by: Francesco Romani <fromani@redhat.com>
This commit is contained in:
Francesco Romani
2020-02-04 17:20:22 +01:00
parent d9d652e867
commit 3b4122bd03
2 changed files with 71 additions and 22 deletions

View File

@@ -18,6 +18,7 @@ package e2enode
import (
"fmt"
"io/ioutil"
"sort"
"strconv"
"strings"
@@ -75,6 +76,18 @@ func (R *numaPodResources) String() string {
return b.String()
}
func getCPUsPerNUMANode(nodeNum int) ([]int, error) {
nodeCPUList, err := ioutil.ReadFile(fmt.Sprintf("/sys/devices/system/node/node%d/cpulist", nodeNum))
if err != nil {
return nil, err
}
cpus, err := cpuset.Parse(strings.TrimSpace(string(nodeCPUList)))
if err != nil {
return nil, err
}
return cpus.ToSlice(), nil
}
func getCPUToNUMANodeMapFromEnv(f *framework.Framework, pod *v1.Pod, environ map[string]string, numaNodes int) (map[int]int, error) {
var cpuIDs []int
cpuListAllowedEnvVar := "CPULIST_ALLOWED"