aboutsummaryrefslogtreecommitdiffstats
path: root/extras/hs-test/vcl_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'extras/hs-test/vcl_test.go')
-rw-r--r--extras/hs-test/vcl_test.go173
1 files changed, 89 insertions, 84 deletions
diff --git a/extras/hs-test/vcl_test.go b/extras/hs-test/vcl_test.go
index cb6aaa4adc0..3b413b26bed 100644
--- a/extras/hs-test/vcl_test.go
+++ b/extras/hs-test/vcl_test.go
@@ -1,152 +1,157 @@
package main
import (
+ . "fd.io/hs-test/infra"
"fmt"
"time"
)
+func init() {
+ RegisterVethTests(XEchoVclClientUdpTest, XEchoVclClientTcpTest, XEchoVclServerUdpTest,
+ XEchoVclServerTcpTest, VclEchoTcpTest, VclEchoUdpTest, VclRetryAttachTest)
+}
+
func getVclConfig(c *Container, ns_id_optional ...string) string {
var s Stanza
ns_id := "default"
if len(ns_id_optional) > 0 {
ns_id = ns_id_optional[0]
}
- s.newStanza("vcl").
- append(fmt.Sprintf("app-socket-api %[1]s/var/run/app_ns_sockets/%[2]s", c.getContainerWorkDir(), ns_id)).
- append("app-scope-global").
- append("app-scope-local").
- append("use-mq-eventfd")
+ s.NewStanza("vcl").
+ Append(fmt.Sprintf("app-socket-api %[1]s/var/run/app_ns_sockets/%[2]s", c.GetContainerWorkDir(), ns_id)).
+ Append("app-scope-global").
+ Append("app-scope-local").
+ Append("use-mq-eventfd")
if len(ns_id_optional) > 0 {
- s.append(fmt.Sprintf("namespace-id %[1]s", ns_id)).
- append(fmt.Sprintf("namespace-secret %[1]s", ns_id))
+ s.Append(fmt.Sprintf("namespace-id %[1]s", ns_id)).
+ Append(fmt.Sprintf("namespace-secret %[1]s", ns_id))
}
- return s.close().toString()
+ return s.Close().ToString()
}
-func (s *VethsSuite) TestXEchoVclClientUdp() {
- s.testXEchoVclClient("udp")
+func XEchoVclClientUdpTest(s *VethsSuite) {
+ testXEchoVclClient(s, "udp")
}
-func (s *VethsSuite) TestXEchoVclClientTcp() {
- s.testXEchoVclClient("tcp")
+func XEchoVclClientTcpTest(s *VethsSuite) {
+ testXEchoVclClient(s, "tcp")
}
-func (s *VethsSuite) testXEchoVclClient(proto string) {
+func testXEchoVclClient(s *VethsSuite, proto string) {
port := "12345"
- serverVpp := s.getContainerByName("server-vpp").vppInstance
+ serverVpp := s.GetContainerByName("server-vpp").VppInstance
- serverVeth := s.getInterfaceByName(serverInterfaceName)
- serverVpp.vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, serverVeth.ip4AddressString(), port)
+ 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")
- echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer))
+ echoClnContainer := s.GetTransientContainerByName("client-app")
+ echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
- testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + serverVeth.ip4AddressString() + " " + port
- s.log(testClientCommand)
- echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
- o := echoClnContainer.exec(testClientCommand)
- s.log(o)
- s.assertContains(o, "CLIENT RESULTS")
+ testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + serverVeth.Ip4AddressString() + " " + port
+ s.Log(testClientCommand)
+ echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+ o := echoClnContainer.Exec(testClientCommand)
+ s.Log(o)
+ s.AssertContains(o, "CLIENT RESULTS")
}
-func (s *VethsSuite) TestXEchoVclServerUdp() {
- s.testXEchoVclServer("udp")
+func XEchoVclServerUdpTest(s *VethsSuite) {
+ testXEchoVclServer(s, "udp")
}
-func (s *VethsSuite) TestXEchoVclServerTcp() {
- s.testXEchoVclServer("tcp")
+func XEchoVclServerTcpTest(s *VethsSuite) {
+ testXEchoVclServer(s, "tcp")
}
-func (s *VethsSuite) testXEchoVclServer(proto string) {
+func testXEchoVclServer(s *VethsSuite, proto string) {
port := "12345"
- srvVppCont := s.getContainerByName("server-vpp")
- srvAppCont := s.getContainerByName("server-app")
+ srvVppCont := s.GetContainerByName("server-vpp")
+ srvAppCont := s.GetContainerByName("server-app")
- srvAppCont.createFile("/vcl.conf", getVclConfig(srvVppCont))
- srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf")
+ srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
+ srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, port)
- srvAppCont.execServer(vclSrvCmd)
+ srvAppCont.ExecServer(vclSrvCmd)
- serverVeth := s.getInterfaceByName(serverInterfaceName)
- serverVethAddress := serverVeth.ip4AddressString()
+ serverVeth := s.GetInterfaceByName(ServerInterfaceName)
+ serverVethAddress := serverVeth.Ip4AddressString()
- clientVpp := s.getContainerByName("client-vpp").vppInstance
- o := clientVpp.vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose mbytes 2", proto, serverVethAddress, port)
- s.log(o)
- s.assertContains(o, "Test finished at")
+ clientVpp := s.GetContainerByName("client-vpp").VppInstance
+ o := clientVpp.Vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose mbytes 2", proto, serverVethAddress, port)
+ s.Log(o)
+ s.AssertContains(o, "Test finished at")
}
-func (s *VethsSuite) testVclEcho(proto string) {
+func testVclEcho(s *VethsSuite, proto string) {
port := "12345"
- srvVppCont := s.getContainerByName("server-vpp")
- srvAppCont := s.getContainerByName("server-app")
+ srvVppCont := s.GetContainerByName("server-vpp")
+ srvAppCont := s.GetContainerByName("server-app")
- srvAppCont.createFile("/vcl.conf", getVclConfig(srvVppCont))
- srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf")
- srvAppCont.execServer("vcl_test_server " + port)
+ srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
+ srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+ srvAppCont.ExecServer("vcl_test_server " + port)
- serverVeth := s.getInterfaceByName(serverInterfaceName)
- serverVethAddress := serverVeth.ip4AddressString()
+ serverVeth := s.GetInterfaceByName(ServerInterfaceName)
+ serverVethAddress := serverVeth.Ip4AddressString()
- echoClnContainer := s.getTransientContainerByName("client-app")
- echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer))
+ echoClnContainer := s.GetTransientContainerByName("client-app")
+ echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port
- echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
- o := echoClnContainer.exec(testClientCommand)
- s.log(o)
+ echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+ o := echoClnContainer.Exec(testClientCommand)
+ s.Log(o)
}
-func (s *VethsSuite) TestVclEchoTcp() {
- s.testVclEcho("tcp")
+func VclEchoTcpTest(s *VethsSuite) {
+ testVclEcho(s, "tcp")
}
-func (s *VethsSuite) TestVclEchoUdp() {
- s.testVclEcho("udp")
+func VclEchoUdpTest(s *VethsSuite) {
+ testVclEcho(s, "udp")
}
-// this test takes too long, for now it's being skipped
-func (s *VethsSuite) SkipTestVclRetryAttach() {
- s.testRetryAttach("tcp")
+func VclRetryAttachTest(s *VethsSuite) {
+ testRetryAttach(s, "tcp")
}
-func (s *VethsSuite) testRetryAttach(proto string) {
- srvVppContainer := s.getTransientContainerByName("server-vpp")
+func testRetryAttach(s *VethsSuite, proto string) {
+ srvVppContainer := s.GetTransientContainerByName("server-vpp")
- echoSrvContainer := s.getContainerByName("server-app")
+ echoSrvContainer := s.GetContainerByName("server-app")
- echoSrvContainer.createFile("/vcl.conf", getVclConfig(echoSrvContainer))
+ echoSrvContainer.CreateFile("/vcl.conf", getVclConfig(echoSrvContainer))
- echoSrvContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
- echoSrvContainer.execServer("vcl_test_server -p " + proto + " 12346")
+ echoSrvContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+ echoSrvContainer.ExecServer("vcl_test_server -p " + proto + " 12346")
- 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.")
+ 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.getInterfaceByName(serverInterfaceName)
- serverVethAddress := serverVeth.ip4AddressString()
+ serverVeth := s.GetInterfaceByName(ServerInterfaceName)
+ serverVethAddress := serverVeth.Ip4AddressString()
- echoClnContainer := s.getTransientContainerByName("client-app")
- echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer))
+ echoClnContainer := s.GetTransientContainerByName("client-app")
+ echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346"
- echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
- o := echoClnContainer.exec(testClientCommand)
- s.log(o)
- s.log("... First test ended. Stopping VPP server now.")
+ echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+ o := echoClnContainer.Exec(testClientCommand)
+ s.Log(o)
+ s.Log("... First test ended. Stopping VPP server now.")
// Stop server-vpp-instance, start it again and then run vcl-test-client once more
- srvVppContainer.vppInstance.disconnect()
+ srvVppContainer.VppInstance.Disconnect()
stopVppCommand := "/bin/bash -c 'ps -C vpp_main -o pid= | xargs kill -9'"
- srvVppContainer.exec(stopVppCommand)
+ srvVppContainer.Exec(stopVppCommand)
- s.setupServerVpp()
+ s.SetupServerVpp()
- s.log("... VPP server is starting again, so waiting for a bit.")
+ s.Log("... VPP server is starting again, so waiting for a bit.")
time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen
- s.log("... Running second echo client test, after disconnect and re-attachment.")
- o = echoClnContainer.exec(testClientCommand)
- s.log(o)
- s.log("Done.")
+ s.Log("... Running second echo client test, after disconnect and re-attachment.")
+ o = echoClnContainer.Exec(testClientCommand)
+ s.Log(o)
+ s.Log("Done.")
}