hs-test: experimental support for multiple test instances
[vpp.git] / extras / hs-test / proxy_test.go
index 748e48b..c2f9b6f 100644 (file)
@@ -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
        }{