aboutsummaryrefslogtreecommitdiffstats
path: root/extras/hs-test/ldp_test.go
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2022-08-09 14:44:47 +0000
committerFlorin Coras <florin.coras@gmail.com>2022-09-19 21:00:18 +0000
commit229f5fcf188cf710f4a8fb269d92f1a1d04a99da (patch)
treebc2c85a49bac6aea4e5ef3304c356acb75ad9493 /extras/hs-test/ldp_test.go
parent6cacc94de3984d9f0cf6d562a27d89a4ab0a89f9 (diff)
misc: add test framework for host stack
Type: feature Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I5a64a2c095cae3a4d5f8fdc73e624b010339ec8e
Diffstat (limited to 'extras/hs-test/ldp_test.go')
-rwxr-xr-xextras/hs-test/ldp_test.go114
1 files changed, 114 insertions, 0 deletions
diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go
new file mode 100755
index 00000000000..0783b189522
--- /dev/null
+++ b/extras/hs-test/ldp_test.go
@@ -0,0 +1,114 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/edwarnicke/exechelper"
+)
+
+func (s *Veths2Suite) TestLDPreloadIperfVpp() {
+ t := s.T()
+ var clnVclConf, srvVclConf Stanza
+
+ srvInstance := "vpp-ldp-srv"
+ clnInstance := "vpp-ldp-cln"
+ srvPath := "/tmp/" + srvInstance
+ clnPath := "/tmp/" + clnInstance
+ srvVcl := srvPath + "/vcl_srv.conf"
+ clnVcl := clnPath + "/vcl_cln.conf"
+
+ exechelper.Run("mkdir " + srvPath)
+ exechelper.Run("mkdir " + clnPath)
+
+ ldpreload := os.Getenv("HST_LDPRELOAD")
+ s.Assert().NotEqual("", ldpreload)
+
+ ldpreload = "LD_PRELOAD=" + ldpreload
+
+ stopServerCh := make(chan struct{}, 1)
+ srvCh := make(chan error, 1)
+ clnCh := make(chan error)
+
+ fmt.Println("starting VPPs")
+
+ err := dockerRun(srvInstance, fmt.Sprintf("-v /tmp/%s:/tmp", srvInstance))
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+ defer func() { exechelper.Run("docker stop " + srvInstance) }()
+
+ err = dockerRun(clnInstance, fmt.Sprintf("-v /tmp/%s:/tmp", clnInstance))
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+ defer func() { exechelper.Run("docker stop " + clnInstance) }()
+
+ _, err = hstExec("2veths srv", srvInstance)
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+
+ _, err = hstExec("2veths cln", clnInstance)
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+
+ err = clnVclConf.
+ NewStanza("vcl").
+ Append("rx-fifo-size 4000000").
+ Append("tx-fifo-size 4000000").
+ Append("app-scope-local").
+ Append("app-scope-global").
+ Append("use-mq-eventfd").
+ Append(fmt.Sprintf("app-socket-api /tmp/%s/2veths/var/run/app_ns_sockets/2", clnInstance)).Close().
+ SaveToFile(clnVcl)
+ if err != nil {
+ t.Errorf("%v", err)
+ t.FailNow()
+ }
+
+ err = srvVclConf.
+ NewStanza("vcl").
+ Append("rx-fifo-size 4000000").
+ Append("tx-fifo-size 4000000").
+ Append("app-scope-local").
+ Append("app-scope-global").
+ Append("use-mq-eventfd").
+ Append(fmt.Sprintf("app-socket-api /tmp/%s/2veths/var/run/app_ns_sockets/1", srvInstance)).Close().
+ SaveToFile(srvVcl)
+ if err != nil {
+ t.Errorf("%v", err)
+ t.FailNow()
+ }
+ fmt.Printf("attaching server to vpp")
+
+ // FIXME
+ time.Sleep(5 * time.Second)
+
+ srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+srvVcl)
+ go StartServerApp(srvCh, stopServerCh, srvEnv)
+
+ err = <-srvCh
+ if err != nil {
+ s.FailNow("vcl server", "%v", err)
+ }
+
+ fmt.Println("attaching client to vpp")
+ clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clnVcl)
+ go StartClientApp(clnEnv, clnCh)
+
+ // wait for client's result
+ err = <-clnCh
+ if err != nil {
+ s.Failf("client", "%v", err)
+ }
+
+ // stop server
+ stopServerCh <- struct{}{}
+}