diff options
author | adrianvillin <avillin@cisco.com> | 2024-02-13 06:00:02 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-03-12 16:48:46 +0000 |
commit | 28bd8f07d33bdd70c2cac03b70911a9069e4bd50 (patch) | |
tree | 102bab11aa225339995a4dd07ea8332d1fce2212 /extras/hs-test | |
parent | 7a2961523ef6d58d718a9efb7809a212bb0b58b1 (diff) |
hs-test: experimental support for multiple test instances
- appending PID to interface and container names
- added a check for used IP addresses
- TestEnvoyProxyHttpTcp and TestTcpWithLoss are broken when running multiple instances
Type: test
Change-Id: Ib917079ec7cf851dee59ff9c67e74f48c7c5e3c6
Signed-off-by: adrianvillin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test')
-rw-r--r-- | extras/hs-test/address_allocator.go | 60 | ||||
-rw-r--r-- | extras/hs-test/container.go | 8 | ||||
-rw-r--r-- | extras/hs-test/echo_test.go | 6 | ||||
-rw-r--r-- | extras/hs-test/hst_suite.go | 61 | ||||
-rw-r--r-- | extras/hs-test/http_test.go | 14 | ||||
-rw-r--r-- | extras/hs-test/ldp_test.go | 2 | ||||
-rw-r--r-- | extras/hs-test/linux_iperf_test.go | 2 | ||||
-rw-r--r-- | extras/hs-test/mirroring_test.go | 2 | ||||
-rw-r--r-- | extras/hs-test/proxy_test.go | 27 | ||||
-rw-r--r-- | extras/hs-test/raw_session_test.go | 2 | ||||
-rw-r--r-- | extras/hs-test/suite_nginx_test.go | 10 | ||||
-rw-r--r-- | extras/hs-test/suite_no_topo_test.go | 8 | ||||
-rw-r--r-- | extras/hs-test/suite_ns_test.go | 6 | ||||
-rw-r--r-- | extras/hs-test/suite_veth_test.go | 7 | ||||
-rw-r--r-- | extras/hs-test/tools/http_server/http_server.go | 4 | ||||
-rw-r--r-- | extras/hs-test/vcl_test.go | 8 |
16 files changed, 164 insertions, 63 deletions
diff --git a/extras/hs-test/address_allocator.go b/extras/hs-test/address_allocator.go index c08f88958dc..72bc298fd3f 100644 --- a/extras/hs-test/address_allocator.go +++ b/extras/hs-test/address_allocator.go @@ -1,11 +1,20 @@ package main -import "fmt" +import ( + "errors" + "fmt" + "os" + "strings" + + "github.com/edwarnicke/exechelper" +) type AddressCounter = int type Ip4AddressAllocator struct { networks map[int]AddressCounter + chosenOctet int + assignedIps []string } func (a *Ip4AddressAllocator) AddNetwork(networkNumber int) { @@ -28,12 +37,59 @@ func (a *Ip4AddressAllocator) NewIp4InterfaceAddress(inputNetworkNumber ...int) return "", fmt.Errorf("no available IPv4 addresses") } - address := fmt.Sprintf("10.10.%v.%v/24", networkNumber, numberOfAddresses) + address, err := a.createIpAddress(networkNumber, numberOfAddresses) + a.networks[networkNumber] = numberOfAddresses + 1 + return address + "/24", err +} + +// Creates a file every time an IP is assigned: used to keep track of addresses in use. +// If an address is not in use, 'counter' is then copied to 'chosenOctet' and it is used for the remaining tests. +// Also checks host IP addresses. +func (a *Ip4AddressAllocator) createIpAddress(networkNumber int, numberOfAddresses int) (string, error){ + hostIps, _ := exechelper.CombinedOutput("ip a") + counter := 10 + var address string + + for { + if a.chosenOctet != 0 { + address = fmt.Sprintf("10.%v.%v.%v", a.chosenOctet, networkNumber, numberOfAddresses) + file, err := os.Create(address) + if err != nil{ + return "", errors.New("unable to create file: " + fmt.Sprint(err)) + } + file.Close() + break + } else { + address = fmt.Sprintf("10.%v.%v.%v", counter, networkNumber, numberOfAddresses) + _, err := os.Stat(address) + if err == nil || strings.Contains(string(hostIps), address) { + counter++ + } else if os.IsNotExist(err) { + file, err := os.Create(address) + if err != nil{ + return "", errors.New("unable to create file: " + fmt.Sprint(err)) + } + file.Close() + a.chosenOctet = counter + break + } else { + return "", errors.New("an error occured while checking if a file exists: " + fmt.Sprint(err)) + } + } + } + + a.assignedIps = append(a.assignedIps, address) return address, nil } +func (a *Ip4AddressAllocator) deleteIpAddresses(){ + for ip := range a.assignedIps{ + os.Remove(a.assignedIps[ip]) + } +} + func NewIp4AddressAllocator() *Ip4AddressAllocator { var ip4AddrAllocator = new(Ip4AddressAllocator) ip4AddrAllocator.networks = make(map[int]AddressCounter) diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go index 10b5933b17f..87e8aa38e98 100644 --- a/extras/hs-test/container.go +++ b/extras/hs-test/container.go @@ -38,7 +38,7 @@ type Container struct { vppInstance *VppInstance } -func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error) { +func newContainer(suite *HstSuite, yamlInput ContainerConfig, pid string) (*Container, error) { containerName := yamlInput["name"].(string) if len(containerName) == 0 { err := fmt.Errorf("container name must not be blank") @@ -48,7 +48,7 @@ func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error var container = new(Container) container.volumes = make(map[string]Volume) container.envVars = make(map[string]string) - container.name = containerName + container.name = containerName + pid container.suite = suite if image, ok := yamlInput["image"]; ok { @@ -76,7 +76,7 @@ func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error } if _, ok := yamlInput["volumes"]; ok { - workingVolumeDir := logDir + container.suite.T().Name() + volumeDir + workingVolumeDir := logDir + container.suite.T().Name() + pid + volumeDir workDirReplacer := strings.NewReplacer("$HST_DIR", workDir) volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir) for _, volu := range yamlInput["volumes"].([]interface{}) { @@ -249,7 +249,7 @@ func (c *Container) copy(sourceFileName string, targetFileName string) error { } func (c *Container) createFile(destFileName string, content string) error { - f, err := os.CreateTemp("/tmp", "hst-config") + f, err := os.CreateTemp("/tmp", "hst-config" + c.suite.pid) if err != nil { return err } diff --git a/extras/hs-test/echo_test.go b/extras/hs-test/echo_test.go index 8dd620a336a..690f6d1378e 100644 --- a/extras/hs-test/echo_test.go +++ b/extras/hs-test/echo_test.go @@ -2,7 +2,7 @@ package main func (s *VethsSuite) TestEchoBuiltin() { serverVpp := s.getContainerByName("server-vpp").vppInstance - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverVpp.vppctl("test echo server " + " uri tcp://" + serverVeth.ip4AddressString() + "/1234") @@ -19,7 +19,7 @@ func (s *VethsSuite) TestEchoBuiltin() { func (s *VethsSuite) TestTcpWithLoss() { serverVpp := s.getContainerByName("server-vpp").vppInstance - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverVpp.vppctl("test echo server uri tcp://%s/20022", serverVeth.ip4AddressString()) @@ -33,7 +33,7 @@ func (s *VethsSuite) TestTcpWithLoss() { clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" + " packet-size 1400 packets-per-drop 1000") - clientVpp.vppctl("nsim output-feature enable-disable " + s.netInterfaces[clientInterfaceName].name) + clientVpp.vppctl("nsim output-feature enable-disable " + s.getInterfaceByName(clientInterfaceName).name) // Do echo test from client-vpp container output := clientVpp.vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes mbytes 50", diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go index 908c046d082..c5c8edbb829 100644 --- a/extras/hs-test/hst_suite.go +++ b/extras/hs-test/hst_suite.go @@ -38,10 +38,12 @@ type HstSuite struct { cpuAllocator *CpuAllocatorT cpuContexts []*CpuContext cpuPerVpp int + pid string } func (s *HstSuite) SetupSuite() { var err error + s.pid = fmt.Sprint(os.Getpid()) s.cpuAllocator, err = CpuAllocator() if err != nil { s.FailNow("failed to init cpu allocator: %v", err) @@ -73,6 +75,7 @@ func (s *HstSuite) TearDownTest() { } s.resetContainers() s.removeVolumes() + s.ip4AddrAllocator.deleteIpAddresses() } func (s *HstSuite) skipIfUnconfiguring() { @@ -134,7 +137,6 @@ func logVppInstance(container *Container, maxLines int){ fmt.Println(line) } fmt.Printf("^^^^^^^^^^^^^^^\n\n") - } func (s *HstSuite) hstFail() { @@ -242,8 +244,16 @@ func (s *HstSuite) removeVolumes() { } } +func (s *HstSuite) getNetNamespaceByName(name string) string { + return name + s.pid +} + +func (s *HstSuite) getInterfaceByName(name string) *NetInterface { + return s.netInterfaces[name + s.pid] +} + func (s *HstSuite) getContainerByName(name string) *Container { - return s.containers[name] + return s.containers[name + s.pid] } /* @@ -251,7 +261,7 @@ func (s *HstSuite) getContainerByName(name string) *Container { * are not able to modify the original container and affect other tests by doing that */ func (s *HstSuite) getTransientContainerByName(name string) *Container { - containerCopy := *s.containers[name] + containerCopy := *s.containers[name + s.pid] return &containerCopy } @@ -269,7 +279,7 @@ 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 + workingVolumeDir := logDir + s.T().Name() + s.pid + volumeDir volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir) hostDir = volDirReplacer.Replace(hostDir) s.volumes = append(s.volumes, hostDir) @@ -277,7 +287,8 @@ func (s *HstSuite) loadContainerTopology(topologyName string) { s.containers = make(map[string]*Container) for _, elem := range yamlTopo.Containers { - newContainer, err := newContainer(s, elem) + newContainer, err := newContainer(s, elem, s.pid) + newContainer.suite = s if err != nil { s.T().Fatalf("container config error: %v", err) } @@ -298,7 +309,32 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) { s.ip4AddrAllocator = NewIp4AddressAllocator() s.netInterfaces = make(map[string]*NetInterface) + for _, elem := range yamlTopo.Devices { + if _, ok := elem["name"]; ok { + elem["name"] = elem["name"].(string) + s.pid + } + + if peer, ok := elem["peer"].(NetDevConfig); ok { + if peer["name"].(string) != ""{ + peer["name"] = peer["name"].(string) + s.pid + } + if _, ok := peer["netns"]; ok{ + peer["netns"] = peer["netns"].(string) + s.pid + } + } + + if _, ok := elem["netns"]; ok { + elem["netns"] = elem["netns"].(string) + s.pid + } + + if _, ok := elem["interfaces"]; ok { + interfaceCount := len(elem["interfaces"].([]interface{})) + for i := 0; i < interfaceCount; i++ { + elem["interfaces"].([]interface{})[i] = elem["interfaces"].([]interface{})[i].(string) + s.pid + } + } + switch elem["type"].(string) { case NetNs: { @@ -366,8 +402,17 @@ func (s *HstSuite) getTestId() string { return s.testIds[testName] } +// Returns last 4 digits of PID +func (s *HstSuite) getPortFromPid() string { + port := s.pid + for len(port) < 4 { + port += "0" + } + return port[len(port)-4:] +} + func (s *HstSuite) startServerApp(running chan error, done chan struct{}, env []string) { - cmd := exec.Command("iperf3", "-4", "-s") + cmd := exec.Command("iperf3", "-4", "-s", "-p", s.getPortFromPid()) if env != nil { cmd.Env = env } @@ -391,7 +436,7 @@ func (s *HstSuite) startClientApp(ipAddress string, env []string, clnCh chan err nTries := 0 for { - cmd := exec.Command("iperf3", "-c", ipAddress, "-u", "-l", "1460", "-b", "10g") + cmd := exec.Command("iperf3", "-c", ipAddress, "-u", "-l", "1460", "-b", "10g", "-p", s.getPortFromPid()) if env != nil { cmd.Env = env } @@ -413,7 +458,7 @@ func (s *HstSuite) startClientApp(ipAddress string, env []string, clnCh chan err } func (s *HstSuite) startHttpServer(running chan struct{}, done chan struct{}, addressPort, netNs string) { - cmd := newCommand([]string{"./http_server", addressPort}, netNs) + cmd := newCommand([]string{"./http_server", addressPort, s.pid}, netNs) err := cmd.Start() s.log(cmd) if err != nil { diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index 068d0424555..943c8a591d4 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -7,11 +7,11 @@ import ( ) func (s *NsSuite) TestHttpTps() { - iface := s.netInterfaces[clientInterface] + iface := s.getInterfaceByName(clientInterface) client_ip := iface.ip4AddressString() port := "8080" finished := make(chan error, 1) - clientNetns := "cln" + clientNetns := s.getNetNamespaceByName("cln") container := s.getContainerByName("vpp") @@ -28,7 +28,7 @@ func (s *VethsSuite) TestHttpCli() { serverContainer := s.getContainerByName("server-vpp") clientContainer := s.getContainerByName("client-vpp") - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverContainer.vppInstance.vppctl("http cli server") @@ -50,7 +50,7 @@ func (s *NoTopoSuite) TestNginxHttp3() { vpp := s.getContainerByName("vpp").vppInstance vpp.waitForApp("nginx-", 5) - serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() + serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() defer func() { os.Remove(query) }() curlCont := s.getContainerByName("curl") @@ -65,7 +65,7 @@ func (s *NoTopoSuite) TestHttpStaticProm() { finished := make(chan error, 1) query := "stats.prom" vpp := s.getContainerByName("vpp").vppInstance - serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() + serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() s.log(vpp.vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) s.log(vpp.vppctl("prom enable")) go s.startWget(finished, serverAddress, "80", query, "") @@ -83,7 +83,7 @@ func (s *NoTopoSuite) TestNginxAsServer() { vpp := s.getContainerByName("vpp").vppInstance vpp.waitForApp("nginx-", 5) - serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() + serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() defer func() { os.Remove(query) }() go s.startWget(finished, serverAddress, "80", query, "") @@ -104,7 +104,7 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error { nRequests := 1000000 nClients := 1000 - serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() + serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() vpp := s.getContainerByName("vpp").vppInstance diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go index 1ccf8592863..8d9168d3d5d 100644 --- a/extras/hs-test/ldp_test.go +++ b/extras/hs-test/ldp_test.go @@ -62,7 +62,7 @@ func (s *VethsSuite) TestLDPreloadIperfVpp() { s.log("attaching client to vpp") var clnRes = make(chan string, 1) clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clientVclFileName) - serverVethAddress := s.netInterfaces[serverInterfaceName].ip4AddressString() + serverVethAddress := s.getInterfaceByName(serverInterfaceName).ip4AddressString() go s.startClientApp(serverVethAddress, clnEnv, clnCh, clnRes) s.log(<-clnRes) diff --git a/extras/hs-test/linux_iperf_test.go b/extras/hs-test/linux_iperf_test.go index 47ebd0363ab..06247e45240 100644 --- a/extras/hs-test/linux_iperf_test.go +++ b/extras/hs-test/linux_iperf_test.go @@ -14,7 +14,7 @@ func (s *TapSuite) TestLinuxIperf() { s.assertNil(err, err) s.log("server running") - ipAddress := s.netInterfaces[tapInterfaceName].ip4AddressString() + ipAddress := s.getInterfaceByName(tapInterfaceName).ip4AddressString() go s.startClientApp(ipAddress, nil, clnCh, clnRes) s.log("client running") s.log(<-clnRes) diff --git a/extras/hs-test/mirroring_test.go b/extras/hs-test/mirroring_test.go index 03e9c03b8db..91f43f45682 100644 --- a/extras/hs-test/mirroring_test.go +++ b/extras/hs-test/mirroring_test.go @@ -5,7 +5,7 @@ import ( ) func (s *NginxSuite) TestMirroring() { - proxyAddress := s.netInterfaces[mirroringClientInterfaceName].peer.ip4AddressString() + proxyAddress := s.getInterfaceByName(mirroringClientInterfaceName).peer.ip4AddressString() path := "/64B.json" diff --git a/extras/hs-test/proxy_test.go b/extras/hs-test/proxy_test.go index 748e48b0344..c2f9b6f2825 100644 --- a/extras/hs-test/proxy_test.go +++ b/extras/hs-test/proxy_test.go @@ -8,18 +8,19 @@ import ( ) func testProxyHttpTcp(s *NsSuite, proto string) error { - const outputFile = "test.data" - const srcFile = "httpTestFile" - const fileSize = "10M" + var outputFile string = "test" + s.pid + ".data" + var srcFilePid string = "httpTestFile" + s.pid + const srcFileNoPid = "httpTestFile" + const fileSize string = "10M" stopServer := make(chan struct{}, 1) serverRunning := make(chan struct{}, 1) - serverNetns := "srv" - clientNetns := "cln" + serverNetns := s.getNetNamespaceByName("srv") + clientNetns := s.getNetNamespaceByName("cln") // create test file - err := exechelper.Run(fmt.Sprintf("ip netns exec %s truncate -s %s %s", serverNetns, fileSize, srcFile)) + err := exechelper.Run(fmt.Sprintf("ip netns exec %s truncate -s %s %s", serverNetns, fileSize, srcFilePid)) s.assertNil(err, "failed to run truncate command: " + fmt.Sprint(err)) - defer func() { os.Remove(srcFile) }() + defer func() { os.Remove(srcFilePid) }() s.log("test file created...") @@ -33,13 +34,13 @@ func testProxyHttpTcp(s *NsSuite, proto string) error { s.log("http server started...") - clientVeth := s.netInterfaces[clientInterface] + clientVeth := s.getInterfaceByName(clientInterface) c := fmt.Sprintf("ip netns exec %s wget --no-proxy --retry-connrefused"+ " --retry-on-http-error=503 --tries=10 -O %s ", clientNetns, outputFile) if proto == "tls" { c += " --secure-protocol=TLSv1_3 --no-check-certificate https://" } - c += fmt.Sprintf("%s:555/%s", clientVeth.ip4AddressString(), srcFile) + c += fmt.Sprintf("%s:555/%s", clientVeth.ip4AddressString(), srcFileNoPid) s.log(c) _, err = exechelper.CombinedOutput(c) @@ -48,13 +49,13 @@ func testProxyHttpTcp(s *NsSuite, proto string) error { s.assertNil(err, "failed to run wget: '%s', cmd: %s", err, c) stopServer <- struct{}{} - s.assertNil(assertFileSize(outputFile, srcFile)) + s.assertNil(assertFileSize(outputFile, srcFilePid)) return nil } func configureVppProxy(s *NsSuite, proto string) { - serverVeth := s.netInterfaces[serverInterface] - clientVeth := s.netInterfaces[clientInterface] + serverVeth := s.getInterfaceByName(serverInterface) + clientVeth := s.getInterfaceByName(clientInterface) testVppProxy := s.getContainerByName("vpp").vppInstance output := testVppProxy.vppctl( @@ -85,7 +86,7 @@ func configureEnvoyProxy(s *NsSuite) { err := envoyContainer.create() s.assertNil(err, "Error creating envoy container: %s", err) - serverVeth := s.netInterfaces[serverInterface] + serverVeth := s.getInterfaceByName(serverInterface) address := struct { Server string }{ diff --git a/extras/hs-test/raw_session_test.go b/extras/hs-test/raw_session_test.go index 386f9bc685f..670ed582522 100644 --- a/extras/hs-test/raw_session_test.go +++ b/extras/hs-test/raw_session_test.go @@ -14,7 +14,7 @@ func (s *VethsSuite) TestVppEchoTcp() { } func (s *VethsSuite) testVppEcho(proto string) { - serverVethAddress := s.netInterfaces[serverInterfaceName].ip4AddressString() + serverVethAddress := s.getInterfaceByName(serverInterfaceName).ip4AddressString() uri := proto + "://" + serverVethAddress + "/12344" echoSrvContainer := s.getContainerByName("server-app") diff --git a/extras/hs-test/suite_nginx_test.go b/extras/hs-test/suite_nginx_test.go index 94fd010814a..8f40590d1f2 100644 --- a/extras/hs-test/suite_nginx_test.go +++ b/extras/hs-test/suite_nginx_test.go @@ -1,12 +1,12 @@ package main +// These correspond to names used in yaml config const ( - // These correspond to names used in yaml config - mirroringClientInterfaceName = "hstcln" - mirroringServerInterfaceName = "hstsrv" vppProxyContainerName = "vpp-proxy" nginxProxyContainerName = "nginx-proxy" nginxServerContainerName = "nginx-server" + mirroringClientInterfaceName = "hstcln" + mirroringServerInterfaceName = "hstsrv" ) type NginxSuite struct { @@ -35,10 +35,10 @@ func (s *NginxSuite) SetupTest() { proxyVpp, _ := vppProxyContainer.newVppInstance(cpus, sessionConfig) s.assertNil(proxyVpp.start()) - clientInterface := s.netInterfaces[mirroringClientInterfaceName] + clientInterface := s.getInterfaceByName(mirroringClientInterfaceName) s.assertNil(proxyVpp.createTap(clientInterface, 1)) - serverInterface := s.netInterfaces[mirroringServerInterfaceName] + serverInterface := s.getInterfaceByName(mirroringServerInterfaceName) s.assertNil(proxyVpp.createTap(serverInterface, 2)) nginxContainer := s.getTransientContainerByName(nginxProxyContainerName) diff --git a/extras/hs-test/suite_no_topo_test.go b/extras/hs-test/suite_no_topo_test.go index 97e5ca4f416..bbf0cfda685 100644 --- a/extras/hs-test/suite_no_topo_test.go +++ b/extras/hs-test/suite_no_topo_test.go @@ -1,9 +1,9 @@ package main const ( - singleTopoContainerVpp = "vpp" - singleTopoContainerNginx = "nginx" - tapInterfaceName = "htaphost" + singleTopoContainerVpp = "vpp" + singleTopoContainerNginx = "nginx" + tapInterfaceName = "htaphost" ) type NoTopoSuite struct { @@ -31,7 +31,7 @@ func (s *NoTopoSuite) SetupTest() { vpp, _ := container.newVppInstance(cpus, sessionConfig) s.assertNil(vpp.start()) - tapInterface := s.netInterfaces[tapInterfaceName] + tapInterface := s.getInterfaceByName(tapInterfaceName) s.assertNil(vpp.createTap(tapInterface), "failed to create tap interface") } diff --git a/extras/hs-test/suite_ns_test.go b/extras/hs-test/suite_ns_test.go index b32fec7e729..46d5bef92ad 100644 --- a/extras/hs-test/suite_ns_test.go +++ b/extras/hs-test/suite_ns_test.go @@ -1,7 +1,7 @@ package main +// These correspond to names used in yaml config const ( - // These correspond to names used in yaml config clientInterface = "hclnvpp" serverInterface = "hsrvvpp" ) @@ -33,11 +33,11 @@ func (s *NsSuite) SetupTest() { vpp, _ := container.newVppInstance(cpus, sessionConfig) s.assertNil(vpp.start()) - idx, err := vpp.createAfPacket(s.netInterfaces[serverInterface]) + idx, err := vpp.createAfPacket(s.getInterfaceByName(serverInterface)) s.assertNil(err, err) s.assertNotEqual(0, idx) - idx, err = vpp.createAfPacket(s.netInterfaces[clientInterface]) + idx, err = vpp.createAfPacket(s.getInterfaceByName(clientInterface)) s.assertNil(err, err) s.assertNotEqual(0, idx) diff --git a/extras/hs-test/suite_veth_test.go b/extras/hs-test/suite_veth_test.go index 4158c769474..061eee07d1f 100644 --- a/extras/hs-test/suite_veth_test.go +++ b/extras/hs-test/suite_veth_test.go @@ -4,8 +4,8 @@ import ( "time" ) +// These correspond to names used in yaml config const ( - // These correspond to names used in yaml config serverInterfaceName = "srv" clientInterfaceName = "cln" ) @@ -25,7 +25,6 @@ func (s *VethsSuite) SetupTest() { s.HstSuite.SetupTest() // Setup test conditions - var sessionConfig Stanza sessionConfig. newStanza("session"). @@ -55,7 +54,7 @@ func (s *VethsSuite) setupServerVpp() { serverVpp := s.getContainerByName("server-vpp").vppInstance s.assertNil(serverVpp.start()) - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) idx, err := serverVpp.createAfPacket(serverVeth) s.assertNil(err, err) s.assertNotEqual(0, idx) @@ -65,7 +64,7 @@ func (s *VethsSuite) setupClientVpp() { clientVpp := s.getContainerByName("client-vpp").vppInstance s.assertNil(clientVpp.start()) - clientVeth := s.netInterfaces[clientInterfaceName] + clientVeth := s.getInterfaceByName(clientInterfaceName) idx, err := clientVpp.createAfPacket(clientVeth) s.assertNil(err, err) s.assertNotEqual(0, idx) diff --git a/extras/hs-test/tools/http_server/http_server.go b/extras/hs-test/tools/http_server/http_server.go index 8edbb149967..d2ab3851643 100644 --- a/extras/hs-test/tools/http_server/http_server.go +++ b/extras/hs-test/tools/http_server/http_server.go @@ -8,13 +8,13 @@ import ( ) func main() { - if len(os.Args) < 2 { + if len(os.Args) < 3 { fmt.Println("arg expected") os.Exit(1) } http.HandleFunc("/httpTestFile", func(w http.ResponseWriter, r *http.Request) { - file, _ := os.Open("httpTestFile") + file, _ := os.Open("httpTestFile" + os.Args[2]) defer file.Close() io.Copy(w, file) }) diff --git a/extras/hs-test/vcl_test.go b/extras/hs-test/vcl_test.go index 281b91617b9..cb6aaa4adc0 100644 --- a/extras/hs-test/vcl_test.go +++ b/extras/hs-test/vcl_test.go @@ -35,7 +35,7 @@ func (s *VethsSuite) testXEchoVclClient(proto string) { port := "12345" serverVpp := s.getContainerByName("server-vpp").vppInstance - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverVpp.vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, serverVeth.ip4AddressString(), port) echoClnContainer := s.getTransientContainerByName("client-app") @@ -67,7 +67,7 @@ func (s *VethsSuite) testXEchoVclServer(proto string) { vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, port) srvAppCont.execServer(vclSrvCmd) - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverVethAddress := serverVeth.ip4AddressString() clientVpp := s.getContainerByName("client-vpp").vppInstance @@ -85,7 +85,7 @@ func (s *VethsSuite) testVclEcho(proto string) { srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf") srvAppCont.execServer("vcl_test_server " + port) - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverVethAddress := serverVeth.ip4AddressString() echoClnContainer := s.getTransientContainerByName("client-app") @@ -123,7 +123,7 @@ func (s *VethsSuite) testRetryAttach(proto string) { s.log("This whole test case can take around 3 minutes to run. Please be patient.") s.log("... Running first echo client test, before disconnect.") - serverVeth := s.netInterfaces[serverInterfaceName] + serverVeth := s.getInterfaceByName(serverInterfaceName) serverVethAddress := serverVeth.ip4AddressString() echoClnContainer := s.getTransientContainerByName("client-app") |