Skip to content

Commit 6516ad4

Browse files
committed
test: reshape proxy regression to a customer-experience end-to-end test
The earlier commit introspected RapidClient#build_client directly, which overlapped with the unit tests already added in PR #68. Per review feedback, replace it with a customer-shaped test: bind RIE Runtime API to the container's own non-loopback hostname (so Ruby's URI.find_proxy does not silently bypass the proxy for loopback), set HTTP_PROXY on the image to an unreachable address, and have the handler simply return "success". With the fix the RIC bypasses HTTP_PROXY and the handler runs; without it the RIC tries the unreachable proxy for next_invocation and every suite in the image fails.
1 parent d5a0a8d commit 6516ad4

4 files changed

Lines changed: 48 additions & 30 deletions

File tree

‎Dockerfile.test‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,18 @@ ADD test/dockerized/tasks /var/task
55
RUN gem uninstall aws_lambda_ric --executables
66
ADD pkg /tmp/pkg
77
RUN gem install /tmp/pkg/aws_lambda_ric-*.gem
8-
RUN rm -rf /tmp/pkg
8+
RUN rm -rf /tmp/pkg
9+
10+
# Route every HTTP call in the container through an unreachable proxy. The
11+
# whole suite runs with this: after the fix the RIC bypasses it for Runtime
12+
# API traffic and every test still passes; before the fix the RIC would
13+
# try to reach 127.0.0.1:1, connect refused, and every test would fail.
14+
ENV HTTP_PROXY=http://127.0.0.1:1
15+
ENV http_proxy=http://127.0.0.1:1
16+
17+
# Custom entrypoint binds RIE's Runtime API to the container's own hostname
18+
# (a non-loopback address), so Ruby's URI.find_proxy loopback bypass does
19+
# not silently hide the bug.
20+
COPY test/dockerized/entrypoint.sh /entrypoint.sh
21+
RUN chmod +x /entrypoint.sh
22+
ENTRYPOINT ["/entrypoint.sh"]

‎test/dockerized/entrypoint.sh‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
# Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
5+
set -eu
6+
7+
if [ "$#" -ne 1 ]; then
8+
echo "entrypoint requires the handler name as first argument" 1>&2
9+
exit 142
10+
fi
11+
export _HANDLER="$1"
12+
13+
# Resolve the container's own hostname to its non-loopback IPv4 (docker
14+
# writes this to /etc/hosts for us on eth0).
15+
RIC_HOST="$(getent hosts "$HOSTNAME" | awk '{print $1; exit}')"
16+
if [ -z "$RIC_HOST" ]; then
17+
echo "entrypoint could not resolve \$HOSTNAME ($HOSTNAME)" 1>&2
18+
exit 143
19+
fi
20+
21+
exec /usr/local/bin/aws-lambda-rie \
22+
--runtime-api-address "$RIC_HOST:9001" \
23+
/var/runtime/bootstrap

‎test/dockerized/suites/proxy.json‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"request": {},
77
"assertions": [
88
{
9-
"response": {
10-
"baseline_uses_proxy": true,
11-
"ric_bypasses_proxy": true
12-
}
9+
"response": "success"
1310
}
1411
]
1512
}

‎test/dockerized/tasks/proxy.rb‎

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
require 'aws_lambda_ric/lambda_server'
2-
require 'net/http'
3-
require 'uri'
1+
# Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# The image (see Dockerfile.test) runs with HTTP_PROXY pointed at an
4+
# unreachable address and RIE's Runtime API bound to a non-loopback
5+
# hostname. If the proxy-bypass fix (PR #68) is in place the RIC bypasses
6+
# HTTP_PROXY for Runtime API calls and this handler runs to completion,
7+
# returning "success". Without the fix the RIC would try to reach the
8+
# unreachable proxy for next_invocation and this handler would never run.
49

510
def check_proxy_bypass(event:, context:)
6-
original_http_proxy = ENV['HTTP_PROXY']
7-
original_https_proxy = ENV['HTTPS_PROXY']
8-
ENV['HTTP_PROXY'] = 'http://proxy.example.invalid:3128'
9-
ENV['HTTPS_PROXY'] = 'http://proxy.example.invalid:3128'
10-
11-
uri = URI('http://169.254.100.1:9001/2018-06-01/runtime/invocation/next')
12-
13-
# Baseline: a bare Net::HTTP.new (the pre-fix pattern) DOES pick up
14-
# HTTP_PROXY via :ENV proxy resolution for this non-loopback host.
15-
baseline_client = Net::HTTP.new(uri.host, uri.port)
16-
17-
# Under test: RapidClient#build_client MUST NOT pick up HTTP_PROXY.
18-
rapid_client = RapidClient.new('169.254.100.1:9001', 'ric-proxy-regression')
19-
under_test = rapid_client.send(:build_client, uri)
20-
21-
{
22-
baseline_uses_proxy: baseline_client.proxy?,
23-
ric_bypasses_proxy: !under_test.proxy?
24-
}
25-
ensure
26-
ENV['HTTP_PROXY'] = original_http_proxy
27-
ENV['HTTPS_PROXY'] = original_https_proxy
11+
'success'
2812
end

0 commit comments

Comments
 (0)