hs-test: upload via proxy tests
Type: test
Change-Id: Id6b4e2348735081c827f814a814c976b601432ec
Signed-off-by: Matus Fabian <matfabia@cisco.com>
diff --git a/extras/hs-test/docker/Dockerfile.curl b/extras/hs-test/docker/Dockerfile.curl
index 90f415f..fe9b4d9 100644
--- a/extras/hs-test/docker/Dockerfile.curl
+++ b/extras/hs-test/docker/Dockerfile.curl
@@ -7,6 +7,7 @@
&& rm -rf /var/lib/apt/lists/*
COPY script/build_curl.sh /build_curl.sh
+RUN fallocate -l 10MB /tmp/testFile
RUN apt-get update && apt-get install wget
RUN /build_curl.sh
diff --git a/extras/hs-test/docker/Dockerfile.nginx-server b/extras/hs-test/docker/Dockerfile.nginx-server
index 08f428d..ecb8f59 100644
--- a/extras/hs-test/docker/Dockerfile.nginx-server
+++ b/extras/hs-test/docker/Dockerfile.nginx-server
@@ -11,5 +11,6 @@
COPY resources/nginx/html/index.html /usr/share/nginx/index.html
RUN fallocate -l 10MB /usr/share/nginx/httpTestFile
+RUN mkdir /usr/share/nginx/upload && chmod 777 /usr/share/nginx/upload
ENTRYPOINT ["nginx_server_entrypoint.sh"]
diff --git a/extras/hs-test/infra/suite_envoy_proxy.go b/extras/hs-test/infra/suite_envoy_proxy.go
index e1bfae2..52f94bc 100644
--- a/extras/hs-test/infra/suite_envoy_proxy.go
+++ b/extras/hs-test/infra/suite_envoy_proxy.go
@@ -136,6 +136,12 @@
s.AssertContains(log, "HTTP/1.1 200")
}
+func (s *EnvoyProxySuite) CurlUploadResource(uri, file string) {
+ args := fmt.Sprintf("--insecure --noproxy '*' -T %s %s", file, uri)
+ _, log := s.RunCurlContainer(args)
+ s.AssertContains(log, "HTTP/1.1 201")
+}
+
var _ = Describe("EnvoyProxySuite", Ordered, ContinueOnFailure, func() {
var s EnvoyProxySuite
BeforeAll(func() {
diff --git a/extras/hs-test/infra/suite_vpp_proxy.go b/extras/hs-test/infra/suite_vpp_proxy.go
index 94bd0f9..a13897e 100644
--- a/extras/hs-test/infra/suite_vpp_proxy.go
+++ b/extras/hs-test/infra/suite_vpp_proxy.go
@@ -18,6 +18,7 @@
VppProxyContainerName = "vpp-proxy"
ClientTapInterfaceName = "hstcln"
ServerTapInterfaceName = "hstsrv"
+ CurlContainerTestFile = "/tmp/testFile"
)
type VppProxySuite struct {
@@ -102,7 +103,7 @@
}
func (s *VppProxySuite) CurlRequestViaTunnel(targetUri string, proxyUri string) (string, string) {
- args := fmt.Sprintf("--insecure -p -x %s %s", proxyUri, targetUri)
+ args := fmt.Sprintf("--max-time 60 --insecure -p -x %s %s", proxyUri, targetUri)
body, log := s.RunCurlContainer(args)
return body, log
}
@@ -114,11 +115,28 @@
s.AssertContains(log, "HTTP/1.1 200")
}
+func (s *VppProxySuite) CurlUploadResource(uri, file string) {
+ args := fmt.Sprintf("--insecure --noproxy '*' -T %s %s", file, uri)
+ _, log := s.RunCurlContainer(args)
+ s.AssertContains(log, "HTTP/1.1 201")
+}
+
func (s *VppProxySuite) CurlDownloadResourceViaTunnel(uri string, proxyUri string) {
- args := fmt.Sprintf("--insecure -p -x %s --remote-name --output-dir /tmp %s", proxyUri, uri)
+ args := fmt.Sprintf("--max-time 180 --insecure -p -x %s --remote-name --output-dir /tmp %s", proxyUri, uri)
_, log := s.RunCurlContainer(args)
s.AssertNotContains(log, "Recv failure")
+ s.AssertNotContains(log, "Operation timed out")
+ s.AssertContains(log, "CONNECT tunnel established")
s.AssertContains(log, "HTTP/1.1 200")
+ s.AssertNotContains(log, "bytes remaining to read")
+}
+
+func (s *VppProxySuite) CurlUploadResourceViaTunnel(uri, proxyUri, file string) {
+ args := fmt.Sprintf("--max-time 180 --insecure -p -x %s -T %s %s", proxyUri, file, uri)
+ _, log := s.RunCurlContainer(args)
+ s.AssertNotContains(log, "Operation timed out")
+ s.AssertContains(log, "CONNECT tunnel established")
+ s.AssertContains(log, "HTTP/1.1 201")
}
var _ = Describe("VppProxySuite", Ordered, ContinueOnFailure, func() {
diff --git a/extras/hs-test/proxy_test.go b/extras/hs-test/proxy_test.go
index 167cf25..7ec97c7 100644
--- a/extras/hs-test/proxy_test.go
+++ b/extras/hs-test/proxy_test.go
@@ -6,8 +6,8 @@
)
func init() {
- RegisterVppProxyTests(VppProxyHttpTcpTest, VppProxyHttpTlsTest)
- RegisterEnvoyProxyTests(EnvoyProxyHttpTcpTest)
+ RegisterVppProxyTests(VppProxyHttpGetTcpTest, VppProxyHttpGetTlsTest, VppProxyHttpPutTcpTest, VppProxyHttpPutTlsTest)
+ RegisterEnvoyProxyTests(EnvoyProxyHttpGetTcpTest, EnvoyProxyHttpPutTcpTest)
RegisterNginxProxyTests(NginxMirroringTest)
}
@@ -24,25 +24,44 @@
s.Log("proxy configured: " + output)
}
-func VppProxyHttpTcpTest(s *VppProxySuite) {
+func VppProxyHttpGetTcpTest(s *VppProxySuite) {
var proxyPort uint16 = 8080
configureVppProxy(s, "tcp", proxyPort)
uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort)
s.CurlDownloadResource(uri)
}
-func VppProxyHttpTlsTest(s *VppProxySuite) {
+func VppProxyHttpGetTlsTest(s *VppProxySuite) {
var proxyPort uint16 = 8080
configureVppProxy(s, "tls", proxyPort)
uri := fmt.Sprintf("https://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort)
s.CurlDownloadResource(uri)
}
-func EnvoyProxyHttpTcpTest(s *EnvoyProxySuite) {
+func VppProxyHttpPutTcpTest(s *VppProxySuite) {
+ var proxyPort uint16 = 8080
+ configureVppProxy(s, "tcp", proxyPort)
+ uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.VppProxyAddr(), proxyPort)
+ s.CurlUploadResource(uri, CurlContainerTestFile)
+}
+
+func VppProxyHttpPutTlsTest(s *VppProxySuite) {
+ var proxyPort uint16 = 8080
+ configureVppProxy(s, "tls", proxyPort)
+ uri := fmt.Sprintf("https://%s:%d/upload/testFile", s.VppProxyAddr(), proxyPort)
+ s.CurlUploadResource(uri, CurlContainerTestFile)
+}
+
+func EnvoyProxyHttpGetTcpTest(s *EnvoyProxySuite) {
uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort())
s.CurlDownloadResource(uri)
}
+func EnvoyProxyHttpPutTcpTest(s *EnvoyProxySuite) {
+ uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ProxyAddr(), s.ProxyPort())
+ s.CurlUploadResource(uri, CurlContainerTestFile)
+}
+
// broken when CPUS > 1
func NginxMirroringTest(s *NginxProxySuite) {
s.SkipIfMultiWorker()
diff --git a/extras/hs-test/resources/nginx/nginx_server.conf b/extras/hs-test/resources/nginx/nginx_server.conf
index 80ea602..62d27cb 100644
--- a/extras/hs-test/resources/nginx/nginx_server.conf
+++ b/extras/hs-test/resources/nginx/nginx_server.conf
@@ -22,6 +22,14 @@
server_name {{.Address}};
root /usr/share/nginx;
index index.html index.htm;
+ location ~ "/upload/([0-9a-zA-Z-.]*)$" {
+ alias /usr/share/nginx/upload/$1;
+ client_body_temp_path /tmp;
+ client_max_body_size 200M;
+ dav_methods PUT;
+ create_full_put_path off;
+ dav_access all:rw;
+ }
location /64B {
return 200 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
}
diff --git a/extras/hs-test/topo-containers/envoyProxy.yaml b/extras/hs-test/topo-containers/envoyProxy.yaml
index 4980807..92dd9b9 100644
--- a/extras/hs-test/topo-containers/envoyProxy.yaml
+++ b/extras/hs-test/topo-containers/envoyProxy.yaml
@@ -1,17 +1,17 @@
---
volumes:
- - volume: &shared-vol-envoy-proxy
- host-dir: "$HST_VOLUME_DIR/shared-vol-envoy-proxy"
+ - volume: &shared-vol
+ host-dir: "$HST_VOLUME_DIR/shared-vol"
containers:
- name: "vpp"
volumes:
- - <<: *shared-vol-envoy-proxy
+ - <<: *shared-vol
container-dir: "/tmp/vpp"
is-default-work-dir: true
- name: "envoy-vcl"
volumes:
- - <<: *shared-vol-envoy-proxy
+ - <<: *shared-vol
container-dir: "/tmp/vpp-envoy"
is-default-work-dir: true
- host-dir: "$HST_DIR/resources/envoy"
@@ -26,7 +26,7 @@
is-optional: true
- name: "nginx-server"
volumes:
- - <<: *shared-vol-envoy-proxy
+ - <<: *shared-vol
container-dir: "/tmp/nginx"
is-default-work-dir: true
image: "hs-test/nginx-server"
diff --git a/extras/hs-test/topo-containers/vppProxy.yaml b/extras/hs-test/topo-containers/vppProxy.yaml
index c4bbbe9..a1f24bb 100644
--- a/extras/hs-test/topo-containers/vppProxy.yaml
+++ b/extras/hs-test/topo-containers/vppProxy.yaml
@@ -1,17 +1,17 @@
---
volumes:
- - volume: &shared-vol-vpp-proxy
- host-dir: "$HST_VOLUME_DIR/shared-vol-vpp-proxy"
+ - volume: &shared-vol
+ host-dir: "$HST_VOLUME_DIR/shared-vol"
containers:
- name: "vpp-proxy"
volumes:
- - <<: *shared-vol-vpp-proxy
+ - <<: *shared-vol
container-dir: "/tmp/vpp"
is-default-work-dir: true
- name: "nginx-server"
volumes:
- - <<: *shared-vol-vpp-proxy
+ - <<: *shared-vol
container-dir: "/tmp/nginx"
is-default-work-dir: true
image: "hs-test/nginx-server"
@@ -23,4 +23,3 @@
image: "hs-test/curl"
is-optional: true
run-detached: false
-