hs-test: replaced container/interface getter func

- replaced s.GetContainerByName("xyz") with s.Containers.Xyz in tests
  and suites
- same thing for interfaces
- each suite has its own structs with containers/interfaces
- structs are initialized in SetupSuite

Type: test

Change-Id: I5bd99605b40921b7b8c844e8650f6fb0915e9e99
Signed-off-by: Adrian Villin <avillin@cisco.com>
This commit is contained in:
Adrian Villin 2024-12-09 14:18:31 +01:00 committed by Florin Coras
parent fb8f51697c
commit af5fcbfa71
22 changed files with 378 additions and 374 deletions

View File

@ -11,7 +11,7 @@ func init() {
// TODO: Add more CPU configuration tests
func DefaultCpuConfigurationTest(s *CpuPinningSuite) {
vpp := s.GetContainerByName(SingleTopoContainerVpp).VppInstance
vpp := s.Containers.Vpp.VppInstance
s.AssertNil(vpp.Start())
}
@ -23,7 +23,7 @@ func SkipCoresTest(s *CpuPinningSuite) {
SkipCores: 1,
}
vpp := s.GetContainerByName(SingleTopoContainerVpp).VppInstance
vpp := s.Containers.Vpp.VppInstance
vpp.CpuConfig = skipCoresConfiguration
s.AssertNil(vpp.Start())

View File

@ -10,17 +10,16 @@ func init() {
}
func EchoBuiltinTest(s *VethsSuite) {
serverVpp := s.GetContainerByName("server-vpp").VppInstance
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
serverVpp := s.Containers.ServerVpp.VppInstance
serverVpp.Vppctl("test echo server " +
" uri tcp://" + serverVeth.Ip4AddressString() + "/1234")
" uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/1234")
clientVpp := s.GetContainerByName("client-vpp").VppInstance
clientVpp := s.Containers.ClientVpp.VppInstance
o := clientVpp.Vppctl("test echo client nclients 100 bytes 1 verbose" +
" syn-timeout 100 test-timeout 100" +
" uri tcp://" + serverVeth.Ip4AddressString() + "/1234")
" uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/1234")
s.Log(o)
s.AssertNotContains(o, "failed:")
}
@ -28,28 +27,26 @@ func EchoBuiltinTest(s *VethsSuite) {
// unstable with multiple workers
func TcpWithLossTest(s *VethsSuite) {
s.SkipIfMultiWorker()
serverVpp := s.GetContainerByName("server-vpp").VppInstance
serverVpp := s.Containers.ServerVpp.VppInstance
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
serverVpp.Vppctl("test echo server uri tcp://%s/20022",
serverVeth.Ip4AddressString())
s.Interfaces.Server.Ip4AddressString())
clientVpp := s.GetContainerByName("client-vpp").VppInstance
clientVpp := s.Containers.ClientVpp.VppInstance
// Ensure that VPP doesn't abort itself with NSIM enabled
// Warning: Removing this ping will make VPP crash!
clientVpp.Vppctl("ping %s", serverVeth.Ip4AddressString())
clientVpp.Vppctl("ping %s", s.Interfaces.Server.Ip4AddressString())
// Add loss of packets with Network Delay Simulator
clientVpp.Vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" +
" packet-size 1400 packets-per-drop 1000")
name := s.GetInterfaceByName(ClientInterfaceName).Name()
clientVpp.Vppctl("nsim output-feature enable-disable host-" + name)
clientVpp.Vppctl("nsim output-feature enable-disable host-" + s.Interfaces.Server.Name())
// Do echo test from client-vpp container
output := clientVpp.Vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes mbytes 50",
serverVeth.Ip4AddressString())
s.Interfaces.Server.Ip4AddressString())
s.Log(output)
s.AssertNotEqual(len(output), 0)
s.AssertNotContains(output, "failed", output)

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ var NumaAwareCpuAlloc bool
var TestTimeout time.Duration
type HstSuite struct {
Containers map[string]*Container
AllContainers map[string]*Container
StartedContainers []*Container
Volumes []string
NetConfigs []NetConfig
@ -240,7 +240,7 @@ func (s *HstSuite) SetupTest() {
}
func (s *HstSuite) SetupContainers() {
for _, container := range s.Containers {
for _, container := range s.AllContainers {
if !container.IsOptional {
container.Run()
}
@ -527,7 +527,7 @@ func (s *HstSuite) GetInterfaceByName(name string) *NetInterface {
}
func (s *HstSuite) GetContainerByName(name string) *Container {
return s.Containers[s.ProcessIndex+name+s.Ppid]
return s.AllContainers[s.ProcessIndex+name+s.Ppid]
}
/*
@ -535,7 +535,7 @@ func (s *HstSuite) GetContainerByName(name string) *Container {
* are not able to modify the original container and affect other tests by doing that
*/
func (s *HstSuite) GetTransientContainerByName(name string) *Container {
containerCopy := *s.Containers[s.ProcessIndex+name+s.Ppid]
containerCopy := *s.AllContainers[s.ProcessIndex+name+s.Ppid]
return &containerCopy
}
@ -559,7 +559,7 @@ func (s *HstSuite) LoadContainerTopology(topologyName string) {
s.Volumes = append(s.Volumes, hostDir)
}
s.Containers = make(map[string]*Container)
s.AllContainers = make(map[string]*Container)
for _, elem := range yamlTopo.Containers {
newContainer, err := newContainer(s, elem)
newContainer.Suite = s
@ -567,12 +567,12 @@ func (s *HstSuite) LoadContainerTopology(topologyName string) {
if err != nil {
Fail("container config error: " + fmt.Sprint(err))
}
s.Containers[newContainer.Name] = newContainer
s.AllContainers[newContainer.Name] = newContainer
}
if *DryRun {
s.Log(Colors.pur + "* Containers used by this suite (some might already be running):" + Colors.rst)
for name := range s.Containers {
for name := range s.AllContainers {
s.Log("%sdocker start %s && docker exec -it %s bash%s", Colors.pur, name, name, Colors.rst)
}
}

View File

@ -15,6 +15,12 @@ var cpuPinningSoloTests = map[string][]func(s *CpuPinningSuite){}
type CpuPinningSuite struct {
HstSuite
previousMaxContainerCount int
Interfaces struct {
Tap *NetInterface
}
Containers struct {
Vpp *Container
}
}
func RegisterCpuPinningTests(tests ...func(s *CpuPinningSuite)) {
@ -29,6 +35,8 @@ func (s *CpuPinningSuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.LoadNetworkTopology("tap")
s.LoadContainerTopology("singleCpuPinning")
s.Interfaces.Tap = s.GetInterfaceByName("htaphost")
s.Containers.Vpp = s.GetContainerByName("vpp")
}
func (s *CpuPinningSuite) SetupTest() {
@ -39,8 +47,7 @@ func (s *CpuPinningSuite) SetupTest() {
s.SkipIfNotEnoughAvailableCpus()
s.HstSuite.SetupTest()
container := s.GetContainerByName(SingleTopoContainerVpp)
vpp, err := container.newVppInstance(container.AllocatedCpus)
vpp, err := s.Containers.Vpp.newVppInstance(s.Containers.Vpp.AllocatedCpus)
s.AssertNotNil(vpp, fmt.Sprint(err))
if *DryRun {

View File

@ -15,16 +15,21 @@ import (
. "github.com/onsi/ginkgo/v2"
)
const (
VppContainerName = "vpp"
EnvoyProxyContainerName = "envoy-vcl"
)
type EnvoyProxySuite struct {
HstSuite
nginxPort uint16
proxyPort uint16
maxTimeout int
Interfaces struct {
Server *NetInterface
Client *NetInterface
}
Containers struct {
EnvoyProxy *Container
NginxServerTransient *Container
Vpp *Container
Curl *Container
}
}
var envoyProxyTests = map[string][]func(s *EnvoyProxySuite){}
@ -48,6 +53,12 @@ func (s *EnvoyProxySuite) SetupSuite() {
} else {
s.maxTimeout = 60
}
s.Interfaces.Client = s.GetInterfaceByName("hstcln")
s.Interfaces.Server = s.GetInterfaceByName("hstsrv")
s.Containers.NginxServerTransient = s.GetTransientContainerByName("nginx-server")
s.Containers.Vpp = s.GetContainerByName("vpp")
s.Containers.EnvoyProxy = s.GetContainerByName("envoy-vcl")
s.Containers.Curl = s.GetContainerByName("curl")
}
func (s *EnvoyProxySuite) SetupTest() {
@ -62,15 +73,11 @@ func (s *EnvoyProxySuite) SetupTest() {
Append("evt_qs_memfd_seg").
Append("event-queue-length 100000")
vppContainer := s.GetContainerByName(VppContainerName)
vpp, err := vppContainer.newVppInstance(vppContainer.AllocatedCpus, sessionConfig)
vpp, err := s.Containers.Vpp.newVppInstance(s.Containers.Vpp.AllocatedCpus, sessionConfig)
s.AssertNotNil(vpp, fmt.Sprint(err))
clientInterface := s.GetInterfaceByName(ClientTapInterfaceName)
serverInterface := s.GetInterfaceByName(ServerTapInterfaceName)
// nginx HTTP server
nginxContainer := s.GetTransientContainerByName(NginxServerContainerName)
s.AssertNil(nginxContainer.Create())
s.AssertNil(s.Containers.NginxServerTransient.Create())
s.nginxPort = 80
nginxSettings := struct {
LogPrefix string
@ -78,20 +85,19 @@ func (s *EnvoyProxySuite) SetupTest() {
Port uint16
Timeout int
}{
LogPrefix: nginxContainer.Name,
Address: serverInterface.Ip4AddressString(),
LogPrefix: s.Containers.NginxServerTransient.Name,
Address: s.Interfaces.Server.Ip4AddressString(),
Port: s.nginxPort,
Timeout: s.maxTimeout,
}
nginxContainer.CreateConfigFromTemplate(
s.Containers.NginxServerTransient.CreateConfigFromTemplate(
"/nginx.conf",
"./resources/nginx/nginx_server.conf",
nginxSettings,
)
// Envoy
envoyContainer := s.GetContainerByName(EnvoyProxyContainerName)
s.AssertNil(envoyContainer.Create())
s.AssertNil(s.Containers.EnvoyProxy.Create())
s.proxyPort = 8080
envoySettings := struct {
@ -100,12 +106,12 @@ func (s *EnvoyProxySuite) SetupTest() {
ServerPort uint16
ProxyPort uint16
}{
LogPrefix: envoyContainer.Name,
ServerAddress: serverInterface.Ip4AddressString(),
LogPrefix: s.Containers.EnvoyProxy.Name,
ServerAddress: s.Interfaces.Server.Ip4AddressString(),
ServerPort: s.nginxPort,
ProxyPort: s.proxyPort,
}
envoyContainer.CreateConfigFromTemplate(
s.Containers.EnvoyProxy.CreateConfigFromTemplate(
"/etc/envoy/envoy.yaml",
"resources/envoy/proxy.yaml",
envoySettings,
@ -114,15 +120,15 @@ func (s *EnvoyProxySuite) SetupTest() {
s.AssertNil(vpp.Start())
// wait for VPP to start
time.Sleep(time.Second * 1)
s.AssertNil(vpp.CreateTap(clientInterface, 1, 1))
s.AssertNil(vpp.CreateTap(serverInterface, 1, 2))
vppContainer.Exec(false, "chmod 777 -R %s", vppContainer.GetContainerWorkDir())
s.AssertNil(vpp.CreateTap(s.Interfaces.Client, 1, 1))
s.AssertNil(vpp.CreateTap(s.Interfaces.Server, 1, 2))
s.Containers.Vpp.Exec(false, "chmod 777 -R %s", s.Containers.Vpp.GetContainerWorkDir())
// Add Ipv4 ARP entry for nginx HTTP server, otherwise first request fail (HTTP error 503)
arp := fmt.Sprintf("set ip neighbor %s %s %s",
serverInterface.Peer.Name(),
serverInterface.Ip4AddressString(),
serverInterface.HwAddress)
s.Interfaces.Server.Peer.Name(),
s.Interfaces.Server.Ip4AddressString(),
s.Interfaces.Server.HwAddress)
if *DryRun {
vpp.AppendToCliConfig(arp)
@ -131,15 +137,15 @@ func (s *EnvoyProxySuite) SetupTest() {
s.Skip("Dry run mode = true")
}
vppContainer.VppInstance.Vppctl(arp)
s.AssertNil(nginxContainer.Start())
s.AssertNil(envoyContainer.Start())
s.Containers.Vpp.VppInstance.Vppctl(arp)
s.AssertNil(s.Containers.NginxServerTransient.Start())
s.AssertNil(s.Containers.EnvoyProxy.Start())
}
func (s *EnvoyProxySuite) TearDownTest() {
if CurrentSpecReport().Failed() {
s.CollectNginxLogs(NginxServerContainerName)
s.CollectEnvoyLogs(EnvoyProxyContainerName)
s.CollectNginxLogs(s.Containers.NginxServerTransient)
s.CollectEnvoyLogs(s.Containers.EnvoyProxy)
}
s.HstSuite.TearDownTest()
}
@ -149,12 +155,12 @@ func (s *EnvoyProxySuite) ProxyPort() uint16 {
}
func (s *EnvoyProxySuite) ProxyAddr() string {
return s.GetInterfaceByName(ClientTapInterfaceName).Peer.Ip4AddressString()
return s.Interfaces.Client.Peer.Ip4AddressString()
}
func (s *EnvoyProxySuite) CurlDownloadResource(uri string) {
args := fmt.Sprintf("-w @/tmp/write_out_download --max-time %d --insecure --noproxy '*' --remote-name --output-dir /tmp %s", s.maxTimeout, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "GET response code: 200")
s.AssertNotContains(log, "bytes remaining to read")
s.AssertNotContains(log, "Operation timed out")
@ -162,7 +168,7 @@ func (s *EnvoyProxySuite) CurlDownloadResource(uri string) {
func (s *EnvoyProxySuite) CurlUploadResource(uri, file string) {
args := fmt.Sprintf("-w @/tmp/write_out_upload --max-time %d --insecure --noproxy '*' -T %s %s", s.maxTimeout, file, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "PUT response code: 201")
s.AssertNotContains(log, "Operation timed out")
}

View File

@ -11,15 +11,16 @@ import (
type IperfSuite struct {
HstSuite
Interfaces struct {
Server *NetInterface
Client *NetInterface
}
Containers struct {
Server *Container
Client *Container
}
}
const (
ServerIperfContainerName string = "server"
ServerIperfInterfaceName string = "hstsrv"
ClientIperfContainerName string = "client"
ClientIperfInterfaceName string = "hstcln"
)
var iperfTests = map[string][]func(s *IperfSuite){}
var iperfSoloTests = map[string][]func(s *IperfSuite){}
@ -35,6 +36,10 @@ func (s *IperfSuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.ConfigureNetworkTopology("2taps")
s.LoadContainerTopology("2containers")
s.Interfaces.Client = s.GetInterfaceByName("hstcln")
s.Interfaces.Server = s.GetInterfaceByName("hstsrv")
s.Containers.Server = s.GetContainerByName("server")
s.Containers.Client = s.GetContainerByName("client")
}
var _ = Describe("IperfSuite", Ordered, ContinueOnFailure, func() {

View File

@ -10,17 +10,21 @@ import (
. "github.com/onsi/ginkgo/v2"
)
// These correspond to names used in yaml config
const (
ServerLdpInterfaceName = "srv"
ClientLdpInterfaceName = "cln"
)
var ldpTests = map[string][]func(s *LdpSuite){}
var ldpSoloTests = map[string][]func(s *LdpSuite){}
type LdpSuite struct {
HstSuite
Interfaces struct {
Server *NetInterface
Client *NetInterface
}
Containers struct {
ServerVpp *Container
ClientVpp *Container
ServerApp *Container
ClientApp *Container
}
}
func RegisterLdpTests(tests ...func(s *LdpSuite)) {
@ -35,6 +39,12 @@ func (s *LdpSuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.ConfigureNetworkTopology("2peerVeth")
s.LoadContainerTopology("2peerVethLdp")
s.Interfaces.Client = s.GetInterfaceByName("cln")
s.Interfaces.Server = s.GetInterfaceByName("srv")
s.Containers.ServerVpp = s.GetContainerByName("server-vpp")
s.Containers.ClientVpp = s.GetContainerByName("client-vpp")
s.Containers.ServerApp = s.GetContainerByName("server-app")
s.Containers.ClientApp = s.GetContainerByName("client-app")
}
func (s *LdpSuite) SetupTest() {
@ -55,19 +65,15 @@ func (s *LdpSuite) SetupTest() {
}
// ... For server
serverContainer := s.GetContainerByName("server-vpp")
serverVpp, err := serverContainer.newVppInstance(serverContainer.AllocatedCpus, sessionConfig)
serverVpp, err := s.Containers.ServerVpp.newVppInstance(s.Containers.ServerVpp.AllocatedCpus, sessionConfig)
s.AssertNotNil(serverVpp, fmt.Sprint(err))
// ... For client
clientContainer := s.GetContainerByName("client-vpp")
clientVpp, err := clientContainer.newVppInstance(clientContainer.AllocatedCpus, sessionConfig)
clientVpp, err := s.Containers.ClientVpp.newVppInstance(s.Containers.ClientVpp.AllocatedCpus, sessionConfig)
s.AssertNotNil(clientVpp, fmt.Sprint(err))
serverContainer.AddEnvVar("VCL_CONFIG", serverContainer.GetContainerWorkDir()+"/vcl.conf")
clientContainer.AddEnvVar("VCL_CONFIG", clientContainer.GetContainerWorkDir()+"/vcl.conf")
s.Containers.ServerVpp.AddEnvVar("VCL_CONFIG", s.Containers.ServerVpp.GetContainerWorkDir()+"/vcl.conf")
s.Containers.ClientVpp.AddEnvVar("VCL_CONFIG", s.Containers.ClientVpp.GetContainerWorkDir()+"/vcl.conf")
for _, container := range s.StartedContainers {
container.AddEnvVar("LD_PRELOAD", "/usr/lib/libvcl_ldpreload.so")
@ -75,17 +81,17 @@ func (s *LdpSuite) SetupTest() {
container.AddEnvVar("VCL_DEBUG", "0")
}
s.CreateVclConfig(serverContainer)
s.CreateVclConfig(clientContainer)
s.SetupServerVpp(serverContainer)
s.setupClientVpp(clientContainer)
s.CreateVclConfig(s.Containers.ServerVpp)
s.CreateVclConfig(s.Containers.ClientVpp)
s.SetupServerVpp(s.Containers.ServerVpp)
s.setupClientVpp(s.Containers.ClientVpp)
if *DryRun {
s.LogStartedContainers()
s.Log("\n%s* LD_PRELOAD and VCL_CONFIG server/client paths:", Colors.grn)
s.Log("LD_PRELOAD=/usr/lib/libvcl_ldpreload.so")
s.Log("VCL_CONFIG=%s/vcl.conf", serverContainer.GetContainerWorkDir())
s.Log("VCL_CONFIG=%s/vcl.conf%s\n", clientContainer.GetContainerWorkDir(), Colors.rst)
s.Log("VCL_CONFIG=%s/vcl.conf", s.Containers.ServerVpp.GetContainerWorkDir())
s.Log("VCL_CONFIG=%s/vcl.conf%s\n", s.Containers.ClientVpp.GetContainerWorkDir(), Colors.rst)
s.Skip("Dry run mode = true")
}
}
@ -121,8 +127,7 @@ func (s *LdpSuite) SetupServerVpp(serverContainer *Container) {
serverVpp := serverContainer.VppInstance
s.AssertNil(serverVpp.Start())
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
idx, err := serverVpp.createAfPacket(serverVeth)
idx, err := serverVpp.createAfPacket(s.Interfaces.Server)
s.AssertNil(err, fmt.Sprint(err))
s.AssertNotEqual(0, idx)
}
@ -131,8 +136,7 @@ func (s *LdpSuite) setupClientVpp(clientContainer *Container) {
clientVpp := clientContainer.VppInstance
s.AssertNil(clientVpp.Start())
clientVeth := s.GetInterfaceByName(ClientInterfaceName)
idx, err := clientVpp.createAfPacket(clientVeth)
idx, err := clientVpp.createAfPacket(s.Interfaces.Client)
s.AssertNil(err, fmt.Sprint(err))
s.AssertNotEqual(0, idx)
}

View File

@ -9,14 +9,6 @@ import (
. "github.com/onsi/ginkgo/v2"
)
// These correspond to names used in yaml config
const (
NginxProxyContainerName = "nginx-proxy"
NginxServerContainerName = "nginx-server"
MirroringClientInterfaceName = "hstcln"
MirroringServerInterfaceName = "hstsrv"
)
var nginxProxyTests = map[string][]func(s *NginxProxySuite){}
var nginxProxySoloTests = map[string][]func(s *NginxProxySuite){}
@ -24,6 +16,16 @@ type NginxProxySuite struct {
HstSuite
proxyPort uint16
maxTimeout int
Interfaces struct {
Server *NetInterface
Client *NetInterface
}
Containers struct {
NginxProxy *Container
NginxServerTransient *Container
Vpp *Container
Curl *Container
}
}
func RegisterNginxProxyTests(tests ...func(s *NginxProxySuite)) {
@ -43,6 +45,12 @@ func (s *NginxProxySuite) SetupSuite() {
} else {
s.maxTimeout = 60
}
s.Interfaces.Client = s.GetInterfaceByName("hstcln")
s.Interfaces.Server = s.GetInterfaceByName("hstsrv")
s.Containers.NginxProxy = s.GetContainerByName("nginx-proxy")
s.Containers.NginxServerTransient = s.GetTransientContainerByName("nginx-server")
s.Containers.Vpp = s.GetContainerByName("vpp")
s.Containers.Curl = s.GetContainerByName("curl")
}
func (s *NginxProxySuite) SetupTest() {
@ -55,38 +63,33 @@ func (s *NginxProxySuite) SetupTest() {
Append("enable").
Append("use-app-socket-api")
vppContainer := s.GetContainerByName(VppContainerName)
vpp, err := vppContainer.newVppInstance(vppContainer.AllocatedCpus, sessionConfig)
vpp, err := s.Containers.Vpp.newVppInstance(s.Containers.Vpp.AllocatedCpus, sessionConfig)
s.AssertNotNil(vpp, fmt.Sprint(err))
clientInterface := s.GetInterfaceByName(MirroringClientInterfaceName)
serverInterface := s.GetInterfaceByName(MirroringServerInterfaceName)
// nginx proxy
nginxProxyContainer := s.GetContainerByName(NginxProxyContainerName)
s.AssertNil(nginxProxyContainer.Create())
s.AssertNil(s.Containers.NginxProxy.Create())
s.proxyPort = 80
// nginx HTTP server
nginxServerContainer := s.GetTransientContainerByName(NginxServerContainerName)
s.AssertNil(nginxServerContainer.Create())
s.AssertNil(s.Containers.NginxServerTransient.Create())
nginxSettings := struct {
LogPrefix string
Address string
Timeout int
}{
LogPrefix: nginxServerContainer.Name,
Address: serverInterface.Ip4AddressString(),
LogPrefix: s.Containers.NginxServerTransient.Name,
Address: s.Interfaces.Server.Ip4AddressString(),
Timeout: s.maxTimeout,
}
nginxServerContainer.CreateConfigFromTemplate(
s.Containers.NginxServerTransient.CreateConfigFromTemplate(
"/nginx.conf",
"./resources/nginx/nginx_server_mirroring.conf",
nginxSettings,
)
s.AssertNil(vpp.Start())
s.AssertNil(vpp.CreateTap(clientInterface, 1, 1))
s.AssertNil(vpp.CreateTap(serverInterface, 1, 2))
s.AssertNil(vpp.CreateTap(s.Interfaces.Client, 1, 1))
s.AssertNil(vpp.CreateTap(s.Interfaces.Server, 1, 2))
if *DryRun {
s.LogStartedContainers()
@ -94,21 +97,19 @@ func (s *NginxProxySuite) SetupTest() {
s.Skip("Dry run mode = true")
}
s.AssertNil(nginxProxyContainer.Start())
s.AssertNil(nginxServerContainer.Start())
s.AssertNil(s.Containers.NginxProxy.Start())
s.AssertNil(s.Containers.NginxServerTransient.Start())
}
func (s *NginxProxySuite) TearDownTest() {
if CurrentSpecReport().Failed() {
s.CollectNginxLogs(NginxServerContainerName)
s.CollectNginxLogs(NginxProxyContainerName)
s.CollectNginxLogs(s.Containers.NginxProxy)
s.CollectNginxLogs(s.Containers.NginxServerTransient)
}
s.HstSuite.TearDownTest()
}
func (s *NginxProxySuite) CreateNginxProxyConfig(container *Container, multiThreadWorkers bool) {
clientInterface := s.GetInterfaceByName(MirroringClientInterfaceName)
serverInterface := s.GetInterfaceByName(MirroringServerInterfaceName)
var workers uint8
if multiThreadWorkers {
workers = 2
@ -124,8 +125,8 @@ func (s *NginxProxySuite) CreateNginxProxyConfig(container *Container, multiThre
}{
Workers: workers,
LogPrefix: container.Name,
Proxy: clientInterface.Peer.Ip4AddressString(),
Server: serverInterface.Ip4AddressString(),
Proxy: s.Interfaces.Client.Peer.Ip4AddressString(),
Server: s.Interfaces.Server.Ip4AddressString(),
Port: s.proxyPort,
}
container.CreateConfigFromTemplate(
@ -140,12 +141,12 @@ func (s *NginxProxySuite) ProxyPort() uint16 {
}
func (s *NginxProxySuite) ProxyAddr() string {
return s.GetInterfaceByName(MirroringClientInterfaceName).Peer.Ip4AddressString()
return s.Interfaces.Client.Peer.Ip4AddressString()
}
func (s *NginxProxySuite) CurlDownloadResource(uri string) {
args := fmt.Sprintf("-w @/tmp/write_out_download --max-time %d --insecure --noproxy '*' --remote-name --output-dir /tmp %s", s.maxTimeout, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "GET response code: 200")
s.AssertNotContains(log, "bytes remaining to read")
s.AssertNotContains(log, "Operation timed out")

View File

@ -9,18 +9,22 @@ import (
. "github.com/onsi/ginkgo/v2"
)
const (
SingleTopoContainerVpp = "vpp"
SingleTopoContainerNginx = "nginx"
TapInterfaceName = "htaphost"
NginxHttp3ContainerName = "nginx-http3"
)
var noTopoTests = map[string][]func(s *NoTopoSuite){}
var noTopoSoloTests = map[string][]func(s *NoTopoSuite){}
type NoTopoSuite struct {
HstSuite
Interfaces struct {
Tap *NetInterface
}
Containers struct {
Vpp *Container
Nginx *Container
NginxHttp3 *Container
Wrk *Container
Curl *Container
Ab *Container
}
}
func RegisterNoTopoTests(tests ...func(s *NoTopoSuite)) {
@ -34,6 +38,13 @@ func (s *NoTopoSuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.LoadNetworkTopology("tap")
s.LoadContainerTopology("single")
s.Interfaces.Tap = s.GetInterfaceByName("htaphost")
s.Containers.Vpp = s.GetContainerByName("vpp")
s.Containers.Nginx = s.GetContainerByName("nginx")
s.Containers.NginxHttp3 = s.GetContainerByName("nginx-http3")
s.Containers.Wrk = s.GetContainerByName("wrk")
s.Containers.Curl = s.GetContainerByName("curl")
s.Containers.Ab = s.GetContainerByName("ab")
}
func (s *NoTopoSuite) SetupTest() {
@ -53,12 +64,10 @@ func (s *NoTopoSuite) SetupTest() {
sessionConfig.Close()
}
container := s.GetContainerByName(SingleTopoContainerVpp)
vpp, _ := container.newVppInstance(container.AllocatedCpus, sessionConfig)
vpp, _ := s.Containers.Vpp.newVppInstance(s.Containers.Vpp.AllocatedCpus, sessionConfig)
s.AssertNil(vpp.Start())
tapInterface := s.GetInterfaceByName(TapInterfaceName)
s.AssertNil(vpp.CreateTap(tapInterface, 1, 1), "failed to create tap interface")
s.AssertNil(vpp.CreateTap(s.Interfaces.Tap, 1, 1), "failed to create tap interface")
if *DryRun {
s.LogStartedContainers()
@ -68,7 +77,7 @@ func (s *NoTopoSuite) SetupTest() {
func (s *NoTopoSuite) TearDownTest() {
if CurrentSpecReport().Failed() {
s.CollectNginxLogs(NginxHttp3ContainerName)
s.CollectNginxLogs(s.Containers.NginxHttp3)
}
s.HstSuite.TearDownTest()
}
@ -93,10 +102,9 @@ func (s *NoTopoSuite) CreateNginxConfig(container *Container, multiThreadWorkers
}
func (s *NoTopoSuite) AddNginxVclConfig(multiThreadWorkers bool) {
nginxCont := s.GetContainerByName(SingleTopoContainerNginx)
vclFileName := nginxCont.GetHostWorkDir() + "/vcl.conf"
vclFileName := s.Containers.Nginx.GetHostWorkDir() + "/vcl.conf"
appSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default",
nginxCont.GetContainerWorkDir())
s.Containers.Nginx.GetContainerWorkDir())
var vclConf Stanza
vclConf.
@ -118,15 +126,15 @@ func (s *NoTopoSuite) AddNginxVclConfig(multiThreadWorkers bool) {
}
func (s *NoTopoSuite) VppAddr() string {
return s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString()
return s.Interfaces.Tap.Peer.Ip4AddressString()
}
func (s *NoTopoSuite) VppIfName() string {
return s.GetInterfaceByName(TapInterfaceName).Peer.Name()
return s.Interfaces.Tap.Peer.Name()
}
func (s *NoTopoSuite) HostAddr() string {
return s.GetInterfaceByName(TapInterfaceName).Ip4AddressString()
return s.Interfaces.Tap.Ip4AddressString()
}
func (s *NoTopoSuite) CreateNginxHttp3Config(container *Container) {

View File

@ -10,17 +10,21 @@ import (
. "github.com/onsi/ginkgo/v2"
)
// These correspond to names used in yaml config
const (
ServerInterfaceName = "srv"
ClientInterfaceName = "cln"
)
var vethTests = map[string][]func(s *VethsSuite){}
var vethSoloTests = map[string][]func(s *VethsSuite){}
type VethsSuite struct {
HstSuite
Interfaces struct {
Server *NetInterface
Client *NetInterface
}
Containers struct {
ServerVpp *Container
ClientVpp *Container
ServerApp *Container
ClientApp *Container
}
}
func RegisterVethTests(tests ...func(s *VethsSuite)) {
@ -35,6 +39,12 @@ func (s *VethsSuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.ConfigureNetworkTopology("2peerVeth")
s.LoadContainerTopology("2peerVeth")
s.Interfaces.Client = s.GetInterfaceByName("cln")
s.Interfaces.Server = s.GetInterfaceByName("srv")
s.Containers.ServerVpp = s.GetContainerByName("server-vpp")
s.Containers.ClientVpp = s.GetContainerByName("client-vpp")
s.Containers.ServerApp = s.GetContainerByName("server-app")
s.Containers.ClientApp = s.GetContainerByName("client-app")
}
func (s *VethsSuite) SetupTest() {
@ -55,15 +65,11 @@ func (s *VethsSuite) SetupTest() {
}
// ... For server
serverContainer := s.GetContainerByName("server-vpp")
serverVpp, err := serverContainer.newVppInstance(serverContainer.AllocatedCpus, sessionConfig)
serverVpp, err := s.Containers.ServerVpp.newVppInstance(s.Containers.ServerVpp.AllocatedCpus, sessionConfig)
s.AssertNotNil(serverVpp, fmt.Sprint(err))
// ... For client
clientContainer := s.GetContainerByName("client-vpp")
clientVpp, err := clientContainer.newVppInstance(clientContainer.AllocatedCpus, sessionConfig)
clientVpp, err := s.Containers.ClientVpp.newVppInstance(s.Containers.ClientVpp.AllocatedCpus, sessionConfig)
s.AssertNotNil(clientVpp, fmt.Sprint(err))
s.SetupServerVpp()
@ -75,11 +81,10 @@ func (s *VethsSuite) SetupTest() {
}
func (s *VethsSuite) SetupServerVpp() {
serverVpp := s.GetContainerByName("server-vpp").VppInstance
serverVpp := s.Containers.ServerVpp.VppInstance
s.AssertNil(serverVpp.Start())
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
idx, err := serverVpp.createAfPacket(serverVeth)
idx, err := serverVpp.createAfPacket(s.Interfaces.Server)
s.AssertNil(err, fmt.Sprint(err))
s.AssertNotEqual(0, idx)
}
@ -88,8 +93,7 @@ func (s *VethsSuite) setupClientVpp() {
clientVpp := s.GetContainerByName("client-vpp").VppInstance
s.AssertNil(clientVpp.Start())
clientVeth := s.GetInterfaceByName(ClientInterfaceName)
idx, err := clientVpp.createAfPacket(clientVeth)
idx, err := clientVpp.createAfPacket(s.Interfaces.Client)
s.AssertNil(err, fmt.Sprint(err))
s.AssertNotEqual(0, idx)
}

View File

@ -14,20 +14,25 @@ import (
. "github.com/onsi/ginkgo/v2"
)
// These correspond to names used in yaml config
const (
VppProxyContainerName = "vpp-proxy"
ClientTapInterfaceName = "hstcln"
ServerTapInterfaceName = "hstsrv"
IperfServerContainerName = "iperfA"
IperfClientContainerName = "iperfB"
CurlContainerTestFile = "/tmp/testFile"
CurlContainerTestFile = "/tmp/testFile"
)
type VppProxySuite struct {
HstSuite
serverPort uint16
maxTimeout int
Interfaces struct {
Client *NetInterface
Server *NetInterface
}
Containers struct {
VppProxy *Container
Curl *Container
NginxServerTransient *Container
IperfS *Container
IperfC *Container
}
}
var vppProxyTests = map[string][]func(s *VppProxySuite){}
@ -52,22 +57,25 @@ func (s *VppProxySuite) SetupSuite() {
} else {
s.maxTimeout = 60
}
s.Interfaces.Client = s.GetInterfaceByName("hstcln")
s.Interfaces.Server = s.GetInterfaceByName("hstsrv")
s.Containers.NginxServerTransient = s.GetTransientContainerByName("nginx-server")
s.Containers.VppProxy = s.GetContainerByName("vpp-proxy")
s.Containers.Curl = s.GetContainerByName("curl")
s.Containers.IperfC = s.GetContainerByName("iperfC")
s.Containers.IperfS = s.GetContainerByName("iperfS")
}
func (s *VppProxySuite) SetupTest() {
s.HstSuite.SetupTest()
// VPP HTTP connect-proxy
vppContainer := s.GetContainerByName(VppProxyContainerName)
vpp, err := vppContainer.newVppInstance(vppContainer.AllocatedCpus)
vpp, err := s.Containers.VppProxy.newVppInstance(s.Containers.VppProxy.AllocatedCpus)
s.AssertNotNil(vpp, fmt.Sprint(err))
clientInterface := s.GetInterfaceByName(ClientTapInterfaceName)
serverInterface := s.GetInterfaceByName(ServerTapInterfaceName)
s.AssertNil(vpp.Start())
s.AssertNil(vpp.CreateTap(clientInterface, 1, 1))
s.AssertNil(vpp.CreateTap(serverInterface, 1, 2))
s.AssertNil(vpp.CreateTap(s.Interfaces.Client, 1, 1))
s.AssertNil(vpp.CreateTap(s.Interfaces.Server, 1, 2))
if *DryRun {
s.LogStartedContainers()
@ -76,36 +84,34 @@ func (s *VppProxySuite) SetupTest() {
}
func (s *VppProxySuite) TearDownTest() {
vpp := s.GetContainerByName(VppProxyContainerName).VppInstance
vpp := s.Containers.VppProxy.VppInstance
if CurrentSpecReport().Failed() {
s.Log(vpp.Vppctl("show session verbose 2"))
s.Log(vpp.Vppctl("show error"))
s.CollectNginxLogs(NginxServerContainerName)
s.CollectNginxLogs(s.Containers.NginxServerTransient)
}
s.HstSuite.TearDownTest()
}
func (s *VppProxySuite) SetupNginxServer() {
nginxContainer := s.GetTransientContainerByName(NginxServerContainerName)
serverInterface := s.GetInterfaceByName(ServerTapInterfaceName)
s.AssertNil(nginxContainer.Create())
s.AssertNil(s.Containers.NginxServerTransient.Create())
nginxSettings := struct {
LogPrefix string
Address string
Port uint16
Timeout int
}{
LogPrefix: nginxContainer.Name,
Address: serverInterface.Ip4AddressString(),
LogPrefix: s.Containers.NginxServerTransient.Name,
Address: s.Interfaces.Server.Ip4AddressString(),
Port: s.serverPort,
Timeout: s.maxTimeout,
}
nginxContainer.CreateConfigFromTemplate(
s.Containers.NginxServerTransient.CreateConfigFromTemplate(
"/nginx.conf",
"./resources/nginx/nginx_server.conf",
nginxSettings,
)
s.AssertNil(nginxContainer.Start())
s.AssertNil(s.Containers.NginxServerTransient.Start())
}
func (s *VppProxySuite) ServerPort() uint16 {
@ -113,32 +119,32 @@ func (s *VppProxySuite) ServerPort() uint16 {
}
func (s *VppProxySuite) ServerAddr() string {
return s.GetInterfaceByName(ServerTapInterfaceName).Ip4AddressString()
return s.Interfaces.Server.Ip4AddressString()
}
func (s *VppProxySuite) VppProxyAddr() string {
return s.GetInterfaceByName(ClientTapInterfaceName).Peer.Ip4AddressString()
return s.Interfaces.Client.Peer.Ip4AddressString()
}
func (s *VppProxySuite) ClientAddr() string {
return s.GetInterfaceByName(ClientTapInterfaceName).Ip4AddressString()
return s.Interfaces.Client.Ip4AddressString()
}
func (s *VppProxySuite) CurlRequest(targetUri string) (string, string) {
args := fmt.Sprintf("--insecure --noproxy '*' %s", targetUri)
body, log := s.RunCurlContainer(args)
body, log := s.RunCurlContainer(s.Containers.Curl, args)
return body, log
}
func (s *VppProxySuite) CurlRequestViaTunnel(targetUri string, proxyUri string) (string, string) {
args := fmt.Sprintf("--max-time %d --insecure -p -x %s %s", s.maxTimeout, proxyUri, targetUri)
body, log := s.RunCurlContainer(args)
body, log := s.RunCurlContainer(s.Containers.Curl, args)
return body, log
}
func (s *VppProxySuite) CurlDownloadResource(uri string) {
args := fmt.Sprintf("-w @/tmp/write_out_download --max-time %d --insecure --noproxy '*' --remote-name --output-dir /tmp %s", s.maxTimeout, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "GET response code: 200")
s.AssertNotContains(log, "bytes remaining to read")
s.AssertNotContains(log, "Operation timed out")
@ -146,14 +152,14 @@ func (s *VppProxySuite) CurlDownloadResource(uri string) {
func (s *VppProxySuite) CurlUploadResource(uri, file string) {
args := fmt.Sprintf("-w @/tmp/write_out_upload --max-time %d --insecure --noproxy '*' -T %s %s", s.maxTimeout, file, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "PUT response code: 201")
s.AssertNotContains(log, "Operation timed out")
}
func (s *VppProxySuite) CurlDownloadResourceViaTunnel(uri string, proxyUri string) {
args := fmt.Sprintf("-w @/tmp/write_out_download_connect --max-time %d --insecure -p -x %s --remote-name --output-dir /tmp %s", s.maxTimeout, proxyUri, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "CONNECT response code: 200")
s.AssertContains(writeOut, "GET response code: 200")
s.AssertNotContains(log, "bytes remaining to read")
@ -163,7 +169,7 @@ func (s *VppProxySuite) CurlDownloadResourceViaTunnel(uri string, proxyUri strin
func (s *VppProxySuite) CurlUploadResourceViaTunnel(uri, proxyUri, file string) {
args := fmt.Sprintf("-w @/tmp/write_out_upload_connect --max-time %d --insecure -p -x %s -T %s %s", s.maxTimeout, proxyUri, file, uri)
writeOut, log := s.RunCurlContainer(args)
writeOut, log := s.RunCurlContainer(s.Containers.Curl, args)
s.AssertContains(writeOut, "CONNECT response code: 200")
s.AssertContains(writeOut, "PUT response code: 201")
s.AssertNotContains(log, "Operation timed out")

View File

@ -11,12 +11,17 @@ import (
. "github.com/onsi/ginkgo/v2"
)
const VppUdpProxyContainerName = "vpp"
type VppUdpProxySuite struct {
HstSuite
proxyPort int
serverPort int
Interfaces struct {
Client *NetInterface
Server *NetInterface
}
Containers struct {
VppProxy *Container
}
}
var vppUdpProxyTests = map[string][]func(s *VppUdpProxySuite){}
@ -34,30 +39,29 @@ func (s *VppUdpProxySuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.LoadNetworkTopology("2taps")
s.LoadContainerTopology("single")
s.Interfaces.Client = s.GetInterfaceByName("hstcln")
s.Interfaces.Server = s.GetInterfaceByName("hstsrv")
s.Containers.VppProxy = s.GetContainerByName("vpp")
}
func (s *VppUdpProxySuite) SetupTest() {
s.HstSuite.SetupTest()
// VPP proxy
vppContainer := s.GetContainerByName(VppUdpProxyContainerName)
vpp, err := vppContainer.newVppInstance(vppContainer.AllocatedCpus)
vpp, err := s.Containers.VppProxy.newVppInstance(s.Containers.VppProxy.AllocatedCpus)
s.AssertNotNil(vpp, fmt.Sprint(err))
clientInterface := s.GetInterfaceByName(ClientTapInterfaceName)
serverInterface := s.GetInterfaceByName(ServerTapInterfaceName)
s.AssertNil(vpp.Start())
s.AssertNil(vpp.CreateTap(clientInterface, 1, 1))
s.AssertNil(vpp.CreateTap(serverInterface, 1, 2))
s.AssertNil(vpp.CreateTap(s.Interfaces.Client, 1, 1))
s.AssertNil(vpp.CreateTap(s.Interfaces.Server, 1, 2))
s.proxyPort = 8080
s.serverPort = 80
arp := fmt.Sprintf("set ip neighbor %s %s %s",
serverInterface.Peer.Name(),
serverInterface.Ip4AddressString(),
serverInterface.HwAddress)
s.Interfaces.Server.Peer.Name(),
s.Interfaces.Server.Ip4AddressString(),
s.Interfaces.Server.HwAddress)
vpp.Vppctl(arp)
if *DryRun {
@ -67,7 +71,7 @@ func (s *VppUdpProxySuite) SetupTest() {
}
func (s *VppUdpProxySuite) TearDownTest() {
vpp := s.GetContainerByName(VppUdpProxyContainerName).VppInstance
vpp := s.Containers.VppProxy.VppInstance
if CurrentSpecReport().Failed() {
s.Log(vpp.Vppctl("show session verbose 2"))
s.Log(vpp.Vppctl("show error"))
@ -76,7 +80,7 @@ func (s *VppUdpProxySuite) TearDownTest() {
}
func (s *VppUdpProxySuite) VppProxyAddr() string {
return s.GetInterfaceByName(ClientTapInterfaceName).Peer.Ip4AddressString()
return s.Interfaces.Client.Peer.Ip4AddressString()
}
func (s *VppUdpProxySuite) ProxyPort() int {
@ -84,7 +88,7 @@ func (s *VppUdpProxySuite) ProxyPort() int {
}
func (s *VppUdpProxySuite) ServerAddr() string {
return s.GetInterfaceByName(ServerTapInterfaceName).Ip4AddressString()
return s.Interfaces.Server.Ip4AddressString()
}
func (s *VppUdpProxySuite) ServerPort() int {
@ -92,7 +96,7 @@ func (s *VppUdpProxySuite) ServerPort() int {
}
func (s *VppUdpProxySuite) ClientAddr() string {
return s.GetInterfaceByName(ClientTapInterfaceName).Ip4AddressString()
return s.Interfaces.Client.Ip4AddressString()
}
func (s *VppUdpProxySuite) StartEchoServer() *net.UDPConn {

View File

@ -174,8 +174,7 @@ RunCurlContainer execute curl command with given args.
Container with name "curl" must be available.
Curl runs in verbose mode and progress meter switch off by default.
*/
func (s *HstSuite) RunCurlContainer(args string) (string, string) {
curlCont := s.GetContainerByName("curl")
func (s *HstSuite) RunCurlContainer(curlCont *Container, args string) (string, string) {
cmd := fmt.Sprintf("curl -v -s %s", args)
s.Log(cmd)
curlCont.ExtraRunningArgs = cmd
@ -195,8 +194,7 @@ Nginx logging need to be set following way:
where LogPrefix is set to nginxContainer.Name
*/
func (s *HstSuite) CollectNginxLogs(containerName string) {
nginxContainer := s.GetContainerByName(containerName)
func (s *HstSuite) CollectNginxLogs(nginxContainer *Container) {
targetDir := nginxContainer.Suite.getLogDirPath()
source := nginxContainer.GetHostWorkDir() + "/" + nginxContainer.Name + "-"
cmd := exec.Command("cp", "-t", targetDir, source+"error.log", source+"access.log")
@ -213,8 +211,7 @@ Envoy access log path need to be set following way:
<default-work-dir>/{{.LogPrefix}}-access.log
where LogPrefix is set to envoyContainer.Name
*/
func (s *HstSuite) CollectEnvoyLogs(containerName string) {
envoyContainer := s.GetContainerByName(containerName)
func (s *HstSuite) CollectEnvoyLogs(envoyContainer *Container) {
targetDir := envoyContainer.Suite.getLogDirPath()
source := envoyContainer.GetHostWorkDir() + "/" + envoyContainer.Name + "-"
cmd := exec.Command("cp", "-t", targetDir, source+"access.log")

View File

@ -13,10 +13,8 @@ func init() {
}
func IperfUdpLinuxTest(s *IperfSuite) {
serverContainer := s.GetContainerByName(ServerIperfContainerName)
serverIpAddress := s.GetInterfaceByName(ServerIperfInterfaceName).Ip4AddressString()
clientContainer := s.GetContainerByName(ClientIperfContainerName)
clientIpAddress := s.GetInterfaceByName(ClientIperfInterfaceName).Ip4AddressString()
serverIpAddress := s.Interfaces.Server.Ip4AddressString()
clientIpAddress := s.Interfaces.Client.Ip4AddressString()
clnCh := make(chan error)
stopServerCh := make(chan struct{})
@ -30,7 +28,7 @@ func IperfUdpLinuxTest(s *IperfSuite) {
go func() {
defer GinkgoRecover()
cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.GetPortFromPpid()
s.StartServerApp(serverContainer, "iperf3", cmd, srvCh, stopServerCh)
s.StartServerApp(s.Containers.Server, "iperf3", cmd, srvCh, stopServerCh)
}()
err := <-srvCh
s.AssertNil(err, fmt.Sprint(err))
@ -40,7 +38,7 @@ func IperfUdpLinuxTest(s *IperfSuite) {
defer GinkgoRecover()
cmd := "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress +
" -u -l 1460 -b 10g -J -p " + s.GetPortFromPpid()
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
s.StartClientApp(s.Containers.Client, cmd, clnCh, clnRes)
}()
s.AssertChannelClosed(time.Minute*3, clnCh)
output := <-clnRes

View File

@ -17,7 +17,7 @@ func LdpIperfUdpVppInterruptModeTest(s *LdpSuite) {
}
func LdpIperfTlsTcpTest(s *LdpSuite) {
for _, c := range s.Containers {
for _, c := range s.StartedContainers {
defer delete(c.EnvVars, "LDP_TRANSPARENT_TLS")
defer delete(c.EnvVars, "LDP_TLS_CERT_FILE")
defer delete(c.EnvVars, "LDP_TLS_KEY_FILE")
@ -42,9 +42,7 @@ func ldPreloadIperfVpp(s *LdpSuite, useUdp bool) {
if useUdp {
protocol = " -u "
}
clientContainer := s.GetContainerByName("client-vpp")
serverContainer := s.GetContainerByName("server-vpp")
serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString()
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
stopServerCh := make(chan struct{}, 1)
srvCh := make(chan error, 1)
clnCh := make(chan error)
@ -57,7 +55,7 @@ func ldPreloadIperfVpp(s *LdpSuite, useUdp bool) {
go func() {
defer GinkgoRecover()
cmd := "iperf3 -4 -s -p " + s.GetPortFromPpid()
s.StartServerApp(serverContainer, "iperf3", cmd, srvCh, stopServerCh)
s.StartServerApp(s.Containers.ServerVpp, "iperf3", cmd, srvCh, stopServerCh)
}()
err := <-srvCh
@ -66,7 +64,7 @@ func ldPreloadIperfVpp(s *LdpSuite, useUdp bool) {
go func() {
defer GinkgoRecover()
cmd := "iperf3 -c " + serverVethAddress + " -l 1460 -b 10g -J -p " + s.GetPortFromPpid() + protocol
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
s.StartClientApp(s.Containers.ClientVpp, cmd, clnCh, clnRes)
}()
s.AssertChannelClosed(time.Minute*3, clnCh)
@ -80,10 +78,7 @@ func RedisBenchmarkTest(s *LdpSuite) {
s.SkipIfMultiWorker()
s.SkipIfArm()
serverContainer := s.GetContainerByName("server-vpp")
clientContainer := s.GetContainerByName("client-vpp")
serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString()
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
runningSrv := make(chan error)
doneSrv := make(chan struct{})
clnCh := make(chan error)
@ -96,7 +91,7 @@ func RedisBenchmarkTest(s *LdpSuite) {
go func() {
defer GinkgoRecover()
cmd := "redis-server --daemonize yes --protected-mode no --bind " + serverVethAddress
s.StartServerApp(serverContainer, "redis-server", cmd, runningSrv, doneSrv)
s.StartServerApp(s.Containers.ServerVpp, "redis-server", cmd, runningSrv, doneSrv)
}()
err := <-runningSrv
@ -110,7 +105,7 @@ func RedisBenchmarkTest(s *LdpSuite) {
} else {
cmd = "redis-benchmark --threads " + fmt.Sprint(*NConfiguredCpus) + "-h " + serverVethAddress
}
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
s.StartClientApp(s.Containers.ClientVpp, cmd, clnCh, clnRes)
}()

View File

@ -12,7 +12,7 @@ func init() {
func MemLeakTest(s *NoTopoSuite) {
s.SkipUnlessLeakCheck()
vpp := s.GetContainerByName("vpp").VppInstance
vpp := s.Containers.Vpp.VppInstance
/* no goVPP less noise */
vpp.Disconnect()
vpp.EnableMemoryTrace()

View File

@ -17,22 +17,20 @@ func init() {
func NginxHttp3Test(s *NoTopoSuite) {
query := "index.html"
nginxCont := s.GetContainerByName(NginxHttp3ContainerName)
nginxCont.Create()
s.CreateNginxHttp3Config(nginxCont)
nginxCont.Start()
s.Containers.NginxHttp3.Create()
s.CreateNginxHttp3Config(s.Containers.NginxHttp3)
s.Containers.NginxHttp3.Start()
vpp := s.GetContainerByName("vpp").VppInstance
vpp := s.Containers.Vpp.VppInstance
vpp.WaitForApp("nginx-", 5)
serverAddress := s.VppAddr()
defer func() { os.Remove(query) }()
curlCont := s.GetContainerByName("curl")
args := fmt.Sprintf("curl --noproxy '*' --local-port 55444 --http3-only -k https://%s:8443/%s", serverAddress, query)
curlCont.ExtraRunningArgs = args
curlCont.Run()
body, stats := curlCont.GetOutput()
s.Containers.Curl.ExtraRunningArgs = args
s.Containers.Curl.Run()
body, stats := s.Containers.Curl.GetOutput()
s.Log(body)
s.Log(stats)
s.AssertNotContains(stats, "refused")
@ -44,13 +42,12 @@ func NginxAsServerTest(s *NoTopoSuite) {
query := "return_ok"
finished := make(chan error, 1)
nginxCont := s.GetContainerByName("nginx")
nginxCont.Create()
s.CreateNginxConfig(nginxCont, false)
s.Containers.Nginx.Create()
s.CreateNginxConfig(s.Containers.Nginx, false)
s.AddNginxVclConfig(false)
nginxCont.Start()
s.Containers.Nginx.Start()
vpp := s.GetContainerByName("vpp").VppInstance
vpp := s.Containers.Vpp.VppInstance
vpp.WaitForApp("nginx-", 5)
serverAddress := s.VppAddr()
@ -79,17 +76,15 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string, multiThreadWorkers boo
serverAddress := s.VppAddr()
vpp := s.GetContainerByName("vpp").VppInstance
vpp := s.Containers.Vpp.VppInstance
nginxCont := s.GetContainerByName(SingleTopoContainerNginx)
nginxCont.Create()
s.Containers.Nginx.Create()
s.AddNginxVclConfig(multiThreadWorkers)
s.CreateNginxConfig(nginxCont, multiThreadWorkers)
nginxCont.Start()
s.CreateNginxConfig(s.Containers.Nginx, multiThreadWorkers)
s.Containers.Nginx.Start()
vpp.WaitForApp("nginx-", 5)
if ab_or_wrk == "ab" {
abCont := s.GetContainerByName("ab")
args := fmt.Sprintf("-n %d -c %d", nRequests, nClients)
if mode == "rps" {
args += " -k"
@ -99,21 +94,20 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string, multiThreadWorkers boo
// don't exit on socket receive errors
args += " -r"
args += " http://" + serverAddress + ":80/64B.json"
abCont.ExtraRunningArgs = args
s.Containers.Ab.ExtraRunningArgs = args
s.Log("Test might take up to 2 minutes to finish. Please wait")
abCont.Run()
o, err := abCont.GetOutput()
s.Containers.Ab.Run()
o, err := s.Containers.Ab.GetOutput()
rps := parseString(o, "Requests per second:")
s.Log(rps)
s.AssertContains(err, "Finished "+fmt.Sprint(nRequests))
} else {
wrkCont := s.GetContainerByName("wrk")
args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients,
serverAddress)
wrkCont.ExtraRunningArgs = args
wrkCont.Run()
s.Containers.Wrk.ExtraRunningArgs = args
s.Containers.Wrk.Run()
s.Log("Please wait for 30s, test is running.")
o, err := wrkCont.GetOutput()
o, err := s.Containers.Wrk.GetOutput()
rps := parseString(o, "requests")
s.Log(rps)
s.Log(err)

View File

@ -20,7 +20,7 @@ func init() {
}
func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) {
vppProxy := s.GetContainerByName(VppProxyContainerName).VppInstance
vppProxy := s.Containers.VppProxy.VppInstance
cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri %s://%s/%d", proto, s.VppProxyAddr(), proxyPort)
if proto != "http" && proto != "udp" {
proto = "tcp"
@ -46,23 +46,19 @@ func VppProxyUdpIperfMTTest(s *VppProxySuite) {
}
func vppProxyIperfMTTest(s *VppProxySuite, proto string) {
iperfServer := s.GetContainerByName(IperfServerContainerName)
iperfClient := s.GetContainerByName(IperfClientContainerName)
iperfServer.Run()
iperfClient.Run()
serverInterface := s.GetInterfaceByName(ServerTapInterfaceName)
clientInterface := s.GetInterfaceByName(ClientTapInterfaceName)
vppProxy := s.GetContainerByName(VppProxyContainerName).VppInstance
s.Containers.IperfC.Run()
s.Containers.IperfS.Run()
vppProxy := s.Containers.VppProxy.VppInstance
proxyPort, err := strconv.Atoi(s.GetPortFromPpid())
s.AssertNil(err)
// tap interfaces are created on test setup with 1 rx-queue,
// need to recreate them with 2 + consistent-qp
s.AssertNil(vppProxy.DeleteTap(serverInterface))
s.AssertNil(vppProxy.CreateTap(serverInterface, 2, uint32(serverInterface.Peer.Index), Consistent_qp))
s.AssertNil(vppProxy.DeleteTap(s.Interfaces.Server))
s.AssertNil(vppProxy.CreateTap(s.Interfaces.Server, 2, uint32(s.Interfaces.Server.Peer.Index), Consistent_qp))
s.AssertNil(vppProxy.DeleteTap(clientInterface))
s.AssertNil(vppProxy.CreateTap(clientInterface, 2, uint32(clientInterface.Peer.Index), Consistent_qp))
s.AssertNil(vppProxy.DeleteTap(s.Interfaces.Client))
s.AssertNil(vppProxy.CreateTap(s.Interfaces.Client, 2, uint32(s.Interfaces.Client.Peer.Index), Consistent_qp))
configureVppProxy(s, "tcp", uint16(proxyPort))
if proto == "udp" {
@ -84,7 +80,7 @@ func vppProxyIperfMTTest(s *VppProxySuite, proto string) {
go func() {
defer GinkgoRecover()
cmd := fmt.Sprintf("iperf3 -4 -s -B %s -p %s", s.ServerAddr(), fmt.Sprint(s.ServerPort()))
s.StartServerApp(iperfServer, "iperf3", cmd, srvCh, stopServerCh)
s.StartServerApp(s.Containers.IperfS, "iperf3", cmd, srvCh, stopServerCh)
}()
err = <-srvCh
@ -93,7 +89,7 @@ func vppProxyIperfMTTest(s *VppProxySuite, proto string) {
go func() {
defer GinkgoRecover()
cmd := fmt.Sprintf("iperf3 -c %s -P 4 -l 1460 -b 10g -J -p %d -B %s %s", s.VppProxyAddr(), proxyPort, s.ClientAddr(), proto)
s.StartClientApp(iperfClient, cmd, clnCh, clnRes)
s.StartClientApp(s.Containers.IperfC, cmd, clnCh, clnRes)
}()
s.AssertChannelClosed(time.Minute*4, clnCh)
@ -157,12 +153,11 @@ func NginxMirroringTest(s *NginxProxySuite) {
}
func nginxMirroring(s *NginxProxySuite, multiThreadWorkers bool) {
nginxProxyContainer := s.GetContainerByName(NginxProxyContainerName)
vpp := s.GetContainerByName(VppContainerName).VppInstance
vpp := s.Containers.Vpp.VppInstance
s.AddVclConfig(nginxProxyContainer, multiThreadWorkers)
s.CreateNginxProxyConfig(nginxProxyContainer, multiThreadWorkers)
nginxProxyContainer.Start()
s.AddVclConfig(s.Containers.NginxProxy, multiThreadWorkers)
s.CreateNginxProxyConfig(s.Containers.NginxProxy, multiThreadWorkers)
s.Containers.NginxProxy.Start()
vpp.WaitForApp("nginx-", 5)
uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort())
s.CurlDownloadResource(uri)
@ -192,7 +187,7 @@ func VppProxyUdpTest(s *VppUdpProxySuite) {
remoteServerConn := s.StartEchoServer()
defer remoteServerConn.Close()
vppProxy := s.GetContainerByName(VppUdpProxyContainerName).VppInstance
vppProxy := s.Containers.VppProxy.VppInstance
cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri udp://%s/%d", s.VppProxyAddr(), s.ProxyPort())
cmd += fmt.Sprintf(" client-uri udp://%s/%d", s.ServerAddr(), s.ServerPort())
s.Log(vppProxy.Vppctl(cmd))

View File

@ -20,23 +20,20 @@ func VppEchoTcpTest(s *VethsSuite) {
}
func testVppEcho(s *VethsSuite, proto string) {
serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString()
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
uri := proto + "://" + serverVethAddress + "/12344"
echoSrvContainer := s.GetContainerByName("server-app")
serverCommand := "vpp_echo server TX=RX" +
" socket-name " + echoSrvContainer.GetContainerWorkDir() + "/var/run/app_ns_sockets/default" +
" socket-name " + s.Containers.ServerApp.GetContainerWorkDir() + "/var/run/app_ns_sockets/default" +
" use-app-socket-api" +
" uri " + uri
s.Log(serverCommand)
echoSrvContainer.ExecServer(true, serverCommand)
echoClnContainer := s.GetContainerByName("client-app")
s.Containers.ServerApp.ExecServer(true, serverCommand)
clientCommand := "vpp_echo client" +
" socket-name " + echoClnContainer.GetContainerWorkDir() + "/var/run/app_ns_sockets/default" +
" socket-name " + s.Containers.ClientApp.GetContainerWorkDir() + "/var/run/app_ns_sockets/default" +
" use-app-socket-api uri " + uri
s.Log(clientCommand)
o := echoClnContainer.Exec(true, clientCommand)
o := s.Containers.ClientApp.Exec(true, clientCommand)
s.Log(o)
}

View File

@ -9,13 +9,13 @@ containers:
- <<: *shared-vol
container-dir: "/tmp/vpp"
is-default-work-dir: true
- name: "iperfB"
- name: "iperfC"
volumes:
- <<: *shared-vol
container-dir: "/tmp/vpp"
is-default-work-dir: true
is-optional: true
- name: "iperfA"
- name: "iperfS"
volumes:
- <<: *shared-vol
container-dir: "/tmp/vpp"

View File

@ -40,15 +40,14 @@ func XEchoVclClientTcpTest(s *VethsSuite) {
func testXEchoVclClient(s *VethsSuite, proto string) {
port := "12345"
serverVpp := s.GetContainerByName("server-vpp").VppInstance
serverVpp := s.Containers.ServerVpp.VppInstance
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
serverVpp.Vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, serverVeth.Ip4AddressString(), port)
serverVpp.Vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, s.Interfaces.Server.Ip4AddressString(), port)
echoClnContainer := s.GetTransientContainerByName("client-app")
echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + serverVeth.Ip4AddressString() + " " + port
testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + s.Interfaces.Server.Ip4AddressString() + " " + port
s.Log(testClientCommand)
echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
o := echoClnContainer.Exec(true, testClientCommand)
@ -66,18 +65,17 @@ func XEchoVclServerTcpTest(s *VethsSuite) {
func testXEchoVclServer(s *VethsSuite, proto string) {
port := "12345"
srvVppCont := s.GetContainerByName("server-vpp")
srvAppCont := s.GetContainerByName("server-app")
srvVppCont := s.Containers.ServerVpp
srvAppCont := s.Containers.ServerApp
srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, port)
srvAppCont.ExecServer(true, vclSrvCmd)
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
serverVethAddress := serverVeth.Ip4AddressString()
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
clientVpp := s.GetContainerByName("client-vpp").VppInstance
clientVpp := s.Containers.ClientVpp.VppInstance
o := clientVpp.Vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose mbytes 2", proto, serverVethAddress, port)
s.Log(o)
s.AssertContains(o, "Test finished at")
@ -85,15 +83,14 @@ func testXEchoVclServer(s *VethsSuite, proto string) {
func testVclEcho(s *VethsSuite, proto string) {
port := "12345"
srvVppCont := s.GetContainerByName("server-vpp")
srvAppCont := s.GetContainerByName("server-app")
srvVppCont := s.Containers.ServerVpp
srvAppCont := s.Containers.ServerApp
srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
srvAppCont.ExecServer(true, "vcl_test_server -p "+proto+" "+port)
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
serverVethAddress := serverVeth.Ip4AddressString()
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
echoClnContainer := s.GetTransientContainerByName("client-app")
echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
@ -123,7 +120,7 @@ func VclRetryAttachTest(s *VethsSuite) {
func testRetryAttach(s *VethsSuite, proto string) {
srvVppContainer := s.GetTransientContainerByName("server-vpp")
echoSrvContainer := s.GetContainerByName("server-app")
echoSrvContainer := s.Containers.ServerApp
echoSrvContainer.CreateFile("/vcl.conf", getVclConfig(echoSrvContainer))
@ -133,8 +130,7 @@ func testRetryAttach(s *VethsSuite, proto string) {
s.Log("This whole test case can take around 3 minutes to run. Please be patient.")
s.Log("... Running first echo client test, before disconnect.")
serverVeth := s.GetInterfaceByName(ServerInterfaceName)
serverVethAddress := serverVeth.Ip4AddressString()
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
echoClnContainer := s.GetTransientContainerByName("client-app")
echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))