diff options
Diffstat (limited to 'extras/hs-test/infra')
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 21 | ||||
-rw-r--r-- | extras/hs-test/infra/suite_envoy_proxy.go | 1 | ||||
-rw-r--r-- | extras/hs-test/infra/suite_nginx_proxy.go | 75 | ||||
-rw-r--r-- | extras/hs-test/infra/suite_no_topo.go | 47 | ||||
-rw-r--r-- | extras/hs-test/infra/suite_ns.go | 127 | ||||
-rw-r--r-- | extras/hs-test/infra/utils.go | 1 |
6 files changed, 116 insertions, 156 deletions
diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index 07c0d935e04..8785fbf63d4 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -322,20 +322,25 @@ func (s *HstSuite) SkipIfMultiWorker(args ...any) { } } -func (s *HstSuite) SkipIfNotEnoughAvailableCpus() bool { - var MaxRequestedCpu int +func (s *HstSuite) SkipIfNotEnoughAvailableCpus() { + var maxRequestedCpu int + availableCpus := len(s.CpuAllocator.cpus) - 1 + + if *UseCpu0 { + availableCpus++ + } if s.CpuAllocator.runningInCi { - MaxRequestedCpu = ((s.CpuAllocator.buildNumber + 1) * s.CpuAllocator.maxContainerCount * s.CpuCount) + maxRequestedCpu = ((s.CpuAllocator.buildNumber + 1) * s.CpuAllocator.maxContainerCount * s.CpuCount) } else { - MaxRequestedCpu = (GinkgoParallelProcess() * s.CpuAllocator.maxContainerCount * s.CpuCount) + maxRequestedCpu = (GinkgoParallelProcess() * s.CpuAllocator.maxContainerCount * s.CpuCount) } - if len(s.CpuAllocator.cpus)-1 < MaxRequestedCpu { - s.Skip(fmt.Sprintf("test case cannot allocate requested cpus (%d cpus * %d containers)", s.CpuCount, s.CpuAllocator.maxContainerCount)) + if availableCpus < maxRequestedCpu { + s.Skip(fmt.Sprintf("Test case cannot allocate requested cpus "+ + "(%d cpus * %d containers, %d available). Try using 'CPU0=true'", + s.CpuCount, s.CpuAllocator.maxContainerCount, availableCpus)) } - - return true } func (s *HstSuite) SkipUnlessLeakCheck() { diff --git a/extras/hs-test/infra/suite_envoy_proxy.go b/extras/hs-test/infra/suite_envoy_proxy.go index e34a7d74225..b7f37a9ace7 100644 --- a/extras/hs-test/infra/suite_envoy_proxy.go +++ b/extras/hs-test/infra/suite_envoy_proxy.go @@ -96,6 +96,7 @@ func (s *EnvoyProxySuite) SetupTest() { // Envoy envoyContainer := s.GetContainerByName(EnvoyProxyContainerName) s.AssertNil(envoyContainer.Create()) + s.proxyPort = 8080 envoySettings := struct { LogPrefix string diff --git a/extras/hs-test/infra/suite_nginx_proxy.go b/extras/hs-test/infra/suite_nginx_proxy.go index 75215cfc78d..93a9635f938 100644 --- a/extras/hs-test/infra/suite_nginx_proxy.go +++ b/extras/hs-test/infra/suite_nginx_proxy.go @@ -65,26 +65,9 @@ func (s *NginxProxySuite) SetupTest() { s.AssertNil(vpp.createTap(serverInterface, 2)) // nginx proxy - nginxProxyContainer := s.GetTransientContainerByName(NginxProxyContainerName) + nginxProxyContainer := s.GetContainerByName(NginxProxyContainerName) s.AssertNil(nginxProxyContainer.Create()) s.proxyPort = 80 - values := struct { - LogPrefix string - Proxy string - Server string - Port uint16 - }{ - LogPrefix: nginxProxyContainer.Name, - Proxy: clientInterface.Peer.Ip4AddressString(), - Server: serverInterface.Ip4AddressString(), - Port: s.proxyPort, - } - nginxProxyContainer.CreateConfig( - "/nginx.conf", - "./resources/nginx/nginx_proxy_mirroring.conf", - values, - ) - s.AssertNil(nginxProxyContainer.Start()) // nginx HTTP server nginxServerContainer := s.GetTransientContainerByName(NginxServerContainerName) @@ -104,8 +87,6 @@ func (s *NginxProxySuite) SetupTest() { nginxSettings, ) s.AssertNil(nginxServerContainer.Start()) - - vpp.WaitForApp("nginx-", 5) } func (s *NginxProxySuite) TearDownTest() { @@ -116,6 +97,35 @@ func (s *NginxProxySuite) TearDownTest() { 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 + } else { + workers = 1 + } + values := struct { + Workers uint8 + LogPrefix string + Proxy string + Server string + Port uint16 + }{ + Workers: workers, + LogPrefix: container.Name, + Proxy: clientInterface.Peer.Ip4AddressString(), + Server: serverInterface.Ip4AddressString(), + Port: s.proxyPort, + } + container.CreateConfig( + "/nginx.conf", + "./resources/nginx/nginx_proxy_mirroring.conf", + values, + ) +} + func (s *NginxProxySuite) ProxyPort() uint16 { return s.proxyPort } @@ -132,6 +142,31 @@ func (s *NginxProxySuite) CurlDownloadResource(uri string) { s.AssertNotContains(log, "Operation timed out") } +func (s *NginxProxySuite) AddVclConfig(container *Container, multiThreadWorkers bool) { + var vclConf Stanza + vclFileName := container.GetHostWorkDir() + "/vcl.conf" + + appSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default", + container.GetContainerWorkDir()) + + vclConf. + NewStanza("vcl"). + Append("heapsize 64M"). + Append("rx-fifo-size 4000000"). + Append("tx-fifo-size 4000000"). + Append("segment-size 4000000000"). + Append("add-segment-size 4000000000"). + Append("event-queue-size 100000"). + Append("use-mq-eventfd"). + Append(appSocketApi) + if multiThreadWorkers { + vclConf.Append("multi-thread-workers") + } + + err := vclConf.Close().SaveToFile(vclFileName) + s.AssertNil(err, fmt.Sprint(err)) +} + var _ = Describe("NginxProxySuite", Ordered, ContinueOnFailure, func() { var s NginxProxySuite BeforeAll(func() { diff --git a/extras/hs-test/infra/suite_no_topo.go b/extras/hs-test/infra/suite_no_topo.go index a4abf40d07a..f518ba7c5e1 100644 --- a/extras/hs-test/infra/suite_no_topo.go +++ b/extras/hs-test/infra/suite_no_topo.go @@ -1,6 +1,7 @@ package hst import ( + "fmt" "reflect" "runtime" "strings" @@ -68,6 +69,50 @@ func (s *NoTopoSuite) TearDownTest() { s.HstSuite.TearDownTest() } +func (s *NoTopoSuite) CreateNginxConfig(container *Container, multiThreadWorkers bool) { + var workers uint8 + if multiThreadWorkers { + workers = 2 + } else { + workers = 1 + } + values := struct { + Workers uint8 + }{ + Workers: workers, + } + container.CreateConfig( + "/nginx.conf", + "./resources/nginx/nginx.conf", + values, + ) +} + +func (s *NoTopoSuite) AddNginxVclConfig(multiThreadWorkers bool) { + nginxCont := s.GetContainerByName(SingleTopoContainerNginx) + vclFileName := nginxCont.GetHostWorkDir() + "/vcl.conf" + appSocketApi := fmt.Sprintf("app-socket-api %s/var/run/app_ns_sockets/default", + nginxCont.GetContainerWorkDir()) + + var vclConf Stanza + vclConf. + NewStanza("vcl"). + Append("heapsize 64M"). + Append("rx-fifo-size 4000000"). + Append("tx-fifo-size 4000000"). + Append("segment-size 4000000000"). + Append("add-segment-size 4000000000"). + Append("event-queue-size 100000"). + Append("use-mq-eventfd"). + Append(appSocketApi) + if multiThreadWorkers { + vclConf.Append("multi-thread-workers") + } + + err := vclConf.Close().SaveToFile(vclFileName) + s.AssertNil(err, fmt.Sprint(err)) +} + func (s *NoTopoSuite) VppAddr() string { return s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString() } @@ -80,7 +125,7 @@ func (s *NoTopoSuite) HostAddr() string { return s.GetInterfaceByName(TapInterfaceName).Ip4AddressString() } -func (s *NoTopoSuite) CreateNginxConfig(container *Container) { +func (s *NoTopoSuite) CreateNginxHttp3Config(container *Container) { nginxSettings := struct { LogPrefix string }{ diff --git a/extras/hs-test/infra/suite_ns.go b/extras/hs-test/infra/suite_ns.go deleted file mode 100644 index 601ec22a8a9..00000000000 --- a/extras/hs-test/infra/suite_ns.go +++ /dev/null @@ -1,127 +0,0 @@ -package hst - -import ( - "fmt" - "reflect" - "runtime" - "strings" - - . "github.com/onsi/ginkgo/v2" -) - -// These correspond to names used in yaml config -const ( - ClientInterface = "hclnvpp" - ServerInterface = "hsrvvpp" -) - -var nsTests = map[string][]func(s *NsSuite){} -var nsSoloTests = map[string][]func(s *NsSuite){} - -type NsSuite struct { - HstSuite -} - -func RegisterNsTests(tests ...func(s *NsSuite)) { - nsTests[getTestFilename()] = tests -} -func RegisterNsSoloTests(tests ...func(s *NsSuite)) { - nsSoloTests[getTestFilename()] = tests -} - -func (s *NsSuite) SetupSuite() { - s.HstSuite.SetupSuite() - s.ConfigureNetworkTopology("ns") - s.LoadContainerTopology("ns") -} - -func (s *NsSuite) SetupTest() { - s.HstSuite.SetupTest() - - // Setup test conditions - var sessionConfig Stanza - sessionConfig. - NewStanza("session"). - Append("enable"). - Append("use-app-socket-api"). - Append("evt_qs_memfd_seg"). - Append("event-queue-length 100000") - - if strings.Contains(CurrentSpecReport().LeafNodeText, "InterruptMode") { - sessionConfig.Append("use-private-rx-mqs").Close() - } else { - sessionConfig.Close() - } - - container := s.GetContainerByName("vpp") - vpp, _ := container.newVppInstance(container.AllocatedCpus, sessionConfig) - s.AssertNil(vpp.Start()) - - idx, err := vpp.createAfPacket(s.GetInterfaceByName(ServerInterface)) - s.AssertNil(err, fmt.Sprint(err)) - s.AssertNotEqual(0, idx) - - idx, err = vpp.createAfPacket(s.GetInterfaceByName(ClientInterface)) - s.AssertNil(err, fmt.Sprint(err)) - s.AssertNotEqual(0, idx) - - container.Exec("chmod 777 -R %s", container.GetContainerWorkDir()) -} - -var _ = Describe("NsSuite", Ordered, ContinueOnFailure, func() { - var s NsSuite - BeforeAll(func() { - s.SetupSuite() - }) - BeforeEach(func() { - s.SetupTest() - }) - AfterAll(func() { - s.TearDownSuite() - }) - AfterEach(func() { - s.TearDownTest() - }) - - for filename, tests := range nsTests { - for _, test := range tests { - test := test - pc := reflect.ValueOf(test).Pointer() - funcValue := runtime.FuncForPC(pc) - testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2] - It(testName, func(ctx SpecContext) { - s.Log(testName + ": BEGIN") - test(&s) - }, SpecTimeout(SuiteTimeout)) - } - } -}) - -var _ = Describe("NsSuiteSolo", Ordered, ContinueOnFailure, Serial, func() { - var s NsSuite - BeforeAll(func() { - s.SetupSuite() - }) - BeforeEach(func() { - s.SetupTest() - }) - AfterAll(func() { - s.TearDownSuite() - }) - AfterEach(func() { - s.TearDownTest() - }) - - for filename, tests := range nsSoloTests { - for _, test := range tests { - test := test - pc := reflect.ValueOf(test).Pointer() - funcValue := runtime.FuncForPC(pc) - testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2] - It(testName, Label("SOLO"), func(ctx SpecContext) { - s.Log(testName + ": BEGIN") - test(&s) - }, SpecTimeout(SuiteTimeout)) - } - } -}) diff --git a/extras/hs-test/infra/utils.go b/extras/hs-test/infra/utils.go index 25d8519cb8a..ee528370280 100644 --- a/extras/hs-test/infra/utils.go +++ b/extras/hs-test/infra/utils.go @@ -254,6 +254,7 @@ func (s *HstSuite) StartWget(finished chan error, server_ip, port, query, netNs netNs) s.Log(cmd) o, err := cmd.CombinedOutput() + s.Log(string(o)) if err != nil { finished <- fmt.Errorf("wget error: '%v\n\n%s'", err, o) return |