vpp/extras/hs-test/container.go
Maros Ondrejicka 11a03e972e hs-test: add test suite features
Test suite now supports assertions which on fail stop test case run,
also it allows to create docker containers which are going to be
stopped automatically after the test run is finished.

Type: improvement
Signed-off-by: Maros Ondrejicka <maros.ondrejicka@pantheon.tech>
Change-Id: I2834709b1efd17b8182d36cc0404b986b4ed595d
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2022-12-02 21:35:10 +00:00

32 lines
629 B
Go

package main
import (
"fmt"
"github.com/edwarnicke/exechelper"
)
type Container struct {
name string
}
func (c *Container) run() error {
if c.name == "" {
return fmt.Errorf("create volume failed: container name is blank")
}
exechelper.Run(fmt.Sprintf("mkdir -p /tmp/%s/sync", c.name))
syncPath := fmt.Sprintf("-v /tmp/%s/sync:/tmp/sync", c.name)
cmd := "docker run --cap-add=all -d --privileged --network host --rm "
cmd += syncPath
cmd += " --name " + c.name + " hs-test/vpp"
fmt.Println(cmd)
err := exechelper.Run(cmd)
if err != nil {
return fmt.Errorf("create volume failed: %s", err)
}
return nil
}