diff options
author | 2024-06-14 09:32:39 +0200 | |
---|---|---|
committer | 2024-06-14 18:10:26 +0000 | |
commit | 4677d920c0b0ff1f1aae81fb2f0052d939a2e89c (patch) | |
tree | 9c1adf90f6c1a977b622c1d0211e0e86d1bef985 /extras/hs-test/vcl_test.go | |
parent | 2aa0f0da5dedcf6301c74a39b5e3749359e07e6d (diff) |
hs-test: separate infra from tests
- most functions and vars now start with a capital letter:
needed to access them outside the package that declares
them
- updated README.md
- very minor changes in MAKEFILE
Type: test
Change-Id: I4b5a194f08f09d59e372e57da6451fbb5a1de4da
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/vcl_test.go')
-rw-r--r-- | extras/hs-test/vcl_test.go | 155 |
1 files changed, 78 insertions, 77 deletions
diff --git a/extras/hs-test/vcl_test.go b/extras/hs-test/vcl_test.go index fdcd60ad503..3b413b26bed 100644 --- a/extras/hs-test/vcl_test.go +++ b/extras/hs-test/vcl_test.go @@ -1,12 +1,13 @@ package main import ( + . "fd.io/hs-test/infra" "fmt" "time" ) func init() { - registerVethTests(XEchoVclClientUdpTest, XEchoVclClientTcpTest, XEchoVclServerUdpTest, + RegisterVethTests(XEchoVclClientUdpTest, XEchoVclClientTcpTest, XEchoVclServerUdpTest, XEchoVclServerTcpTest, VclEchoTcpTest, VclEchoUdpTest, VclRetryAttachTest) } @@ -16,141 +17,141 @@ func getVclConfig(c *Container, ns_id_optional ...string) string { 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 XEchoVclClientUdpTest(s *VethsSuite) { - s.testXEchoVclClient("udp") + testXEchoVclClient(s, "udp") } func XEchoVclClientTcpTest(s *VethsSuite) { - s.testXEchoVclClient("tcp") + 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 XEchoVclServerUdpTest(s *VethsSuite) { - s.testXEchoVclServer("udp") + testXEchoVclServer(s, "udp") } func XEchoVclServerTcpTest(s *VethsSuite) { - s.testXEchoVclServer("tcp") + 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 VclEchoTcpTest(s *VethsSuite) { - s.testVclEcho("tcp") + testVclEcho(s, "tcp") } func VclEchoUdpTest(s *VethsSuite) { - s.testVclEcho("udp") + testVclEcho(s, "udp") } func VclRetryAttachTest(s *VethsSuite) { - s.testRetryAttach("tcp") + 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.") } |