Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Fix thrift proxy tests #13220

Merged
merged 24 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/extensions/filters/network/thrift_proxy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ envoy_extension_cc_test(
"//test/extensions/filters/network/thrift_proxy/driver:generate_fixture",
],
extension_name = "envoy.filters.network.thrift_proxy",
tags = ["fails_on_windows"],
deps = [
":integration_lib",
":utility_lib",
Expand All @@ -350,7 +349,6 @@ envoy_extension_cc_test(
"//test/extensions/filters/network/thrift_proxy/driver:generate_fixture",
],
extension_name = "envoy.filters.network.thrift_proxy",
tags = ["fails_on_windows"],
deps = [
":integration_lib",
":utility_lib",
Expand Down
2 changes: 2 additions & 0 deletions test/extensions/filters/network/thrift_proxy/driver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from fbthrift import THeaderTransport
from twitter.common.rpc.finagle.protocol import TFinagleProtocol

sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')

class TRecordingTransport(TTransport.TTransportBase):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,11 @@
set -e

function usage() {
echo "Usage: $0 <mode> <transport> <protocol> -s [multiplex-service] -H [headers] method [param...]"
echo "Usage: $0 <mode> <transport> <protocol> -s [multiplex-service] -H [headers] -T [TempPath] method [param...]"
echo "where mode is success, exception, or idl-exception"
exit 1
}

FIXTURE_DIR="${TEST_TMPDIR}"
mkdir -p "${FIXTURE_DIR}"

DRIVER_DIR="${TEST_SRCDIR}/envoy/test/extensions/filters/network/thrift_proxy/driver"

if [[ -z "${TEST_UDSDIR}" ]]; then
TEST_UDSDIR=$(mktemp -d /tmp/envoy_test_thrift.XXXXXX)
fi

MODE="$1"
TRANSPORT="$2"
PROTOCOL="$3"
Expand All @@ -35,15 +26,18 @@ fi

MULTIPLEX=
HEADERS=
while getopts ":s:H:" opt; do
TEST_TMPDIR=
while getopts ":s:H:T:" opt; do
case ${opt} in
s)
MULTIPLEX=$OPTARG
;;
H)
HEADERS=$OPTARG
;;

T)
TEST_TMPDIR=$OPTARG
;;
\?)
echo "Invalid Option: -$OPTARG" >&2
exit 1
Expand All @@ -62,11 +56,24 @@ if [[ "${METHOD}" == "" ]]; then
fi
shift

SOCKET="${TEST_UDSDIR}/fixture.sock"
rm -f "${SOCKET}"
FIXTURE_DIR="${TEST_TMPDIR}"
mkdir -p "${FIXTURE_DIR}"

DRIVER_DIR="${TEST_SRCDIR}/envoy/test/extensions/filters/network/thrift_proxy/driver"


while
port=$(shuf -n 1 -i 49152-65535)
netstat -atn | grep -q "$port" >> /dev/null
do
continue
done


SOCKET="127.0.0.1:${port}"
echo "Using address ${SOCKET}"

SERVICE_FLAGS=("--addr" "${SOCKET}"
"--unix"
"--response" "${MODE}"
"--transport" "${TRANSPORT}"
"--protocol" "${PROTOCOL}")
Expand All @@ -83,26 +90,20 @@ else
fi

# start server
"${DRIVER_DIR}/server" "${SERVICE_FLAGS[@]}" &
"${DRIVER_DIR}/server.py" "${SERVICE_FLAGS[@]}" &
SERVER_PID="$!"

trap 'kill ${SERVER_PID}' EXIT;

while [[ ! -a "${SOCKET}" ]]; do
sleep 0.1

if ! kill -0 "${SERVER_PID}"; then
echo "server failed to start"
exit 1
fi
done

if [[ -n "$HEADERS" ]]; then
SERVICE_FLAGS+=("--headers")
SERVICE_FLAGS+=("$HEADERS")
fi

"${DRIVER_DIR}/client" "${SERVICE_FLAGS[@]}" \
davinci26 marked this conversation as resolved.
Show resolved Hide resolved
echo "${METHOD}" "$@"

"${DRIVER_DIR}/client.py" "${SERVICE_FLAGS[@]}" \
--request "${REQUEST_FILE}" \
--response "${RESPONSE_FILE}" \
"${METHOD}" "$@"
2 changes: 2 additions & 0 deletions test/extensions/filters/network/thrift_proxy/driver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from fbthrift import THeaderTransport
from finagle import TFinagleServerProcessor, TFinagleServerProtocol

sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')

class SuccessHandler:

Expand Down
4 changes: 4 additions & 0 deletions test/extensions/filters/network/thrift_proxy/integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ void BaseThriftIntegrationTest::preparePayloads(const PayloadOptions& options,
args.push_back(absl::StrJoin(headers, ","));
}

auto temp_path = TestEnvironment::temporaryDirectory();
args.push_back("-T");
args.push_back(temp_path);
davinci26 marked this conversation as resolved.
Show resolved Hide resolved

args.push_back(options.method_name_);
std::copy(options.method_args_.begin(), options.method_args_.end(), std::back_inserter(args));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ INSTANTIATE_TEST_SUITE_P(FramedTwitter, ThriftTwitterConnManagerIntegrationTest,
Values(false, true)),
paramToString);

// This test relies on an old apache thrift python package
// that is only available in python2. Disabling the test on Windows.
#ifndef WIN32
// Because of the protocol upgrade requests and the difficulty of separating them, we test this
// protocol independently.
TEST_P(ThriftTwitterConnManagerIntegrationTest, Success) {
Expand Down Expand Up @@ -458,6 +461,7 @@ TEST_P(ThriftTwitterConnManagerIntegrationTest, Success) {
counter = test_server_->counter("thrift.thrift_stats.response_success");
EXPECT_EQ(2U, counter->value());
}
#endif

} // namespace ThriftProxy
} // namespace NetworkFilters
Expand Down