blob: 8d9168d3d5d9e8026839ac1824182ee8cea715a0 [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
Filip Tehlar5ebdd512023-12-14 13:06:54 +010028 clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default",
Filip Tehlara1bd50c2024-01-24 11:59:44 +010029 clientContainer.getHostWorkDir())
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)
adrianvillin7c675472024-02-12 02:44:53 -050039 s.assertNil(err, err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000040
Filip Tehlar5ebdd512023-12-14 13:06:54 +010041 serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default",
Filip Tehlara1bd50c2024-01-24 11:59:44 +010042 serverContainer.getHostWorkDir())
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)
adrianvillin7c675472024-02-12 02:44:53 -050052 s.assertNil(err, err)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010053
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
adrianvillin7c675472024-02-12 02:44:53 -050060 s.assertNil(err, 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)
adrianvillin28bd8f02024-02-13 06:00:02 -050065 serverVethAddress := s.getInterfaceByName(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
adrianvillin7c675472024-02-12 02:44:53 -050071 s.assertNil(err, err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000072
73 // stop server
74 stopServerCh <- struct{}{}
75}