X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fhs-test%2Fcontainer.go;h=812198d62db834bd3070c66d18f225d738e5d6ef;hb=9caef2a35;hp=fd3aa47b21bf75f51a1c7c3e73f80bc10618b979;hpb=608d0069d98579b0635be978dea8e316f77a8841;p=vpp.git diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go index fd3aa47b21b..812198d62db 100644 --- a/extras/hs-test/container.go +++ b/extras/hs-test/container.go @@ -6,6 +6,7 @@ import ( "os/exec" "strings" "text/template" + "time" "github.com/edwarnicke/exechelper" ) @@ -129,11 +130,26 @@ func (c *Container) getContainerArguments() string { args := "--ulimit nofile=90000:90000 --cap-add=all --privileged --network host --rm" args += c.getVolumesAsCliOption() args += c.getEnvVarsAsCliOption() + if *vppSourceFileDir != "" { + args += fmt.Sprintf(" -v %s:%s", *vppSourceFileDir, *vppSourceFileDir) + } args += " --name " + c.name + " " + c.image args += " " + c.extraRunningArgs return args } +func (c *Container) runWithRetry(cmd string) error { + nTries := 5 + for i := 0; i < nTries; i++ { + err := exechelper.Run(cmd) + if err == nil { + return nil + } + time.Sleep(1 * time.Second) + } + return fmt.Errorf("failed to run container command") +} + func (c *Container) create() error { cmd := "docker create " + c.getContainerArguments() c.suite.log(cmd) @@ -143,7 +159,7 @@ func (c *Container) create() error { func (c *Container) start() error { cmd := "docker start " + c.name c.suite.log(cmd) - return exechelper.Run(cmd) + return c.runWithRetry(cmd) } func (c *Container) prepareCommand() (string, error) { @@ -176,8 +192,7 @@ func (c *Container) run() error { if err != nil { return err } - - return exechelper.Run(cmd) + return c.runWithRetry(cmd) } func (c *Container) addVolume(hostDir string, containerDir string, isDefaultWorkDir bool) {