summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/container.go
diff options
context:
space:
mode:
authorMaros Ondrejicka <mondreji@cisco.com>2023-02-27 13:22:45 +0100
committerFlorin Coras <florin.coras@gmail.com>2023-02-28 18:27:17 +0000
commitc2f76f4590f57729d1bcf03bd816c10991431b18 (patch)
tree9ab0273c87c3f5ba21cf0ee8277f60f73e95f762 /extras/hs-test/container.go
parentb0116a13dcc631d5128209dec867c3fb5209629d (diff)
hs-test: test vpp+nginx mirroring with tap ifaces
Type: test Signed-off-by: Maros Ondrejicka <mondreji@cisco.com> Change-Id: I05bbed8fd9d40929f040574044aed5292a475e91
Diffstat (limited to 'extras/hs-test/container.go')
-rw-r--r--extras/hs-test/container.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go
index c55fddead54..5def2789528 100644
--- a/extras/hs-test/container.go
+++ b/extras/hs-test/container.go
@@ -121,12 +121,22 @@ func (c *Container) GetContainerWorkDir() (res string) {
return
}
-func (c *Container) getRunCommand() string {
- cmd := "docker run --cap-add=all -d --privileged --network host --rm"
- cmd += c.getVolumesAsCliOption()
- cmd += c.getEnvVarsAsCliOption()
- cmd += " --name " + c.name + " " + c.image + " " + c.extraRunningArgs
- return cmd
+func (c *Container) getContainerArguments() string {
+ args := "--cap-add=all --privileged --network host --rm"
+ args += c.getVolumesAsCliOption()
+ args += c.getEnvVarsAsCliOption()
+ args += " --name " + c.name + " " + c.image
+ return args
+}
+
+func (c *Container) create() {
+ cmd := "docker create " + c.getContainerArguments()
+ exechelper.Run(cmd)
+}
+
+func (c *Container) start() {
+ cmd := "docker start " + c.name
+ exechelper.Run(cmd)
}
func (c *Container) run() error {
@@ -134,7 +144,8 @@ func (c *Container) run() error {
return fmt.Errorf("run container failed: name is blank")
}
- cmd := c.getRunCommand()
+ cmd := "docker run -d " + c.getContainerArguments() + " " + c.extraRunningArgs
+ c.Suite().log(cmd)
err := exechelper.Run(cmd)
if err != nil {
return fmt.Errorf("container run failed: %s", err)
@@ -273,6 +284,14 @@ func (c *Container) saveLogs() {
f.Close()
}
+func (c *Container) log() string {
+ cmd := "docker logs " + c.name
+ c.Suite().log(cmd)
+ o, err := exechelper.CombinedOutput(cmd)
+ c.Suite().assertNil(err)
+ return string(o)
+}
+
func (c *Container) stop() error {
if c.vppInstance != nil && c.vppInstance.apiChannel != nil {
c.vppInstance.saveLogs()