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 | 2908f8c | 2023-02-02 08:58:04 +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 | 2908f8c | 2023-02-02 08:58:04 +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 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 28 | clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/2", |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 29 | clientContainer.GetContainerWorkDir()) |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 30 | err := clnVclConf. |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [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"). |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 37 | Append(clientAppSocketApi).Close(). |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 38 | SaveToFile(clientVclFileName) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 39 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 40 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 41 | serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/1", |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 42 | serverContainer.GetContainerWorkDir()) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 43 | err = srvVclConf. |
| 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"). |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 50 | Append(serverAppSocketApi).Close(). |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 51 | SaveToFile(serverVclFileName) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 52 | s.assertNil(err) |
| 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 | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 57 | go StartServerApp(srvCh, stopServerCh, srvEnv) |
| 58 | |
| 59 | err = <-srvCh |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 60 | s.assertNil(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) |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 65 | serverVethAddress := s.netInterfaces[serverInterfaceName].IP4AddressString() |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 66 | go 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 |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 71 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 72 | |
| 73 | // stop server |
| 74 | stopServerCh <- struct{}{} |
| 75 | } |