aboutsummaryrefslogtreecommitdiffstats
path: root/extras/hs-test/container.go
diff options
context:
space:
mode:
Diffstat (limited to 'extras/hs-test/container.go')
-rw-r--r--extras/hs-test/container.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go
index c82f1fc03a7..44d84d5fe65 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) {
@@ -77,7 +78,7 @@ func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error
}
if _, ok := yamlInput["volumes"]; ok {
- workingVolumeDir := logDir + CurrentSpecReport().LeafNodeText + container.suite.pid + volumeDir
+ workingVolumeDir := logDir + CurrentSpecReport().LeafNodeText + volumeDir
workDirReplacer := strings.NewReplacer("$HST_DIR", workDir)
volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
for _, volu := range yamlInput["volumes"].([]interface{}) {
@@ -160,6 +161,12 @@ func (c *Container) create() error {
return exechelper.Run(cmd)
}
+func (c *Container) allocateCpus() {
+ c.suite.startedContainers = append(c.suite.startedContainers, c)
+ 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)
@@ -286,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)
}
@@ -340,7 +350,7 @@ func (c *Container) log(maxLines int) (string, error) {
}
func (c *Container) stop() error {
- if c.vppInstance != nil && c.vppInstance.apiChannel != nil {
+ if c.vppInstance != nil && c.vppInstance.apiStream != nil {
c.vppInstance.saveLogs()
c.vppInstance.disconnect()
}