summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/hs-test/container.go17
-rw-r--r--extras/hs-test/proxy_test.go31
-rw-r--r--extras/hs-test/resources/envoy/proxy.yaml2
-rw-r--r--extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf8
-rw-r--r--extras/hs-test/suite_nginx_test.go14
-rw-r--r--extras/hs-test/topo-containers/ns.yaml2
6 files changed, 56 insertions, 18 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go
index 5def2789528..40dc0828376 100644
--- a/extras/hs-test/container.go
+++ b/extras/hs-test/container.go
@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"strings"
+ "text/template"
"github.com/edwarnicke/exechelper"
)
@@ -301,3 +302,19 @@ func (c *Container) stop() error {
c.saveLogs()
return exechelper.Run("docker stop " + c.name + " -t 0")
}
+
+func (c *Container) createConfig(targetConfigName string, templateName string, values any) {
+ template := template.Must(template.ParseFiles(templateName))
+
+ f, err := os.CreateTemp("/tmp/hs-test/", "hst-config")
+ c.Suite().assertNil(err)
+ defer os.Remove(f.Name())
+
+ err = template.Execute(f, values)
+ c.Suite().assertNil(err)
+
+ err = f.Close()
+ c.Suite().assertNil(err)
+
+ c.copy(f.Name(), targetConfigName)
+}
diff --git a/extras/hs-test/proxy_test.go b/extras/hs-test/proxy_test.go
index f1218662374..ce0e7ad854d 100644
--- a/extras/hs-test/proxy_test.go
+++ b/extras/hs-test/proxy_test.go
@@ -49,7 +49,7 @@ func testProxyHttpTcp(s *NsSuite) error {
return nil
}
-func configureVppProxy(s *NsSuite) error {
+func configureVppProxy(s *NsSuite) {
serverVeth := s.netInterfaces[serverInterface]
clientVeth := s.netInterfaces[clientInterface]
@@ -60,24 +60,35 @@ func configureVppProxy(s *NsSuite) error {
serverVeth.Peer().IP4AddressString(),
)
s.log("proxy configured...", output)
- return nil
}
func (s *NsSuite) TestVppProxyHttpTcp() {
- err := configureVppProxy(s)
- s.assertNil(err)
- err = testProxyHttpTcp(s)
+ configureVppProxy(s)
+ err := testProxyHttpTcp(s)
s.assertNil(err)
}
-func configureEnvoyProxy(s *NsSuite) error {
+func configureEnvoyProxy(s *NsSuite) {
envoyContainer := s.getContainerByName("envoy")
- return envoyContainer.run()
+ envoyContainer.create()
+
+ serverVeth := s.netInterfaces[serverInterface]
+ address := struct {
+ Server string
+ }{
+ Server: serverVeth.Peer().IP4AddressString(),
+ }
+ envoyContainer.createConfig(
+ "/etc/envoy/envoy.yaml",
+ "resources/envoy/proxy.yaml",
+ address,
+ )
+
+ envoyContainer.start()
}
func (s *NsSuite) TestEnvoyProxyHttpTcp() {
- err := configureEnvoyProxy(s)
- s.assertNil(err)
- err = testProxyHttpTcp(s)
+ configureEnvoyProxy(s)
+ err := testProxyHttpTcp(s)
s.assertNil(err)
}
diff --git a/extras/hs-test/resources/envoy/proxy.yaml b/extras/hs-test/resources/envoy/proxy.yaml
index 2093b5613ae..77da80d934d 100644
--- a/extras/hs-test/resources/envoy/proxy.yaml
+++ b/extras/hs-test/resources/envoy/proxy.yaml
@@ -44,7 +44,7 @@ static_resources:
address:
socket_address:
# following address will be generated by Addresser during test run
- address: 10.10.2.1
+ address: {{.Server}}
port_value: 666
bootstrap_extensions:
- name: envoy.extensions.vcl.vcl_socket_interface
diff --git a/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf b/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf
index 03af8b76f15..bf15d1cdb7f 100644
--- a/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf
+++ b/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf
@@ -29,21 +29,21 @@ http {
gzip on;
upstream bk {
- server 10.10.2.1:8091;
+ server {{.Server}}:8091;
keepalive 30000;
}
upstream bk1 {
- server 10.10.2.1:8092;
+ server {{.Server}}:8092;
keepalive 30000;
}
upstream bk2 {
- server 10.10.2.1:8093;
+ server {{.Server}}:8093;
keepalive 30000;
}
server {
listen 80;
- server_name 10.10.1.2;
+ server_name {{.Proxy}};
server_tokens off;
diff --git a/extras/hs-test/suite_nginx_test.go b/extras/hs-test/suite_nginx_test.go
index d950cf834b5..e66eca70d73 100644
--- a/extras/hs-test/suite_nginx_test.go
+++ b/extras/hs-test/suite_nginx_test.go
@@ -45,7 +45,19 @@ func (s *NginxSuite) SetupTest() {
nginxContainer := s.getTransientContainerByName(nginxProxyContainerName)
nginxContainer.create()
- nginxContainer.copy("./resources/nginx/nginx_proxy_mirroring.conf", "/nginx.conf")
+
+ values := struct {
+ Proxy string
+ Server string
+ }{
+ Proxy: clientInterface.Peer().IP4AddressString(),
+ Server: serverInterface.IP4AddressString(),
+ }
+ nginxContainer.createConfig(
+ "/nginx.conf",
+ "./resources/nginx/nginx_proxy_mirroring.conf",
+ values,
+ )
nginxContainer.start()
proxyVpp.waitForApp("-app", 5)
diff --git a/extras/hs-test/topo-containers/ns.yaml b/extras/hs-test/topo-containers/ns.yaml
index fddf2d8e37a..2b1902b2922 100644
--- a/extras/hs-test/topo-containers/ns.yaml
+++ b/extras/hs-test/topo-containers/ns.yaml
@@ -12,8 +12,6 @@ containers:
is-default-work-dir: true
- name: "envoy"
volumes:
- - host-dir: "$HST_DIR/resources/envoy/proxy.yaml"
- container-dir: "/etc/envoy/envoy.yaml"
- <<: *shared-vol
container-dir: "/tmp/vpp-envoy"
is-default-work-dir: true