aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/hs-test/container.go17
-rw-r--r--extras/hs-test/hst_suite.go6
-rw-r--r--extras/hs-test/ldp_test.go4
-rw-r--r--extras/hs-test/topo-containers/2peerVeth.yaml6
-rw-r--r--extras/hs-test/topo-containers/nginxProxyAndServer.yaml2
-rw-r--r--extras/hs-test/topo-containers/ns.yaml2
-rw-r--r--extras/hs-test/topo-containers/single.yaml2
7 files changed, 22 insertions, 17 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go
index 812198d62db..86f511c2b46 100644
--- a/extras/hs-test/container.go
+++ b/extras/hs-test/container.go
@@ -12,7 +12,8 @@ import (
)
const (
- logDir string = "/tmp/hs-test/"
+ logDir string = "/tmp/hs-test/"
+ volumeDir string = "/volumes"
)
var (
@@ -37,7 +38,7 @@ type Container struct {
vppInstance *VppInstance
}
-func newContainer(yamlInput ContainerConfig) (*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")
@@ -48,6 +49,7 @@ func newContainer(yamlInput ContainerConfig) (*Container, error) {
container.volumes = make(map[string]Volume)
container.envVars = make(map[string]string)
container.name = containerName
+ container.suite = suite
if image, ok := yamlInput["image"]; ok {
container.image = image.(string)
@@ -74,19 +76,20 @@ func newContainer(yamlInput ContainerConfig) (*Container, error) {
}
if _, ok := yamlInput["volumes"]; ok {
- r := strings.NewReplacer("$HST_DIR", workDir)
+ workingVolumeDir := logDir + container.suite.T().Name() + volumeDir
+ workDirReplacer := strings.NewReplacer("$HST_DIR", workDir)
+ volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
for _, volu := range yamlInput["volumes"].([]interface{}) {
volumeMap := volu.(ContainerConfig)
- hostDir := r.Replace(volumeMap["host-dir"].(string))
+ hostDir := workDirReplacer.Replace(volumeMap["host-dir"].(string))
+ hostDir = volDirReplacer.Replace(hostDir)
containerDir := volumeMap["container-dir"].(string)
isDefaultWorkDir := false
if isDefault, ok := volumeMap["is-default-work-dir"]; ok {
isDefaultWorkDir = isDefault.(bool)
}
-
container.addVolume(hostDir, containerDir, isDefaultWorkDir)
-
}
}
@@ -342,7 +345,7 @@ func (c *Container) stop() error {
func (c *Container) createConfig(targetConfigName string, templateName string, values any) {
template := template.Must(template.ParseFiles(templateName))
- f, err := os.CreateTemp("/tmp/hs-test/", "hst-config")
+ f, err := os.CreateTemp(logDir, "hst-config")
c.suite.assertNil(err)
defer os.Remove(f.Name())
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go
index 12a66e44d46..7f93b15f50a 100644
--- a/extras/hs-test/hst_suite.go
+++ b/extras/hs-test/hst_suite.go
@@ -221,13 +221,15 @@ func (s *HstSuite) loadContainerTopology(topologyName string) {
for _, elem := range yamlTopo.Volumes {
volumeMap := elem["volume"].(VolumeConfig)
hostDir := volumeMap["host-dir"].(string)
+ workingVolumeDir := logDir + s.T().Name() + volumeDir
+ volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
+ hostDir = volDirReplacer.Replace(hostDir)
s.volumes = append(s.volumes, hostDir)
}
s.containers = make(map[string]*Container)
for _, elem := range yamlTopo.Containers {
- newContainer, err := newContainer(elem)
- newContainer.suite = s
+ newContainer, err := newContainer(s, elem)
if err != nil {
s.T().Fatalf("container config error: %v", err)
}
diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go
index 90a6182a039..b6249cdd257 100644
--- a/extras/hs-test/ldp_test.go
+++ b/extras/hs-test/ldp_test.go
@@ -26,7 +26,7 @@ func (s *VethsSuite) TestLDPreloadIperfVpp() {
s.log("starting VPPs")
clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default",
- clientContainer.getContainerWorkDir())
+ clientContainer.getHostWorkDir())
err := clnVclConf.
newStanza("vcl").
append("rx-fifo-size 4000000").
@@ -39,7 +39,7 @@ func (s *VethsSuite) TestLDPreloadIperfVpp() {
s.assertNil(err)
serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default",
- serverContainer.getContainerWorkDir())
+ serverContainer.getHostWorkDir())
err = srvVclConf.
newStanza("vcl").
append("rx-fifo-size 4000000").
diff --git a/extras/hs-test/topo-containers/2peerVeth.yaml b/extras/hs-test/topo-containers/2peerVeth.yaml
index 36de33b0f45..e1591fb9019 100644
--- a/extras/hs-test/topo-containers/2peerVeth.yaml
+++ b/extras/hs-test/topo-containers/2peerVeth.yaml
@@ -1,11 +1,11 @@
---
volumes:
- volume: &server-vol
- host-dir: /tmp/server-share
- container-dir: /tmp/server-share
+ host-dir: "$HST_VOLUME_DIR/server-share"
+ container-dir: "/tmp/server-share"
is-default-work-dir: true
- volume: &client-vol
- host-dir: /tmp/client-share
+ host-dir: "$HST_VOLUME_DIR/client-share"
container-dir: "/tmp/client-share"
is-default-work-dir: true
diff --git a/extras/hs-test/topo-containers/nginxProxyAndServer.yaml b/extras/hs-test/topo-containers/nginxProxyAndServer.yaml
index bac6a2df174..cc6b780bafc 100644
--- a/extras/hs-test/topo-containers/nginxProxyAndServer.yaml
+++ b/extras/hs-test/topo-containers/nginxProxyAndServer.yaml
@@ -1,7 +1,7 @@
---
volumes:
- volume: &shared-vol-proxy
- host-dir: /tmp/shared-vol-proxy
+ host-dir: "$HST_VOLUME_DIR/shared-vol-proxy"
containers:
- name: "vpp-proxy"
diff --git a/extras/hs-test/topo-containers/ns.yaml b/extras/hs-test/topo-containers/ns.yaml
index 2b1902b2922..2298ad232c2 100644
--- a/extras/hs-test/topo-containers/ns.yaml
+++ b/extras/hs-test/topo-containers/ns.yaml
@@ -1,7 +1,7 @@
---
volumes:
- volume: &shared-vol
- host-dir: /tmp/shared-vol
+ host-dir: "$HST_VOLUME_DIR/shared-vol"
# $HST_DIR will be replaced during runtime by path to hs-test directory
containers:
diff --git a/extras/hs-test/topo-containers/single.yaml b/extras/hs-test/topo-containers/single.yaml
index 6fd4d31bed8..b6970c517bd 100644
--- a/extras/hs-test/topo-containers/single.yaml
+++ b/extras/hs-test/topo-containers/single.yaml
@@ -1,7 +1,7 @@
---
volumes:
- volume: &shared-vol
- host-dir: /tmp/shared-vol
+ host-dir: "$HST_VOLUME_DIR/shared-vol"
containers:
- name: "vpp"