summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/container.go
diff options
context:
space:
mode:
authorMaros Ondrejicka <maros.ondrejicka@pantheon.tech>2023-02-02 08:58:04 +0100
committerFlorin Coras <florin.coras@gmail.com>2023-02-10 05:23:19 +0000
commit2908f8cf07c21f385f80d83fdad826a0eea98977 (patch)
tree6391c5b989f2a7800958489feb1d7f460a87e850 /extras/hs-test/container.go
parent0a192ea93df9d1cd4d7777bcc5418a2f9e861a6c (diff)
hs-test: refactor test cases from ns suite
This converts more tests to configure VPP from test context. Type: test Signed-off-by: Maros Ondrejicka <maros.ondrejicka@pantheon.tech> Change-Id: Idf26b0c16f87e87c97b198412af39b99d947ced6
Diffstat (limited to 'extras/hs-test/container.go')
-rw-r--r--extras/hs-test/container.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go
index 91ca2c2b0b1..cc2d441f7ec 100644
--- a/extras/hs-test/container.go
+++ b/extras/hs-test/container.go
@@ -84,6 +84,10 @@ func NewContainer(yamlInput ContainerConfig) (*Container, error) {
return container, nil
}
+func (c *Container) Suite() *HstSuite {
+ return c.suite
+}
+
func (c *Container) getWorkDirVolume() (res Volume, exists bool) {
for _, v := range c.volumes {
if v.isDefaultWorkDir {
@@ -227,14 +231,22 @@ func (c *Container) createFile(destFileName string, content string) error {
* Executes in detached mode so that the started application can continue to run
* without blocking execution of test
*/
-func (c *Container) execServer(command string) error {
- return exechelper.Run("docker exec -d" + c.getEnvVarsAsCliOption() + " " + c.name + " " + command)
+func (c *Container) execServer(command string, arguments ...any) {
+ serverCommand := fmt.Sprintf(command, arguments...)
+ containerExecCommand := "docker exec -d" + c.getEnvVarsAsCliOption() +
+ " " + c.name + " " + serverCommand
+ c.Suite().log(containerExecCommand)
+ c.Suite().assertNil(exechelper.Run(containerExecCommand))
}
-func (c *Container) exec(command string) (string, error) {
- cliCommand := "docker exec" + c.getEnvVarsAsCliOption() + " " + c.name + " " + command
- byteOutput, err := exechelper.CombinedOutput(cliCommand)
- return string(byteOutput), err
+func (c *Container) exec(command string, arguments ...any) string {
+ cliCommand := fmt.Sprintf(command, arguments...)
+ containerExecCommand := "docker exec" + c.getEnvVarsAsCliOption() +
+ " " + c.name + " " + cliCommand
+ c.Suite().log(containerExecCommand)
+ byteOutput, err := exechelper.CombinedOutput(containerExecCommand)
+ c.Suite().assertNil(err)
+ return string(byteOutput)
}
func (c *Container) execAction(args string) (string, error) {