Add envoy integration tests

This commit is contained in:
freddygv 2020-04-14 15:13:58 -06:00
parent 3849b066a6
commit 7d5a02ad61
21 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,14 @@
enable_central_service_config = true
config_entries {
bootstrap {
kind = "terminating-gateway"
name = "terminating-gateway"
services = [
{
name = "s2"
}
]
}
}

View File

@ -0,0 +1,5 @@
services {
name = "terminating-gateway"
kind = "terminating-gateway"
port = 8443
}

View File

@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail
# wait for bootstrap to apply config entries
wait_for_config_entry terminating-gateway terminating-gateway
gen_envoy_bootstrap terminating-gateway 20000 primary true
gen_envoy_bootstrap s1 19000

View File

@ -0,0 +1,3 @@
#!/bin/bash
export REQUIRED_SERVICES="s1 s1-sidecar-proxy s2 terminating-gateway-primary"

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bats
load helpers
@test "terminating proxy admin is up on :20000" {
retry_default curl -f -s localhost:20000/stats -o /dev/null
}
@test "s1 proxy admin is up on :19000" {
retry_default curl -f -s localhost:19000/stats -o /dev/null
}
@test "terminating-gateway-primary listener is up on :8443" {
retry_default nc -z localhost:8443
}
@test "terminating-gateway should have healthy endpoints for s2" {
assert_upstream_has_endpoints_in_status 127.0.0.1:20000 s2 HEALTHY 1
}
@test "s1 upstream should have healthy endpoints for s2" {
assert_upstream_has_endpoints_in_status 127.0.0.1:19000 s2.default.primary HEALTHY 1
}
@test "s1 upstream should be able to connect to s2" {
run retry_default curl -s -f -d hello localhost:5000
[ "$status" -eq 0 ]
[ "$output" = "hello" ]
}

View File

@ -0,0 +1,4 @@
#!/bin/bash
snapshot_envoy_admin localhost:20000 terminating-gateway primary || true
snapshot_envoy_admin localhost:19000 s1 primary || true

View File

@ -0,0 +1,37 @@
config_entries {
bootstrap {
kind = "terminating-gateway"
name = "terminating-gateway"
services = [
{
name = "s2"
}
]
}
bootstrap {
kind = "proxy-defaults"
name = "global"
config {
protocol = "http"
}
}
bootstrap {
kind = "service-resolver"
name = "s2"
default_subset = "v1"
subsets = {
"v1" = {
filter = "Service.Meta.version == v1"
}
"v2" = {
filter = "Service.Meta.version == v2"
}
}
}
}

View File

@ -0,0 +1,9 @@
services {
name = "terminating-gateway"
kind = "terminating-gateway"
port = 8443
meta {
version = "v1"
}
}

View File

@ -0,0 +1,9 @@
services {
id = "s2-v1"
name = "s2"
port = 8182
meta {
version = "v1"
}
}

View File

@ -0,0 +1,9 @@
services {
id = "s2-v2"
name = "s2"
port = 8183
meta {
version = "v2"
}
}

View File

@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail
# wait for bootstrap to apply config entries
wait_for_config_entry terminating-gateway terminating-gateway
wait_for_config_entry proxy-defaults global
wait_for_config_entry service-resolver s2
# terminating gateway will act as s2's proxy
gen_envoy_bootstrap s1 19000
gen_envoy_bootstrap terminating-gateway 20000 primary true

View File

@ -0,0 +1,7 @@
#!/bin/bash
export REQUIRED_SERVICES="
s1 s1-sidecar-proxy
s2-v1
terminating-gateway-primary
"

View File

@ -0,0 +1,36 @@
#!/usr/bin/env bats
load helpers
@test "s1 proxy admin is up on :19000" {
retry_default curl -f -s localhost:19000/stats -o /dev/null
}
@test "terminating proxy admin is up on :20000" {
retry_default curl -f -s localhost:20000/stats -o /dev/null
}
@test "terminating-gateway-primary listener is up on :8443" {
retry_default nc -z localhost:8443
}
@test "s1 proxy listener should be up and have right cert" {
assert_proxy_presents_cert_uri localhost:21000 s1
}
@test "s1 upstream should have healthy endpoints for v1.s2" {
assert_upstream_has_endpoints_in_status 127.0.0.1:19000 v1.s2 HEALTHY 1
}
@test "terminating-gateway should have healthy endpoints for v1.s2" {
assert_upstream_has_endpoints_in_status 127.0.0.1:20000 v1.s2 HEALTHY 1
}
@test "terminating-gateway should have healthy endpoints for v2.s2" {
assert_upstream_has_endpoints_in_status 127.0.0.1:20000 v2.s2 HEALTHY 1
}
@test "s1 upstream should be able to connect to s2-v1 via terminating-gateway" {
assert_expected_fortio_name s2-v1
}

View File

@ -0,0 +1,2 @@
bind_addr = "0.0.0.0"
advertise_addr = "{{ GetInterfaceIP \"eth0\" }}"

View File

@ -0,0 +1,5 @@
services {
name = "terminating-gateway"
kind = "terminating-gateway"
port = 4431
}

View File

@ -0,0 +1 @@
# We don't want an s1 service

View File

@ -0,0 +1 @@
# We don't want an s2 service

View File

@ -0,0 +1,5 @@
#!/bin/bash
set -eEuo pipefail
gen_envoy_bootstrap terminating-gateway 19000 primary true

View File

@ -0,0 +1,3 @@
#!/bin/bash
export REQUIRED_SERVICES="terminating-gateway-primary"

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bats
load helpers
@test "terminating-gateway-primary proxy admin is up on :19000" {
retry_default curl -f -s localhost:19000/stats -o /dev/null
}
@test "terminating-gateway-primary listener is up on :4431" {
retry_default nc -z localhost:4431
}

View File

@ -580,6 +580,23 @@ services:
- *workdir-volume
network_mode: service:consul-primary
terminating-gateway-primary:
depends_on:
- consul-primary
image: "envoyproxy/envoy:v${ENVOY_VERSION}"
command:
- "envoy"
- "-c"
- "/workdir/primary/envoy/terminating-gateway-bootstrap.json"
- "-l"
- "debug"
- "--disable-hot-restart"
- "--drain-time-s"
- "1"
volumes:
- *workdir-volume
network_mode: service:consul-primary
verify-primary:
depends_on:
- consul-primary