Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 6 | |
| 7 | . "github.com/onsi/ginkgo/v2" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 8 | ) |
| 9 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 10 | func init() { |
| 11 | registerVethTests(LDPreloadIperfVppTest) |
| 12 | } |
| 13 | |
| 14 | func LDPreloadIperfVppTest(s *VethsSuite) { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 15 | var clnVclConf, srvVclConf Stanza |
| 16 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 17 | serverContainer := s.getContainerByName("server-vpp") |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 18 | serverVclFileName := serverContainer.getHostWorkDir() + "/vcl_srv.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 19 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 20 | clientContainer := s.getContainerByName("client-vpp") |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 21 | clientVclFileName := clientContainer.getHostWorkDir() + "/vcl_cln.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 22 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 23 | ldpreload := "LD_PRELOAD=../../build-root/build-vpp-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 24 | |
| 25 | stopServerCh := make(chan struct{}, 1) |
| 26 | srvCh := make(chan error, 1) |
| 27 | clnCh := make(chan error) |
| 28 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 29 | s.log("starting VPPs") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 30 | |
Filip Tehlar | 5ebdd51 | 2023-12-14 13:06:54 +0100 | [diff] [blame] | 31 | clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default", |
Filip Tehlar | a1bd50c | 2024-01-24 11:59:44 +0100 | [diff] [blame] | 32 | clientContainer.getHostWorkDir()) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 33 | err := clnVclConf. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 34 | newStanza("vcl"). |
| 35 | append("rx-fifo-size 4000000"). |
| 36 | append("tx-fifo-size 4000000"). |
| 37 | append("app-scope-local"). |
| 38 | append("app-scope-global"). |
| 39 | append("use-mq-eventfd"). |
| 40 | append(clientAppSocketApi).close(). |
| 41 | saveToFile(clientVclFileName) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 42 | s.assertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 43 | |
Filip Tehlar | 5ebdd51 | 2023-12-14 13:06:54 +0100 | [diff] [blame] | 44 | serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default", |
Filip Tehlar | a1bd50c | 2024-01-24 11:59:44 +0100 | [diff] [blame] | 45 | serverContainer.getHostWorkDir()) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 46 | err = srvVclConf. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 47 | newStanza("vcl"). |
| 48 | append("rx-fifo-size 4000000"). |
| 49 | append("tx-fifo-size 4000000"). |
| 50 | append("app-scope-local"). |
| 51 | append("app-scope-global"). |
| 52 | append("use-mq-eventfd"). |
| 53 | append(serverAppSocketApi).close(). |
| 54 | saveToFile(serverVclFileName) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 55 | s.assertNil(err, fmt.Sprint(err)) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 56 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 57 | s.log("attaching server to vpp") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 58 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 59 | srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+serverVclFileName) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 60 | go func() { |
| 61 | defer GinkgoRecover() |
| 62 | s.startServerApp(srvCh, stopServerCh, srvEnv) |
| 63 | }() |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 64 | |
| 65 | err = <-srvCh |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 66 | s.assertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 67 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 68 | s.log("attaching client to vpp") |
| 69 | var clnRes = make(chan string, 1) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 70 | clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clientVclFileName) |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 71 | serverVethAddress := s.getInterfaceByName(serverInterfaceName).ip4AddressString() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 72 | go func() { |
| 73 | defer GinkgoRecover() |
| 74 | s.startClientApp(serverVethAddress, clnEnv, clnCh, clnRes) |
| 75 | }() |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 76 | s.log(<-clnRes) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 77 | |
| 78 | // wait for client's result |
| 79 | err = <-clnCh |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 80 | s.assertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 81 | |
| 82 | // stop server |
| 83 | stopServerCh <- struct{}{} |
| 84 | } |