2022-08-09 14:44:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) TestLDPreloadIperfVpp() {
|
2022-08-09 14:44:47 +00:00
|
|
|
var clnVclConf, srvVclConf Stanza
|
|
|
|
|
2022-12-14 16:30:04 +01:00
|
|
|
serverContainer := s.getContainerByName("server-vpp")
|
2023-02-02 08:58:04 +01:00
|
|
|
serverVclFileName := serverContainer.GetHostWorkDir() + "/vcl_srv.conf"
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2022-12-14 16:30:04 +01:00
|
|
|
clientContainer := s.getContainerByName("client-vpp")
|
2023-02-02 08:58:04 +01:00
|
|
|
clientVclFileName := clientContainer.GetHostWorkDir() + "/vcl_cln.conf"
|
2022-08-09 14:44:47 +00:00
|
|
|
|
|
|
|
ldpreload := os.Getenv("HST_LDPRELOAD")
|
2022-12-06 15:38:05 +01:00
|
|
|
s.assertNotEqual("", ldpreload)
|
2022-08-09 14:44:47 +00:00
|
|
|
|
|
|
|
ldpreload = "LD_PRELOAD=" + ldpreload
|
|
|
|
|
|
|
|
stopServerCh := make(chan struct{}, 1)
|
|
|
|
srvCh := make(chan error, 1)
|
|
|
|
clnCh := make(chan error)
|
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("starting VPPs")
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2022-12-14 16:30:04 +01:00
|
|
|
clientAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/2",
|
2023-01-26 10:07:29 +01:00
|
|
|
clientContainer.GetContainerWorkDir())
|
2023-02-02 08:58:04 +01:00
|
|
|
err := clnVclConf.
|
2022-08-09 14:44:47 +00:00
|
|
|
NewStanza("vcl").
|
|
|
|
Append("rx-fifo-size 4000000").
|
|
|
|
Append("tx-fifo-size 4000000").
|
|
|
|
Append("app-scope-local").
|
|
|
|
Append("app-scope-global").
|
|
|
|
Append("use-mq-eventfd").
|
2022-12-14 16:30:04 +01:00
|
|
|
Append(clientAppSocketApi).Close().
|
2023-02-02 08:58:04 +01:00
|
|
|
SaveToFile(clientVclFileName)
|
2022-12-06 15:38:05 +01:00
|
|
|
s.assertNil(err)
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2022-12-14 16:30:04 +01:00
|
|
|
serverAppSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/1",
|
2023-01-26 10:07:29 +01:00
|
|
|
serverContainer.GetContainerWorkDir())
|
2022-08-09 14:44:47 +00:00
|
|
|
err = srvVclConf.
|
|
|
|
NewStanza("vcl").
|
|
|
|
Append("rx-fifo-size 4000000").
|
|
|
|
Append("tx-fifo-size 4000000").
|
|
|
|
Append("app-scope-local").
|
|
|
|
Append("app-scope-global").
|
|
|
|
Append("use-mq-eventfd").
|
2022-12-14 16:30:04 +01:00
|
|
|
Append(serverAppSocketApi).Close().
|
2023-02-02 08:58:04 +01:00
|
|
|
SaveToFile(serverVclFileName)
|
2022-12-06 15:38:05 +01:00
|
|
|
s.assertNil(err)
|
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("attaching server to vpp")
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2023-02-02 08:58:04 +01:00
|
|
|
srvEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+serverVclFileName)
|
2022-08-09 14:44:47 +00:00
|
|
|
go StartServerApp(srvCh, stopServerCh, srvEnv)
|
|
|
|
|
|
|
|
err = <-srvCh
|
2022-12-06 15:38:05 +01:00
|
|
|
s.assertNil(err)
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("attaching client to vpp")
|
|
|
|
var clnRes = make(chan string, 1)
|
2023-02-02 08:58:04 +01:00
|
|
|
clnEnv := append(os.Environ(), ldpreload, "VCL_CONFIG="+clientVclFileName)
|
2023-02-07 20:40:27 +01:00
|
|
|
serverVethAddress := s.netInterfaces[serverInterfaceName].IP4AddressString()
|
2023-02-02 08:58:04 +01:00
|
|
|
go StartClientApp(serverVethAddress, clnEnv, clnCh, clnRes)
|
2023-01-09 12:07:09 +01:00
|
|
|
s.log(<-clnRes)
|
2022-08-09 14:44:47 +00:00
|
|
|
|
|
|
|
// wait for client's result
|
|
|
|
err = <-clnCh
|
2022-12-06 15:38:05 +01:00
|
|
|
s.assertNil(err)
|
2022-08-09 14:44:47 +00:00
|
|
|
|
|
|
|
// stop server
|
|
|
|
stopServerCh <- struct{}{}
|
|
|
|
}
|