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