Skip to content

Commit

Permalink
[CONSUL-429] Replace Docker run with Docker exec (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
joselo85 committed Dec 21, 2022
1 parent de41910 commit 8b247ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build-support-windows/Dockerfile-consul-local-windows
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ EXPOSE 19000 19001 19002 19003 19004
EXPOSE 21000 21001 21002 21003 21004
EXPOSE 5000 1234 2345

RUN SETX /M path "%PATH%;C:\consul;C:\envoy;C:\fortio;C:\jaeger;C:\Program Files\Git\bin;C:\Program Files\OpenSSL-Win64\bin;C:\bats\bin\bats;C:\ProgramData\chocolatey\lib\jq\tools;C:\socat;"
RUN SETX /M path "%PATH%;C:\consul;C:\envoy;C:\fortio;C:\jaeger;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\OpenSSL-Win64\bin;C:\bats\bin\;C:\ProgramData\chocolatey\lib\jq\tools;C:\socat;"
13 changes: 12 additions & 1 deletion test/integration/connect/envoy/helpers.windows.bash
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,21 @@ function kill_envoy {
tskill $PID
}

# This function is needed since socats SYSTEM isn't working.
function split_lines_in_stats {
local MATCH=$1
local FILE=$2

sed -i "s/$MATCH/\n$MATCH/g" $FILE
}

function must_match_in_statsd_logs {
local DC=${2:-primary}
local FILE="/c/workdir/${DC}/statsd/statsd.log"

split_lines_in_stats envoy $FILE

run cat /workdir/${DC}/statsd/statsd.log
run cat $FILE
echo "$output"
COUNT=$( echo "$output" | grep -Ec $1 )

Expand Down
10 changes: 3 additions & 7 deletions test/integration/connect/envoy/run-tests.windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -803,15 +803,11 @@ function run_container_terminating-gateway-primary {
}

function run_container_fake-statsd {
local CONTAINER_NAME="$SINGLE_CONTAINER_BASE_NAME"-"primary"_1
# This magic SYSTEM incantation is needed since Envoy doesn't add newlines and so
# we need each packet to be passed to echo to add a new line before
# appending.
docker.exe run -d --name $(container_name) \
$WORKDIR_SNIPPET \
$(network_snippet primary) \
"${HASHICORP_DOCKER_PROXY}/windows/socat" \
-u UDP-RECVFROM:8125,fork,reuseaddr \
SYSTEM:'xargs -0 echo >> /workdir/primary/statsd/statsd.log'
# appending. But it does not work on Windows.
docker.exe exec -d $CONTAINER_NAME bash -c "socat -u UDP-RECVFROM:8125,fork,reuseaddr OPEN:/workdir/primary/statsd/statsd.log,create,append"
}

function run_container_zipkin {
Expand Down

0 comments on commit 8b247ad

Please sign in to comment.