diff options
author | Adrian Villin <avillin@cisco.com> | 2024-05-27 09:52:59 -0400 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2024-05-30 15:58:18 +0000 |
commit | b9464cde7d3288f8feeeaf945ce933b276f07d82 (patch) | |
tree | 81bd58c1a5f3736ea6e5d2be1534c49004bc8d84 /extras/hs-test/container.go | |
parent | 2b671aa3e9b9b23afd46854a4bdd144ed783e99e (diff) |
hs-test: pin CPUs to containers
Type: test
Change-Id: I412be2dec7ff352740e50e838e0ac466bf0a6674
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/container.go')
-rw-r--r-- | extras/hs-test/container.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go index 0bdc3a24996..83693f47d78 100644 --- a/extras/hs-test/container.go +++ b/extras/hs-test/container.go @@ -37,6 +37,7 @@ type Container struct { volumes map[string]Volume envVars map[string]string vppInstance *VppInstance + allocatedCpus []int } func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error) { @@ -160,6 +161,12 @@ func (c *Container) create() error { return exechelper.Run(cmd) } +func (c *Container) allocateCpus() { + c.suite.containerCount += 1 + c.allocatedCpus = c.suite.AllocateCpus() + c.suite.log("Allocated CPUs " + fmt.Sprint(c.allocatedCpus) + " to container " + c.name) +} + func (c *Container) start() error { cmd := "docker start " + c.name c.suite.log(cmd) @@ -175,6 +182,9 @@ func (c *Container) prepareCommand() (string, error) { if c.runDetached { cmd += " -d" } + + c.allocateCpus() + cmd += fmt.Sprintf(" --cpuset-cpus=\"%d-%d\"", c.allocatedCpus[0], c.allocatedCpus[len(c.allocatedCpus)-1]) cmd += " " + c.getContainerArguments() c.suite.log(cmd) @@ -239,7 +249,6 @@ func (c *Container) newVppInstance(cpus []int, additionalConfigs ...Stanza) (*Vp vpp := new(VppInstance) vpp.container = c vpp.cpus = cpus - c.suite.vppContainerCount += 1 vpp.additionalConfig = append(vpp.additionalConfig, additionalConfigs...) c.vppInstance = vpp return vpp, nil @@ -287,7 +296,7 @@ func (c *Container) exec(command string, arguments ...any) string { GinkgoHelper() c.suite.log(containerExecCommand) byteOutput, err := exechelper.CombinedOutput(containerExecCommand) - c.suite.assertNil(err, err) + c.suite.assertNil(err, fmt.Sprint(err)) return string(byteOutput) } |