From 2908f8cf07c21f385f80d83fdad826a0eea98977 Mon Sep 17 00:00:00 2001 From: Maros Ondrejicka Date: Thu, 2 Feb 2023 08:58:04 +0100 Subject: 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 Change-Id: Idf26b0c16f87e87c97b198412af39b99d947ced6 --- extras/hs-test/container.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'extras/hs-test/container.go') 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) { -- cgit 1.2.3-korg