diff options
author | Maros Ondrejicka <mondreji@cisco.com> | 2023-02-07 20:40:27 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-02-10 05:23:32 +0000 |
commit | 7550dd268f80334cbb9127feefe35319b9c7e572 (patch) | |
tree | 08350b3d4dcf5453941312565c63303d95735903 /extras/hs-test/container.go | |
parent | 2908f8cf07c21f385f80d83fdad826a0eea98977 (diff) |
hs-test: refactor test cases from no-topo suite
This converts remaining tests to configation of VPP from test context.
Type: test
Change-Id: I386714f6b290e03d1757c2a033a25fae0340f5d6
Signed-off-by: Maros Ondrejicka <mondreji@cisco.com>
Diffstat (limited to 'extras/hs-test/container.go')
-rw-r--r-- | extras/hs-test/container.go | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go index cc2d441f7ec..8ece8a8952b 100644 --- a/extras/hs-test/container.go +++ b/extras/hs-test/container.go @@ -9,6 +9,10 @@ import ( "github.com/edwarnicke/exechelper" ) +var ( + workDir, _ = os.Getwd() +) + type Volume struct { hostDir string containerDir string @@ -114,9 +118,7 @@ func (c *Container) GetContainerWorkDir() (res string) { } func (c *Container) getRunCommand() string { - syncPath := fmt.Sprintf(" -v %s:/tmp/sync", c.getSyncPath()) cmd := "docker run --cap-add=all -d --privileged --network host --rm" - cmd += syncPath cmd += c.getVolumesAsCliOption() cmd += c.getEnvVarsAsCliOption() cmd += " --name " + c.name + " " + c.image + " " + c.extraRunningArgs @@ -185,10 +187,6 @@ func (c *Container) getEnvVarsAsCliOption() string { return cliOption } -func (c *Container) getSyncPath() string { - return fmt.Sprintf("/tmp/%s/sync", c.name) -} - func (c *Container) newVppInstance(additionalConfig ...Stanza) (*VppInstance, error) { vppConfig := new(VppConfig) vppConfig.CliSocketFilePath = defaultCliSocketFilePath @@ -249,30 +247,6 @@ func (c *Container) exec(command string, arguments ...any) string { return string(byteOutput) } -func (c *Container) execAction(args string) (string, error) { - syncFile := c.getSyncPath() + "/rc" - os.Remove(syncFile) - - workDir := c.getWorkDirAsCliOption() - cmd := fmt.Sprintf("docker exec -d %s %s hs-test %s", - workDir, - c.name, - args) - err := exechelper.Run(cmd) - if err != nil { - return "", err - } - res, err := waitForSyncFile(syncFile) - if err != nil { - return "", fmt.Errorf("failed to read sync file while executing 'hs-test %s': %v", args, err) - } - o := res.StdOutput + res.ErrOutput - if res.Code != 0 { - return o, fmt.Errorf("cmd resulted in non-zero value %d: %s", res.Code, res.Desc) - } - return o, err -} - func (c *Container) stop() error { if c.vppInstance != nil && c.vppInstance.apiChannel != nil { c.vppInstance.disconnect() |