summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/vcl_test.go
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2023-12-14 13:06:54 +0100
committerFilip Tehlar <ftehlar@cisco.com>2023-12-15 13:38:31 +0100
commit5ebdd51c605fd64875e682ce7eab69ebda1518eb (patch)
tree53a7c9821475912d20e4c3f34a78f71aa486293c /extras/hs-test/vcl_test.go
parentc6fe6174908d9a045a7c4f055a9f60f233618e87 (diff)
hs-test: remove unnecessary app ns configs
Type: test Change-Id: I0226227dc756a5a3af5e9d3b0d65a38c0aa55b3d Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'extras/hs-test/vcl_test.go')
-rw-r--r--extras/hs-test/vcl_test.go42
1 files changed, 22 insertions, 20 deletions
diff --git a/extras/hs-test/vcl_test.go b/extras/hs-test/vcl_test.go
index a5983c6fa4d..a949565f299 100644
--- a/extras/hs-test/vcl_test.go
+++ b/extras/hs-test/vcl_test.go
@@ -5,15 +5,23 @@ import (
"time"
)
-const vclTemplate = `vcl {
- app-socket-api %[1]s/var/run/app_ns_sockets/%[2]s
- app-scope-global
- app-scope-local
- namespace-id %[2]s
- namespace-secret %[2]s
- use-mq-eventfd
+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")
+ 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))
+ }
+ return s.close().toString()
}
-`
func (s *VethsSuite) TestXEchoVclClientUdp() {
s.testXEchoVclClient("udp")
@@ -31,8 +39,7 @@ func (s *VethsSuite) testXEchoVclClient(proto string) {
serverVpp.vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, serverVeth.ip4AddressString(), port)
echoClnContainer := s.getTransientContainerByName("client-app")
- clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
- echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
+ echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer))
testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + serverVeth.ip4AddressString() + " " + port
s.log(testClientCommand)
@@ -55,8 +62,7 @@ func (s *VethsSuite) testXEchoVclServer(proto string) {
srvVppCont := s.getContainerByName("server-vpp")
srvAppCont := s.getContainerByName("server-app")
- serverVclConfContent := fmt.Sprintf(vclTemplate, srvVppCont.getContainerWorkDir(), "1")
- srvAppCont.createFile("/vcl.conf", serverVclConfContent)
+ 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)
@@ -75,8 +81,7 @@ func (s *VethsSuite) testVclEcho(proto string) {
srvVppCont := s.getContainerByName("server-vpp")
srvAppCont := s.getContainerByName("server-app")
- serverVclConfContent := fmt.Sprintf(vclTemplate, srvVppCont.getContainerWorkDir(), "1")
- srvAppCont.createFile("/vcl.conf", serverVclConfContent)
+ srvAppCont.createFile("/vcl.conf", getVclConfig(srvVppCont))
srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf")
srvAppCont.execServer("vcl_test_server " + port)
@@ -84,8 +89,7 @@ func (s *VethsSuite) testVclEcho(proto string) {
serverVethAddress := serverVeth.ip4AddressString()
echoClnContainer := s.getTransientContainerByName("client-app")
- clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
- echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
+ echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer))
testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port
echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
@@ -111,8 +115,7 @@ func (s *VethsSuite) testRetryAttach(proto string) {
echoSrvContainer := s.getContainerByName("server-app")
- serverVclConfContent := fmt.Sprintf(vclTemplate, echoSrvContainer.getContainerWorkDir(), "1")
- echoSrvContainer.createFile("/vcl.conf", serverVclConfContent)
+ echoSrvContainer.createFile("/vcl.conf", getVclConfig(echoSrvContainer))
echoSrvContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
echoSrvContainer.execServer("vcl_test_server -p " + proto + " 12346")
@@ -124,8 +127,7 @@ func (s *VethsSuite) testRetryAttach(proto string) {
serverVethAddress := serverVeth.ip4AddressString()
echoClnContainer := s.getTransientContainerByName("client-app")
- clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
- echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
+ echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer))
testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346"
echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")