Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | "time" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 7 | ) |
| 8 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 9 | func (s *VethsSuite) TestLDPreloadIperfVpp() { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 10 | var clnVclConf, srvVclConf Stanza |
| 11 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 12 | serverContainer := s.getContainerByName("server-vpp") |
| 13 | serverVolume := serverContainer.getVolumeByHostDir("/tmp/server") |
| 14 | srvVcl := serverVolume.containerDir + "/vcl_srv.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 15 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 16 | clientContainer := s.getContainerByName("client-vpp") |
| 17 | clientVolume := clientContainer.getVolumeByHostDir("/tmp/client") |
| 18 | clnVcl := clientVolume.containerDir + "/vcl_cln.conf" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 19 | |
| 20 | ldpreload := os.Getenv("HST_LDPRELOAD") |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 21 | s.assertNotEqual("", ldpreload) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 22 | |
| 23 | ldpreload = "LD_PRELOAD=" + ldpreload |
| 24 | |
| 25 | stopServerCh := make(chan struct{}, 1) |
| 26 | srvCh := make(chan error, 1) |
| 27 | clnCh := make(chan error) |
| 28 | |
| 29 | fmt.Println("starting VPPs") |
| 30 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 31 | originalWorkDir := serverContainer.workDir |
| 32 | serverContainer.workDir = serverVolume.containerDir |
| 33 | _, err := serverContainer.execAction("Configure2Veths srv") |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 34 | s.assertNil(err) |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 35 | serverContainer.workDir = originalWorkDir |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 36 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 37 | originalWorkDir = clientContainer.workDir |
| 38 | clientContainer.workDir = clientVolume.containerDir |
| 39 | _, err = clientContainer.execAction("Configure2Veths cln") |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 40 | s.assertNil(err) |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 41 | clientContainer.workDir = originalWorkDir |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 42 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 43 | clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/2", |
| 44 | clientVolume.containerDir) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 45 | err = clnVclConf. |
| 46 | NewStanza("vcl"). |
| 47 | Append("rx-fifo-size 4000000"). |
| 48 | Append("tx-fifo-size 4000000"). |
| 49 | Append("app-scope-local"). |
| 50 | Append("app-scope-global"). |
| 51 | Append("use-mq-eventfd"). |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 52 | Append(clientAppSocketApi).Close(). |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 53 | SaveToFile(clnVcl) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 54 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 55 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 56 | serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/1", |
| 57 | serverVolume.containerDir) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 58 | err = srvVclConf. |
| 59 | NewStanza("vcl"). |
| 60 | Append("rx-fifo-size 4000000"). |
| 61 | Append("tx-fifo-size 4000000"). |
| 62 | Append("app-scope-local"). |
| 63 | Append("app-scope-global"). |
| 64 | Append("use-mq-eventfd"). |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame^] | 65 | Append(serverAppSocketApi).Close(). |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 66 | SaveToFile(srvVcl) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 67 | s.assertNil(err) |
| 68 | |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 69 | fmt.Printf("attaching server to vpp") |
| 70 | |
| 71 | // FIXME |
| 72 | time.Sleep(5 * time.Second) |
| 73 | |
| 74 | srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+srvVcl) |
| 75 | go StartServerApp(srvCh, stopServerCh, srvEnv) |
| 76 | |
| 77 | err = <-srvCh |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 78 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 79 | |
| 80 | fmt.Println("attaching client to vpp") |
| 81 | clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clnVcl) |
| 82 | go StartClientApp(clnEnv, clnCh) |
| 83 | |
| 84 | // wait for client's result |
| 85 | err = <-clnCh |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 86 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 87 | |
| 88 | // stop server |
| 89 | stopServerCh <- struct{}{} |
| 90 | } |