hs-test: nginx proxy/mirroring test cleanup
- test moved to proxy_test.go - topology and suite updated to be vpp/envoy proxy compliant Type: test Change-Id: Iabee50b76bb8d96851f831c0b57d0e98dc4b3a5f Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:

committed by
Florin Coras

parent
7e6606ab4e
commit
7301abe9ba
@ -1,144 +0,0 @@
|
||||
package hst
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
)
|
||||
|
||||
// These correspond to names used in yaml config
|
||||
const (
|
||||
VppProxyContainerName = "vpp-proxy"
|
||||
NginxProxyContainerName = "nginx-proxy"
|
||||
NginxServerContainerName = "nginx-server"
|
||||
MirroringClientInterfaceName = "hstcln"
|
||||
MirroringServerInterfaceName = "hstsrv"
|
||||
)
|
||||
|
||||
var nginxTests = map[string][]func(s *NginxSuite){}
|
||||
var nginxSoloTests = map[string][]func(s *NginxSuite){}
|
||||
|
||||
type NginxSuite struct {
|
||||
HstSuite
|
||||
}
|
||||
|
||||
func RegisterNginxTests(tests ...func(s *NginxSuite)) {
|
||||
nginxTests[getTestFilename()] = tests
|
||||
}
|
||||
func RegisterNginxSoloTests(tests ...func(s *NginxSuite)) {
|
||||
nginxSoloTests[getTestFilename()] = tests
|
||||
}
|
||||
|
||||
func (s *NginxSuite) SetupSuite() {
|
||||
s.HstSuite.SetupSuite()
|
||||
s.LoadNetworkTopology("2taps")
|
||||
s.LoadContainerTopology("nginxProxyAndServer")
|
||||
}
|
||||
|
||||
func (s *NginxSuite) SetupTest() {
|
||||
s.HstSuite.SetupTest()
|
||||
|
||||
// Setup test conditions
|
||||
var sessionConfig Stanza
|
||||
sessionConfig.
|
||||
NewStanza("session").
|
||||
Append("enable").
|
||||
Append("use-app-socket-api")
|
||||
|
||||
if strings.Contains(CurrentSpecReport().LeafNodeText, "InterruptMode") {
|
||||
sessionConfig.Append("use-private-rx-mqs").Close()
|
||||
s.Log("**********************INTERRUPT MODE**********************")
|
||||
} else {
|
||||
sessionConfig.Close()
|
||||
}
|
||||
|
||||
// ... for proxy
|
||||
vppProxyContainer := s.GetContainerByName(VppProxyContainerName)
|
||||
proxyVpp, _ := vppProxyContainer.newVppInstance(vppProxyContainer.AllocatedCpus, sessionConfig)
|
||||
s.AssertNil(proxyVpp.Start())
|
||||
|
||||
clientInterface := s.GetInterfaceByName(MirroringClientInterfaceName)
|
||||
s.AssertNil(proxyVpp.createTap(clientInterface, 1))
|
||||
|
||||
serverInterface := s.GetInterfaceByName(MirroringServerInterfaceName)
|
||||
s.AssertNil(proxyVpp.createTap(serverInterface, 2))
|
||||
|
||||
nginxContainer := s.GetTransientContainerByName(NginxProxyContainerName)
|
||||
s.AssertNil(nginxContainer.Create())
|
||||
|
||||
values := struct {
|
||||
Proxy string
|
||||
Server string
|
||||
}{
|
||||
Proxy: clientInterface.Peer.Ip4AddressString(),
|
||||
Server: serverInterface.Ip4AddressString(),
|
||||
}
|
||||
nginxContainer.CreateConfig(
|
||||
"/nginx.conf",
|
||||
"./resources/nginx/nginx_proxy_mirroring.conf",
|
||||
values,
|
||||
)
|
||||
s.AssertNil(nginxContainer.Start())
|
||||
|
||||
proxyVpp.WaitForApp("nginx-", 5)
|
||||
}
|
||||
|
||||
var _ = Describe("NginxSuite", Ordered, ContinueOnFailure, func() {
|
||||
var s NginxSuite
|
||||
BeforeAll(func() {
|
||||
s.SetupSuite()
|
||||
})
|
||||
BeforeEach(func() {
|
||||
s.SetupTest()
|
||||
})
|
||||
AfterAll(func() {
|
||||
s.TearDownSuite()
|
||||
})
|
||||
AfterEach(func() {
|
||||
s.TearDownTest()
|
||||
})
|
||||
|
||||
for filename, tests := range nginxTests {
|
||||
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("NginxSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
|
||||
var s NginxSuite
|
||||
BeforeAll(func() {
|
||||
s.SetupSuite()
|
||||
})
|
||||
BeforeEach(func() {
|
||||
s.SetupTest()
|
||||
})
|
||||
AfterAll(func() {
|
||||
s.TearDownSuite()
|
||||
})
|
||||
AfterEach(func() {
|
||||
s.TearDownTest()
|
||||
})
|
||||
|
||||
for filename, tests := range nginxSoloTests {
|
||||
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))
|
||||
}
|
||||
}
|
||||
})
|
181
extras/hs-test/infra/suite_nginx_proxy.go
Normal file
181
extras/hs-test/infra/suite_nginx_proxy.go
Normal file
@ -0,0 +1,181 @@
|
||||
package hst
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
. "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){}
|
||||
|
||||
type NginxProxySuite struct {
|
||||
HstSuite
|
||||
proxyPort uint16
|
||||
}
|
||||
|
||||
func RegisterNginxProxyTests(tests ...func(s *NginxProxySuite)) {
|
||||
nginxProxyTests[getTestFilename()] = tests
|
||||
}
|
||||
func RegisterNginxProxySoloTests(tests ...func(s *NginxProxySuite)) {
|
||||
nginxProxySoloTests[getTestFilename()] = tests
|
||||
}
|
||||
|
||||
func (s *NginxProxySuite) SetupSuite() {
|
||||
s.HstSuite.SetupSuite()
|
||||
s.LoadNetworkTopology("2taps")
|
||||
s.LoadContainerTopology("nginxProxy")
|
||||
}
|
||||
|
||||
func (s *NginxProxySuite) SetupTest() {
|
||||
s.HstSuite.SetupTest()
|
||||
|
||||
// VPP
|
||||
var sessionConfig Stanza
|
||||
sessionConfig.
|
||||
NewStanza("session").
|
||||
Append("enable").
|
||||
Append("use-app-socket-api")
|
||||
|
||||
vppContainer := s.GetContainerByName(VppContainerName)
|
||||
vpp, err := vppContainer.newVppInstance(vppContainer.AllocatedCpus, sessionConfig)
|
||||
s.AssertNotNil(vpp, fmt.Sprint(err))
|
||||
s.AssertNil(vpp.Start())
|
||||
clientInterface := s.GetInterfaceByName(MirroringClientInterfaceName)
|
||||
s.AssertNil(vpp.createTap(clientInterface, 1))
|
||||
serverInterface := s.GetInterfaceByName(MirroringServerInterfaceName)
|
||||
s.AssertNil(vpp.createTap(serverInterface, 2))
|
||||
|
||||
// nginx proxy
|
||||
nginxProxyContainer := s.GetTransientContainerByName(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)
|
||||
s.AssertNil(nginxServerContainer.Create())
|
||||
nginxSettings := struct {
|
||||
LogPrefix string
|
||||
Address string
|
||||
}{
|
||||
LogPrefix: nginxServerContainer.Name,
|
||||
Address: serverInterface.Ip4AddressString(),
|
||||
}
|
||||
nginxServerContainer.CreateConfig(
|
||||
"/nginx.conf",
|
||||
"./resources/nginx/nginx_server_mirroring.conf",
|
||||
nginxSettings,
|
||||
)
|
||||
s.AssertNil(nginxServerContainer.Start())
|
||||
|
||||
vpp.WaitForApp("nginx-", 5)
|
||||
}
|
||||
|
||||
func (s *NginxProxySuite) TearDownTest() {
|
||||
if CurrentSpecReport().Failed() {
|
||||
s.CollectNginxLogs(NginxServerContainerName)
|
||||
s.CollectNginxLogs(NginxProxyContainerName)
|
||||
}
|
||||
s.HstSuite.TearDownTest()
|
||||
}
|
||||
|
||||
func (s *NginxProxySuite) ProxyPort() uint16 {
|
||||
return s.proxyPort
|
||||
}
|
||||
|
||||
func (s *NginxProxySuite) ProxyAddr() string {
|
||||
return s.GetInterfaceByName(MirroringClientInterfaceName).Peer.Ip4AddressString()
|
||||
}
|
||||
|
||||
func (s *NginxProxySuite) CurlDownloadResource(uri string) {
|
||||
args := fmt.Sprintf("--insecure --noproxy '*' --remote-name --output-dir /tmp %s", uri)
|
||||
_, log := s.RunCurlContainer(args)
|
||||
s.AssertNotContains(log, "Recv failure")
|
||||
s.AssertContains(log, "HTTP/1.1 200")
|
||||
}
|
||||
|
||||
var _ = Describe("NginxProxySuite", Ordered, ContinueOnFailure, func() {
|
||||
var s NginxProxySuite
|
||||
BeforeAll(func() {
|
||||
s.SetupSuite()
|
||||
})
|
||||
BeforeEach(func() {
|
||||
s.SetupTest()
|
||||
})
|
||||
AfterAll(func() {
|
||||
s.TearDownSuite()
|
||||
})
|
||||
AfterEach(func() {
|
||||
s.TearDownTest()
|
||||
})
|
||||
|
||||
for filename, tests := range nginxProxyTests {
|
||||
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("NginxProxySuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
|
||||
var s NginxProxySuite
|
||||
BeforeAll(func() {
|
||||
s.SetupSuite()
|
||||
})
|
||||
BeforeEach(func() {
|
||||
s.SetupTest()
|
||||
})
|
||||
AfterAll(func() {
|
||||
s.TearDownSuite()
|
||||
})
|
||||
AfterEach(func() {
|
||||
s.TearDownTest()
|
||||
})
|
||||
|
||||
for filename, tests := range nginxProxySoloTests {
|
||||
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))
|
||||
}
|
||||
}
|
||||
})
|
@ -15,6 +15,7 @@ import (
|
||||
|
||||
// These correspond to names used in yaml config
|
||||
const (
|
||||
VppProxyContainerName = "vpp-proxy"
|
||||
ClientTapInterfaceName = "hstcln"
|
||||
ServerTapInterfaceName = "hstsrv"
|
||||
)
|
||||
|
@ -3,35 +3,16 @@ package main
|
||||
import (
|
||||
. "fd.io/hs-test/infra"
|
||||
"fmt"
|
||||
"github.com/edwarnicke/exechelper"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterNginxTests(MirroringTest)
|
||||
RegisterNoTopoTests(NginxHttp3Test, NginxAsServerTest, NginxPerfCpsTest, NginxPerfRpsTest, NginxPerfWrkTest,
|
||||
NginxPerfCpsInterruptModeTest, NginxPerfRpsInterruptModeTest, NginxPerfWrkInterruptModeTest)
|
||||
}
|
||||
|
||||
// broken when CPUS > 1
|
||||
func MirroringTest(s *NginxSuite) {
|
||||
s.SkipIfMultiWorker()
|
||||
proxyAddress := s.GetInterfaceByName(MirroringClientInterfaceName).Peer.Ip4AddressString()
|
||||
|
||||
path := "/64B.json"
|
||||
|
||||
testCommand := "wrk -c 20 -t 10 -d 10 http://" + proxyAddress + ":80" + path
|
||||
s.Log(testCommand)
|
||||
o, _ := exechelper.Output(testCommand)
|
||||
s.Log(string(o))
|
||||
s.AssertNotEmpty(o)
|
||||
|
||||
vppProxyContainer := s.GetContainerByName(VppProxyContainerName)
|
||||
s.AssertEqual(0, vppProxyContainer.VppInstance.GetSessionStat("no lcl port"))
|
||||
}
|
||||
|
||||
func NginxHttp3Test(s *NoTopoSuite) {
|
||||
s.SkipUnlessExtendedTestsBuilt()
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
func init() {
|
||||
RegisterVppProxyTests(VppProxyHttpTcpTest, VppProxyHttpTlsTest)
|
||||
RegisterEnvoyProxyTests(EnvoyProxyHttpTcpTest)
|
||||
RegisterNginxProxyTests(NginxMirroringTest)
|
||||
}
|
||||
|
||||
func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) {
|
||||
@ -41,3 +42,10 @@ func EnvoyProxyHttpTcpTest(s *EnvoyProxySuite) {
|
||||
uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort())
|
||||
s.CurlDownloadResource(uri)
|
||||
}
|
||||
|
||||
// broken when CPUS > 1
|
||||
func NginxMirroringTest(s *NginxProxySuite) {
|
||||
s.SkipIfMultiWorker()
|
||||
uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort())
|
||||
s.CurlDownloadResource(uri)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ worker_processes 4;
|
||||
worker_rlimit_nofile 102400;
|
||||
daemon off;
|
||||
|
||||
error_log /tmp/nginx/error.log;
|
||||
error_log /tmp/nginx/{{.LogPrefix}}-error.log info;
|
||||
|
||||
events {
|
||||
use epoll;
|
||||
@ -44,7 +44,8 @@ http {
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
access_log /tmp/nginx/{{.LogPrefix}}-access.log;
|
||||
listen {{.Port}};
|
||||
server_name {{.Proxy}};
|
||||
|
||||
server_tokens off;
|
||||
|
@ -3,6 +3,8 @@ worker_rlimit_nofile 10240;
|
||||
worker_processes 2;
|
||||
daemon off;
|
||||
|
||||
error_log /tmp/nginx/{{.LogPrefix}}-error.log info;
|
||||
|
||||
events {
|
||||
use epoll;
|
||||
worker_connections 10240;
|
||||
@ -15,18 +17,17 @@ http {
|
||||
keepalive_requests 1000000;
|
||||
sendfile on;
|
||||
server {
|
||||
access_log /tmp/nginx/{{.LogPrefix}}-access.log;
|
||||
listen 8091;
|
||||
listen 8092;
|
||||
listen 8093;
|
||||
root /usr/share/nginx;
|
||||
index index.html index.htm;
|
||||
location /return_ok
|
||||
{
|
||||
return 200 '';
|
||||
}
|
||||
location /64B.json
|
||||
{
|
||||
location /64B {
|
||||
return 200 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
}
|
||||
location / {
|
||||
sendfile on;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
extras/hs-test/topo-containers/nginxProxy.yaml
Normal file
32
extras/hs-test/topo-containers/nginxProxy.yaml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
volumes:
|
||||
- volume: &shared-vol-nginx-proxy
|
||||
host-dir: "$HST_VOLUME_DIR/shared-vol-nginx-proxy"
|
||||
|
||||
containers:
|
||||
- name: "vpp"
|
||||
volumes:
|
||||
- <<: *shared-vol-nginx-proxy
|
||||
container-dir: "/tmp/vpp"
|
||||
is-default-work-dir: true
|
||||
- name: "nginx-proxy"
|
||||
volumes:
|
||||
- <<: *shared-vol-nginx-proxy
|
||||
container-dir: "/tmp/nginx"
|
||||
is-default-work-dir: true
|
||||
image: "hs-test/nginx-ldp"
|
||||
is-optional: true
|
||||
- name: "nginx-server"
|
||||
volumes:
|
||||
- <<: *shared-vol-nginx-proxy
|
||||
container-dir: "/tmp/nginx"
|
||||
is-default-work-dir: true
|
||||
image: "hs-test/nginx-server"
|
||||
is-optional: true
|
||||
- name: "curl"
|
||||
vars:
|
||||
- name: LD_LIBRARY_PATH
|
||||
value: "/usr/local/lib"
|
||||
image: "hs-test/curl"
|
||||
is-optional: true
|
||||
run-detached: false
|
@ -1,20 +0,0 @@
|
||||
---
|
||||
volumes:
|
||||
- volume: &shared-vol-proxy
|
||||
host-dir: "$HST_VOLUME_DIR/shared-vol-proxy"
|
||||
|
||||
containers:
|
||||
- name: "vpp-proxy"
|
||||
volumes:
|
||||
- <<: *shared-vol-proxy
|
||||
container-dir: "/tmp/vpp"
|
||||
is-default-work-dir: true
|
||||
- name: "nginx-proxy"
|
||||
volumes:
|
||||
- <<: *shared-vol-proxy
|
||||
container-dir: "/tmp/nginx"
|
||||
is-default-work-dir: true
|
||||
image: "hs-test/nginx-ldp"
|
||||
is-optional: true
|
||||
- name: "nginx-server"
|
||||
image: "hs-test/nginx-server"
|
Reference in New Issue
Block a user