blob: 2dfdf8b44401f0da3b1d88e7eb9dc89b7e7e24b5 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
3import (
4 "fmt"
5 "os"
6 "time"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00007)
8
Maros Ondrejicka11a03e92022-12-01 09:56:37 +01009func (s *VethsSuite) TestLDPreloadIperfVpp() {
Filip Tehlar229f5fc2022-08-09 14:44:47 +000010 var clnVclConf, srvVclConf Stanza
11
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010012 serverContainer := s.getContainerByName("server-vpp")
13 serverVolume := serverContainer.getVolumeByHostDir("/tmp/server")
14 srvVcl := serverVolume.containerDir + "/vcl_srv.conf"
Filip Tehlar229f5fc2022-08-09 14:44:47 +000015
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010016 clientContainer := s.getContainerByName("client-vpp")
17 clientVolume := clientContainer.getVolumeByHostDir("/tmp/client")
18 clnVcl := clientVolume.containerDir + "/vcl_cln.conf"
Filip Tehlar229f5fc2022-08-09 14:44:47 +000019
20 ldpreload := os.Getenv("HST_LDPRELOAD")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010021 s.assertNotEqual("", ldpreload)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000022
23 ldpreload = "LD_PRELOAD=" + ldpreload
24
25 stopServerCh := make(chan struct{}, 1)
26 srvCh := make(chan error, 1)
27 clnCh := make(chan error)
28
Maros Ondrejicka87531802022-12-19 20:35:27 +010029 s.log("starting VPPs")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000030
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010031 originalWorkDir := serverContainer.workDir
32 serverContainer.workDir = serverVolume.containerDir
33 _, err := serverContainer.execAction("Configure2Veths srv")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010034 s.assertNil(err)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010035 serverContainer.workDir = originalWorkDir
Filip Tehlar229f5fc2022-08-09 14:44:47 +000036
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010037 originalWorkDir = clientContainer.workDir
38 clientContainer.workDir = clientVolume.containerDir
39 _, err = clientContainer.execAction("Configure2Veths cln")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010040 s.assertNil(err)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010041 clientContainer.workDir = originalWorkDir
Filip Tehlar229f5fc2022-08-09 14:44:47 +000042
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010043 clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/2",
44 clientVolume.containerDir)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000045 err = clnVclConf.
46 NewStanza("vcl").
47 Append("rx-fifo-size 4000000").
48 Append("tx-fifo-size 4000000").
49 Append("app-scope-local").
50 Append("app-scope-global").
51 Append("use-mq-eventfd").
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010052 Append(clientAppSocketApi).Close().
Filip Tehlar229f5fc2022-08-09 14:44:47 +000053 SaveToFile(clnVcl)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010054 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000055
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010056 serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/1",
57 serverVolume.containerDir)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000058 err = srvVclConf.
59 NewStanza("vcl").
60 Append("rx-fifo-size 4000000").
61 Append("tx-fifo-size 4000000").
62 Append("app-scope-local").
63 Append("app-scope-global").
64 Append("use-mq-eventfd").
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010065 Append(serverAppSocketApi).Close().
Filip Tehlar229f5fc2022-08-09 14:44:47 +000066 SaveToFile(srvVcl)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010067 s.assertNil(err)
68
Maros Ondrejicka87531802022-12-19 20:35:27 +010069 s.log("attaching server to vpp")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000070
71 // FIXME
72 time.Sleep(5 * time.Second)
73
74 srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+srvVcl)
75 go StartServerApp(srvCh, stopServerCh, srvEnv)
76
77 err = <-srvCh
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010078 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000079
Maros Ondrejicka87531802022-12-19 20:35:27 +010080 s.log("attaching client to vpp")
81 var clnRes = make(chan string, 1)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000082 clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clnVcl)
Maros Ondrejicka87531802022-12-19 20:35:27 +010083 go StartClientApp(clnEnv, clnCh, clnRes)
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010084 s.log(<-clnRes)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000085
86 // wait for client's result
87 err = <-clnCh
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010088 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000089
90 // stop server
91 stopServerCh <- struct{}{}
92}