Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 6 | ) |
| 7 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 8 | func (s *VethsSuite) TestLDPreloadIperfVpp() { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 9 | var clnVclConf, srvVclConf Stanza |
| 10 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 11 | serverContainer := s.getContainerByName("server-vpp") |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 12 | serverVclFileName := serverContainer.getHostWorkDir() + "/vcl_srv.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 13 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 14 | clientContainer := s.getContainerByName("client-vpp") |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 15 | clientVclFileName := clientContainer.getHostWorkDir() + "/vcl_cln.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 16 | |
| 17 | ldpreload := os.Getenv("HST_LDPRELOAD") |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 18 | s.assertNotEqual("", ldpreload) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 19 | |
| 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 Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 26 | s.log("starting VPPs") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 27 | |
Filip Tehlar | 5ebdd51 | 2023-12-14 13:06:54 +0100 | [diff] [blame] | 28 | 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] | 29 | clientContainer.getHostWorkDir()) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 30 | err := clnVclConf. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 31 | 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) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 39 | s.assertNil(err, err) |
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 | 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] | 42 | serverContainer.getHostWorkDir()) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 43 | err = srvVclConf. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [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(serverAppSocketApi).close(). |
| 51 | saveToFile(serverVclFileName) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 52 | s.assertNil(err, err) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 53 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 54 | s.log("attaching server to vpp") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 55 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 56 | srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+serverVclFileName) |
Filip Tehlar | 4b3598e | 2023-09-02 08:54:21 +0200 | [diff] [blame] | 57 | go s.startServerApp(srvCh, stopServerCh, srvEnv) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 58 | |
| 59 | err = <-srvCh |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 60 | s.assertNil(err, err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 61 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 62 | s.log("attaching client to vpp") |
| 63 | var clnRes = make(chan string, 1) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 64 | clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clientVclFileName) |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame^] | 65 | serverVethAddress := s.getInterfaceByName(serverInterfaceName).ip4AddressString() |
Filip Tehlar | 4b3598e | 2023-09-02 08:54:21 +0200 | [diff] [blame] | 66 | go s.startClientApp(serverVethAddress, clnEnv, clnCh, clnRes) |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 67 | s.log(<-clnRes) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 68 | |
| 69 | // wait for client's result |
| 70 | err = <-clnCh |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 71 | s.assertNil(err, err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 72 | |
| 73 | // stop server |
| 74 | stopServerCh <- struct{}{} |
| 75 | } |