func httpClientRepeat(s *NoTopoSuite, requestMethod string, clientArgs string) {
vpp := s.Containers.Vpp.VppInstance
- logPath := s.Containers.NginxServer.GetContainerWorkDir() + "/" + s.Containers.NginxServer.Name + "-access.log"
serverAddress := s.Interfaces.Tap.Ip4AddressString() + ":" + s.Ports.NginxServer
replyCountInt := 0
repeatAmount := 10000
s.CreateNginxServer()
s.AssertNil(s.Containers.NginxServer.Start())
+ logPath := s.Containers.NginxServer.GetContainerWorkDir() + "/" + s.Containers.NginxServer.Name + "-access.log"
if requestMethod == "post" {
fileName := "/tmp/test_file.txt"
const (
LogDir string = "/tmp/hs-test/"
- VolumeDir string = "/volumes"
+ VolumeDir string = "/vol"
)
type HstCommon struct {
VppInstance *VppInstance
AllocatedCpus []int
ctx context.Context
+ volumeYamlConf []any
}
func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error) {
}
if _, ok := yamlInput["volumes"]; ok {
- workingVolumeDir := LogDir + suite.GetCurrentTestName() + VolumeDir
- workDirReplacer := strings.NewReplacer("$HST_DIR", workDir)
- volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
- for _, volu := range yamlInput["volumes"].([]interface{}) {
- volumeMap := volu.(ContainerConfig)
- 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)
- }
+ container.volumeYamlConf = yamlInput["volumes"].([]any)
}
if _, ok := yamlInput["vars"]; ok {
// Creates a container
func (c *Container) Create() error {
+ c.createVolumePaths()
+
var sliceOfImageNames []string
images, err := c.Suite.Docker.ImageList(c.ctx, image.ListOptions{})
c.Suite.AssertNil(err)
c.Suite.AssertNil(c.Start())
}
+func (c *Container) createVolumePaths() {
+ workingVolumeDir := LogDir + c.Suite.GetCurrentTestName() + VolumeDir
+ workDirReplacer := strings.NewReplacer("$HST_DIR", workDir)
+ volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
+
+ for _, volu := range c.volumeYamlConf {
+ volumeMap := volu.(ContainerConfig)
+ 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)
+ }
+ c.addVolume(hostDir, containerDir, isDefaultWorkDir)
+ }
+}
+
func (c *Container) addVolume(hostDir string, containerDir string, isDefaultWorkDir bool) {
var volume Volume
- volume.HostDir = strings.Replace(hostDir, "volumes", c.Suite.GetTestId()+"/"+"volumes", 1)
+ volume.HostDir = strings.Replace(hostDir, "vol", c.Suite.GetTestId()+"/"+"vol", 1)
volume.ContainerDir = containerDir
volume.IsDefaultWorkDir = isDefaultWorkDir
c.Volumes[hostDir] = volume
+ if volume.IsDefaultWorkDir && len(volume.HostDir)+len(defaultApiSocketFilePath) > 108 {
+ c.Suite.Log("**************************************************************\n" +
+ "Default api socket file path exceeds 108 bytes. Test may fail.\n" +
+ "**************************************************************")
+ }
}
func (c *Container) getVolumesAsSlice() []string {
if err := c.Suite.Docker.ContainerStop(c.ctx, c.ID, containerTypes.StopOptions{Timeout: &timeout}); err != nil {
return err
}
+
+ for n, v := range c.Volumes {
+ if v.IsDefaultWorkDir {
+ delete(c.Volumes, n)
+ }
+ }
+
return nil
}
err = f.Close()
c.Suite.AssertNil(err, err)
- c.copy(f.Name(), targetConfigName)
+ c.Suite.AssertNil(c.copy(f.Name(), targetConfigName))
}
func init() {
HstCommon
AllContainers map[string]*Container
StartedContainers []*Container
- Volumes []string
NetConfigs []NetConfig
NetInterfaces map[string]*NetInterface
Ip4AddrAllocator *Ip4AddressAllocator
Fail("unmarshal error: " + fmt.Sprint(err))
}
- for _, elem := range yamlTopo.Volumes {
- volumeMap := elem["volume"].(VolumeConfig)
- hostDir := volumeMap["host-dir"].(string)
- workingVolumeDir := LogDir + s.GetCurrentTestName() + VolumeDir
- volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
- hostDir = volDirReplacer.Replace(hostDir)
- s.Volumes = append(s.Volumes, hostDir)
- }
-
s.AllContainers = make(map[string]*Container)
for _, elem := range yamlTopo.Containers {
newContainer, err := newContainer(s, elem)
}
if _, ok := s.TestIds[testName]; !ok {
- s.TestIds[testName] = time.Now().Format("2006-01-02_15-04-05")
+ s.TestIds[testName] = time.Now().Format("060102_150405")
}
return s.TestIds[testName]
s.Containers.Curl = s.GetContainerByName("curl")
s.Ports.Nginx = s.GeneratePortAsInt()
s.Ports.Proxy = s.GeneratePortAsInt()
+ s.Ports.EnvoyAdmin = s.GeneratePortAsInt()
}
func (s *EnvoyProxySuite) SetupTest() {
RegisterVppUdpProxyTests(VppProxyUdpTest, VppConnectUdpProxyTest, VppConnectUdpInvalidCapsuleTest,
VppConnectUdpUnknownCapsuleTest, VppConnectUdpClientCloseTest, VppConnectUdpInvalidTargetTest)
RegisterVppUdpProxySoloTests(VppProxyUdpMigrationMTTest, VppConnectUdpStressMTTest, VppConnectUdpStressTest)
- RegisterEnvoyProxyTests(EnvoyProxyHttpGetTcpTest, EnvoyProxyHttpPutTcpTest)
+ RegisterEnvoyProxyTests(EnvoyHttpGetTcpTest, EnvoyHttpPutTcpTest)
RegisterNginxProxySoloTests(NginxMirroringTest, MirrorMultiThreadTest)
}
s.CurlUploadResource(uri, CurlContainerTestFile)
}
-func EnvoyProxyHttpGetTcpTest(s *EnvoyProxySuite) {
+func EnvoyHttpGetTcpTest(s *EnvoyProxySuite) {
uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.Ports.Proxy)
s.CurlDownloadResource(uri)
}
-func EnvoyProxyHttpPutTcpTest(s *EnvoyProxySuite) {
+func EnvoyHttpPutTcpTest(s *EnvoyProxySuite) {
uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ProxyAddr(), s.Ports.Proxy)
s.CurlUploadResource(uri, CurlContainerTestFile)
}
---
volumes:
- volume: &server-vol
- host-dir: "$HST_VOLUME_DIR/server-share"
- container-dir: "/tmp/server-share"
+ host-dir: "$HST_VOLUME_DIR/server"
+ container-dir: "/tmp/server"
is-default-work-dir: true
- volume: &client-vol
- host-dir: "$HST_VOLUME_DIR/client-share"
- container-dir: "/tmp/client-share"
+ host-dir: "$HST_VOLUME_DIR/client"
+ container-dir: "/tmp/client"
is-default-work-dir: true
containers:
---
volumes:
- volume: &shared-vol
- host-dir: "$HST_VOLUME_DIR/shared-vol"
+ host-dir: "$HST_VOLUME_DIR/shared"
containers:
- name: "vpp"
---
volumes:
- volume: &shared-vol-nginx-proxy
- host-dir: "$HST_VOLUME_DIR/shared-vol-nginx-proxy"
+ host-dir: "$HST_VOLUME_DIR/shared"
containers:
- name: "vpp"
---
volumes:
- volume: &shared-vol
- host-dir: "$HST_VOLUME_DIR/shared-vol"
+ host-dir: "$HST_VOLUME_DIR/shared"
containers:
- name: "vpp"
---
volumes:
- volume: &shared-vol
- host-dir: "$HST_VOLUME_DIR/shared-vol"
+ host-dir: "$HST_VOLUME_DIR/shared"
containers:
- name: "vpp"
---
volumes:
- volume: &shared-vol
- host-dir: "$HST_VOLUME_DIR/shared-vol"
+ host-dir: "$HST_VOLUME_DIR/shared"
containers:
- name: "vpp-proxy"