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 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 7 | . "fd.io/hs-test/infra" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 8 | . "github.com/onsi/ginkgo/v2" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 9 | ) |
| 10 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 11 | func init() { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 12 | RegisterVethTests(LDPreloadIperfVppTest) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | func LDPreloadIperfVppTest(s *VethsSuite) { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 16 | var clnVclConf, srvVclConf Stanza |
Adrian Villin | b4516bb | 2024-06-19 06:20:00 -0400 | [diff] [blame] | 17 | var ldpreload string |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 18 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 19 | serverContainer := s.GetContainerByName("server-vpp") |
| 20 | serverVclFileName := serverContainer.GetHostWorkDir() + "/vcl_srv.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 21 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 22 | clientContainer := s.GetContainerByName("client-vpp") |
| 23 | clientVclFileName := clientContainer.GetHostWorkDir() + "/vcl_cln.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 24 | |
Adrian Villin | b4516bb | 2024-06-19 06:20:00 -0400 | [diff] [blame] | 25 | if *IsDebugBuild { |
| 26 | ldpreload = "LD_PRELOAD=../../build-root/build-vpp_debug-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so" |
| 27 | } else { |
| 28 | ldpreload = "LD_PRELOAD=../../build-root/build-vpp-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so" |
| 29 | } |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 30 | |
| 31 | stopServerCh := make(chan struct{}, 1) |
| 32 | srvCh := make(chan error, 1) |
| 33 | clnCh := make(chan error) |
| 34 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 35 | s.Log("starting VPPs") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 36 | |
Filip Tehlar | 5ebdd51 | 2023-12-14 13:06:54 +0100 | [diff] [blame] | 37 | clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default", |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 38 | clientContainer.GetHostWorkDir()) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 39 | err := clnVclConf. |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 40 | NewStanza("vcl"). |
| 41 | Append("rx-fifo-size 4000000"). |
| 42 | Append("tx-fifo-size 4000000"). |
| 43 | Append("app-scope-local"). |
| 44 | Append("app-scope-global"). |
| 45 | Append("use-mq-eventfd"). |
| 46 | Append(clientAppSocketApi).Close(). |
| 47 | SaveToFile(clientVclFileName) |
| 48 | s.AssertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 49 | |
Filip Tehlar | 5ebdd51 | 2023-12-14 13:06:54 +0100 | [diff] [blame] | 50 | serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default", |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 51 | serverContainer.GetHostWorkDir()) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 52 | err = srvVclConf. |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 53 | NewStanza("vcl"). |
| 54 | Append("rx-fifo-size 4000000"). |
| 55 | Append("tx-fifo-size 4000000"). |
| 56 | Append("app-scope-local"). |
| 57 | Append("app-scope-global"). |
| 58 | Append("use-mq-eventfd"). |
| 59 | Append(serverAppSocketApi).Close(). |
| 60 | SaveToFile(serverVclFileName) |
| 61 | s.AssertNil(err, fmt.Sprint(err)) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 62 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 63 | s.Log("attaching server to vpp") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 64 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 65 | srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+serverVclFileName) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 66 | go func() { |
| 67 | defer GinkgoRecover() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 68 | s.StartServerApp(srvCh, stopServerCh, srvEnv) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 69 | }() |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 70 | |
| 71 | err = <-srvCh |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 72 | s.AssertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 73 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 74 | s.Log("attaching client to vpp") |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 75 | var clnRes = make(chan string, 1) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 76 | clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clientVclFileName) |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 77 | serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 78 | go func() { |
| 79 | defer GinkgoRecover() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 80 | s.StartClientApp(serverVethAddress, clnEnv, clnCh, clnRes) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 81 | }() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 82 | s.Log(<-clnRes) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 83 | |
| 84 | // wait for client's result |
| 85 | err = <-clnCh |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 86 | s.AssertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 87 | |
| 88 | // stop server |
| 89 | stopServerCh <- struct{}{} |
| 90 | } |