blob: 1906d6b41216a8d086cbdf5c5471a68cbbe473db [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 Ondrejickae7625d02023-02-28 16:55:01 +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 Ondrejickae7625d02023-02-28 16:55:01 +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 Ondrejickae7625d02023-02-28 16:55:01 +010029 clientContainer.getContainerWorkDir())
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010030 err := clnVclConf.
Maros Ondrejickae7625d02023-02-28 16:55:01 +010031 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").
37 append(clientAppSocketApi).close().
38 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 Ondrejickae7625d02023-02-28 16:55:01 +010042 serverContainer.getContainerWorkDir())
Filip Tehlar229f5fc2022-08-09 14:44:47 +000043 err = srvVclConf.
Maros Ondrejickae7625d02023-02-28 16:55:01 +010044 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").
50 append(serverAppSocketApi).close().
51 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 Tehlar4b3598e2023-09-02 08:54:21 +020057 go s.startServerApp(srvCh, stopServerCh, srvEnv)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000058
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 Ondrejickae7625d02023-02-28 16:55:01 +010065 serverVethAddress := s.netInterfaces[serverInterfaceName].ip4AddressString()
Filip Tehlar4b3598e2023-09-02 08:54:21 +020066 go s.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}