"time"
"github.com/edwarnicke/exechelper"
+ . "github.com/onsi/ginkgo/v2"
)
const (
vppInstance *VppInstance
}
-func newContainer(suite *HstSuite, yamlInput ContainerConfig, pid string) (*Container, error) {
+func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error) {
containerName := yamlInput["name"].(string)
if len(containerName) == 0 {
err := fmt.Errorf("container name must not be blank")
var container = new(Container)
container.volumes = make(map[string]Volume)
container.envVars = make(map[string]string)
- container.name = containerName + pid
+ container.name = containerName
container.suite = suite
if image, ok := yamlInput["image"]; ok {
}
if _, ok := yamlInput["volumes"]; ok {
- workingVolumeDir := logDir + container.suite.T().Name() + pid + volumeDir
+ workingVolumeDir := logDir + CurrentSpecReport().LeafNodeText + container.suite.pid + volumeDir
workDirReplacer := strings.NewReplacer("$HST_DIR", workDir)
volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
for _, volu := range yamlInput["volumes"].([]interface{}) {
}
func (c *Container) createFile(destFileName string, content string) error {
- f, err := os.CreateTemp("/tmp", "hst-config" + c.suite.pid)
+ f, err := os.CreateTemp("/tmp", "hst-config"+c.suite.pid)
if err != nil {
return err
}
serverCommand := fmt.Sprintf(command, arguments...)
containerExecCommand := "docker exec -d" + c.getEnvVarsAsCliOption() +
" " + c.name + " " + serverCommand
- c.suite.T().Helper()
+ GinkgoHelper()
c.suite.log(containerExecCommand)
c.suite.assertNil(exechelper.Run(containerExecCommand))
}
cliCommand := fmt.Sprintf(command, arguments...)
containerExecCommand := "docker exec" + c.getEnvVarsAsCliOption() +
" " + c.name + " " + cliCommand
- c.suite.T().Helper()
+ GinkgoHelper()
c.suite.log(containerExecCommand)
byteOutput, err := exechelper.CombinedOutput(containerExecCommand)
c.suite.assertNil(err, err)
func (c *Container) getLogDirPath() string {
testId := c.suite.getTestId()
- testName := c.suite.T().Name()
+ testName := CurrentSpecReport().LeafNodeText
logDirPath := logDir + testName + "/" + testId + "/"
cmd := exec.Command("mkdir", "-p", logDirPath)
if err := cmd.Run(); err != nil {
- c.suite.T().Fatalf("mkdir error: %v", err)
+ Fail("mkdir error: " + fmt.Sprint(err))
}
return logDirPath
cmd = exec.Command("docker", "logs", "--details", "-t", c.name)
output, err := cmd.CombinedOutput()
if err != nil {
- c.suite.T().Fatalf("fetching logs error: %v", err)
+ Fail("fetching logs error: " + fmt.Sprint(err))
}
f, err := os.Create(testLogFilePath)
if err != nil {
- c.suite.T().Fatalf("file create error: %v", err)
+ Fail("file create error: " + fmt.Sprint(err))
}
fmt.Fprint(f, string(output))
f.Close()