blob: 59d31e13890d33c6524b2ab4f5c42554646ce803 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
3import (
4 "fmt"
5 "os"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00006)
7
Maros Ondrejicka11a03e92022-12-01 09:56:37 +01008func (s *VethsSuite) TestLDPreloadIperfVpp() {
Filip Tehlar229f5fc2022-08-09 14:44:47 +00009 var clnVclConf, srvVclConf Stanza
10
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010011 serverContainer := s.getContainerByName("server-vpp")
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010012 serverVclFileName := serverContainer.GetHostWorkDir() + "/vcl_srv.conf"
Filip Tehlar229f5fc2022-08-09 14:44:47 +000013
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010014 clientContainer := s.getContainerByName("client-vpp")
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010015 clientVclFileName := clientContainer.GetHostWorkDir() + "/vcl_cln.conf"
Filip Tehlar229f5fc2022-08-09 14:44:47 +000016
17 ldpreload := os.Getenv("HST_LDPRELOAD")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010018 s.assertNotEqual("", ldpreload)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000019
20 ldpreload = "LD_PRELOAD=" + ldpreload
21
22 stopServerCh := make(chan struct{}, 1)
23 srvCh := make(chan error, 1)
24 clnCh := make(chan error)
25
Maros Ondrejicka87531802022-12-19 20:35:27 +010026 s.log("starting VPPs")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000027
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010028 clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/2",
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010029 clientContainer.GetContainerWorkDir())
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010030 err := clnVclConf.
Filip Tehlar229f5fc2022-08-09 14:44:47 +000031 NewStanza("vcl").
32 Append("rx-fifo-size 4000000").
33 Append("tx-fifo-size 4000000").
34 Append("app-scope-local").
35 Append("app-scope-global").
36 Append("use-mq-eventfd").
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010037 Append(clientAppSocketApi).Close().
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010038 SaveToFile(clientVclFileName)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010039 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000040
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010041 serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/1",
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010042 serverContainer.GetContainerWorkDir())
Filip Tehlar229f5fc2022-08-09 14:44:47 +000043 err = srvVclConf.
44 NewStanza("vcl").
45 Append("rx-fifo-size 4000000").
46 Append("tx-fifo-size 4000000").
47 Append("app-scope-local").
48 Append("app-scope-global").
49 Append("use-mq-eventfd").
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010050 Append(serverAppSocketApi).Close().
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010051 SaveToFile(serverVclFileName)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010052 s.assertNil(err)
53
Maros Ondrejicka87531802022-12-19 20:35:27 +010054 s.log("attaching server to vpp")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000055
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010056 srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+serverVclFileName)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000057 go StartServerApp(srvCh, stopServerCh, srvEnv)
58
59 err = <-srvCh
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010060 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000061
Maros Ondrejicka87531802022-12-19 20:35:27 +010062 s.log("attaching client to vpp")
63 var clnRes = make(chan string, 1)
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010064 clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clientVclFileName)
Maros Ondrejicka7550dd22023-02-07 20:40:27 +010065 serverVethAddress := s.netInterfaces[serverInterfaceName].IP4AddressString()
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010066 go StartClientApp(serverVethAddress, clnEnv, clnCh, clnRes)
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010067 s.log(<-clnRes)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000068
69 // wait for client's result
70 err = <-clnCh
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010071 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000072
73 // stop server
74 stopServerCh <- struct{}{}
75}