Skip to content

Commit

Permalink
[CONSUL-412] Run test-sds-server in single container (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
cocolavayen authored and joselo85 committed Dec 21, 2022
1 parent b3ad08e commit 0fe262f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
5 changes: 4 additions & 1 deletion build-support-windows/Dockerfile-consul-dev-windows
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ COPY --from=envoy ["C:/Program Files/envoy/", "C:/envoy/"]
RUN choco install openssl -yf
RUN choco install jq -yf

# Install Bats
ENV BATS_URL=https://github.com/bats-core/bats-core/archive/refs/tags/v1.7.0.zip
RUN curl %BATS_URL% -L -o bats.zip

RUN mkdir bats-core
RUN tar -xf bats.zip -C bats-core --strip-components=1
RUN cd "C:\\Program Files\\Git\\bin" && bash.exe -c "/c/bats-core/install.sh /c/bats"
Expand All @@ -30,6 +30,9 @@ RUN curl %JAEGER_URL% -L -o jaeger.tar.gz
RUN mkdir jaeger
RUN tar -xf jaeger.tar.gz -C jaeger --strip-components=1

# Copy test-sds-server binary and certs
COPY --from=test-sds-server ["C:/go/src/", "C:/test-sds-server/"]

EXPOSE 8300
EXPOSE 8301 8301/udp 8302 8302/udp
EXPOSE 8500 8600 8600/udp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM golang:1.18.1-nanoserver-1809
WORKDIR /go/src
COPY ./ .

RUN go build -v -o test-sds-server sds.go
RUN go build -v -o test-sds-server.exe sds.go

CMD ["/go/src/test-sds-server"]
CMD ["test-sds-server.exe"]
11 changes: 7 additions & 4 deletions test/integration/connect/envoy/helpers.windows.bash
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ function assert_cert_signed_by_ca {
if [ -n "$SERVER_NAME" ]; then
SNI_FLAG="-servername $SERVER_NAME"
fi
CERT=$(openssl s_client -connect $HOSTPORT $SNI_FLAG -CAfile $CA_FILE -showcerts </dev/null)

# Fix in the CA_FILE parameter: for Windows environments, the root path starts with "/c"
CERT=$(openssl s_client -connect $HOSTPORT $SNI_FLAG -CAfile "/c/$CA_FILE" -showcerts </dev/null)

echo "GOT CERT:"
echo "$CERT"
Expand Down Expand Up @@ -255,7 +257,7 @@ function assert_envoy_network_rbac_policy_count {
}

function get_envoy_network_rbac_once {
local HOSTPORT=$1
local HOSTPORT=$1
run curl -s -f $HOSTPORT/config_dump
[ "$status" -eq 0 ]
echo "$output" | jq --raw-output '.configs[2].dynamic_listeners[].active_state.listener.filter_chains[0].filters[] | select(.name == "envoy.filters.network.rbac") | .typed_config'
Expand Down Expand Up @@ -887,7 +889,8 @@ function get_upstream_fortio_name {
if [ "${HOST:0:8}" = "https://" ]; then
HOST="${HOST:8}"
PROTO="https://"
extra_args="${extra_args} --cacert /workdir/test-sds-server/certs/ca-root.crt"
# Fix in the CA_FILE parameter: for Windows environments, the root path starts with "/c"
extra_args="${extra_args} --cacert /c/workdir/test-sds-server/certs/ca-root.crt"
fi
# We use --resolve instead of setting a Host header since we need the right
# name to be sent for SNI in some cases too.
Expand All @@ -905,7 +908,7 @@ function get_upstream_fortio_name {

function assert_expected_fortio_name {
local EXPECT_NAME=$1
local HOST=${2:-"localhost"} $2
local HOST=${2:-"localhost"}
local PORT=${3:-5000}
local URL_PREFIX=${4:-""}
local DEBUG_HEADER_VALUE="${5:-""}"
Expand Down
17 changes: 9 additions & 8 deletions test/integration/connect/envoy/run-tests.windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ function suite_setup {
--net=none \
"${HASHICORP_DOCKER_PROXY}/windows/kubernetes/pause" &>/dev/null
# TODO(rb): switch back to "${HASHICORP_DOCKER_PROXY}/google/pause" once that is cached

# pre-build the test-sds-server container
echo "Rebuilding 'test-sds-server' image..."
docker.exe build -t test-sds-server -f Dockerfile-test-sds-server-windows test-sds-server
}

function suite_teardown {
Expand Down Expand Up @@ -811,6 +807,8 @@ function run_container_zipkin {
}

function run_container_jaeger {
echo "Starting Jaeger service..."

local DC=${1:-primary}
local CONTAINER_NAME="$SINGLE_CONTAINER_BASE_NAME"-"$DC"_1

Expand All @@ -819,10 +817,13 @@ function run_container_jaeger {
}

function run_container_test-sds-server {
docker.exe run -d --name $(container_name) \
$WORKDIR_SNIPPET \
$(network_snippet primary) \
"test-sds-server"
echo "Starting test-sds-server"

local DC=${1:-primary}
local CONTAINER_NAME="$SINGLE_CONTAINER_BASE_NAME"-"$DC"_1

docker.exe exec -d $CONTAINER_NAME bash -c "cd /c/test-sds-server &&
./test-sds-server.exe"
}

function container_name {
Expand Down

0 comments on commit 0fe262f

Please sign in to comment.