blob: 9a8b8121e8a1fa24165d1076f11dde1029a8e904 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
3import (
4 "fmt"
5 "os"
6 "time"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00007)
8
Maros Ondrejicka11a03e92022-12-01 09:56:37 +01009func (s *VethsSuite) TestLDPreloadIperfVpp() {
Filip Tehlar229f5fc2022-08-09 14:44:47 +000010 var clnVclConf, srvVclConf Stanza
11
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010012 serverContainer := s.getContainerByName("server-vpp")
13 serverVolume := serverContainer.getVolumeByHostDir("/tmp/server")
14 srvVcl := serverVolume.containerDir + "/vcl_srv.conf"
Filip Tehlar229f5fc2022-08-09 14:44:47 +000015
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010016 clientContainer := s.getContainerByName("client-vpp")
17 clientVolume := clientContainer.getVolumeByHostDir("/tmp/client")
18 clnVcl := clientVolume.containerDir + "/vcl_cln.conf"
Filip Tehlar229f5fc2022-08-09 14:44:47 +000019
20 ldpreload := os.Getenv("HST_LDPRELOAD")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010021 s.assertNotEqual("", ldpreload)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000022
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 Ondrejickadb823ed2022-12-14 16:30:04 +010031 originalWorkDir := serverContainer.workDir
32 serverContainer.workDir = serverVolume.containerDir
33 _, err := serverContainer.execAction("Configure2Veths srv")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010034 s.assertNil(err)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010035 serverContainer.workDir = originalWorkDir
Filip Tehlar229f5fc2022-08-09 14:44:47 +000036
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010037 originalWorkDir = clientContainer.workDir
38 clientContainer.workDir = clientVolume.containerDir
39 _, err = clientContainer.execAction("Configure2Veths cln")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010040 s.assertNil(err)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010041 clientContainer.workDir = originalWorkDir
Filip Tehlar229f5fc2022-08-09 14:44:47 +000042
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010043 clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/2",
44 clientVolume.containerDir)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000045 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 Ondrejickadb823ed2022-12-14 16:30:04 +010052 Append(clientAppSocketApi).Close().
Filip Tehlar229f5fc2022-08-09 14:44:47 +000053 SaveToFile(clnVcl)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010054 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000055
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010056 serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/1",
57 serverVolume.containerDir)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000058 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 Ondrejickadb823ed2022-12-14 16:30:04 +010065 Append(serverAppSocketApi).Close().
Filip Tehlar229f5fc2022-08-09 14:44:47 +000066 SaveToFile(srvVcl)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010067 s.assertNil(err)
68
Filip Tehlar229f5fc2022-08-09 14:44:47 +000069 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 Ondrejicka98a91e82022-12-06 15:38:05 +010078 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000079
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 Ondrejicka98a91e82022-12-06 15:38:05 +010086 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000087
88 // stop server
89 stopServerCh <- struct{}{}
90}