Skip to content

Commit 9c54ea5

Browse files
mononoke/integration tests: use $LOCALIP instead of ::1 or 127.0.0.1 (#65)
Summary: Pull Request resolved: #65 Using $LOCALIP will ensure more consistent behavior when setting up the server in ipv4 or ipv6. The LOCALIP variable was also abused when it was used to override ssh client address, so SSH_IP_OVEERIDE env was created here. Lastly the result of `curl` call is now printed whenever the test failed to verify that Mononoke is running. Reviewed By: farnz Differential Revision: D24108186 fbshipit-source-id: e4b68dd2c5dd368851f0b00064088ffc442e31e0
1 parent e7d9e6f commit 9c54ea5

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

eden/mononoke/tests/integration/library.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ function get_free_socket {
5656
"$GET_FREE_SOCKET"
5757
}
5858

59+
function mononoke_address {
60+
if [[ $LOCALIP == *":"* ]]; then
61+
# ipv6, surround in brackets
62+
echo -n "[$LOCALIP]:$MONONOKE_SOCKET"
63+
else
64+
echo -n "$LOCALIP:$MONONOKE_SOCKET"
65+
fi
66+
}
67+
5968
# return random value from [1, max_value]
6069
function random_int() {
6170
max_value=$1
@@ -98,7 +107,7 @@ function mononoke {
98107
--ssl-ticket-seeds "$TEST_CERTDIR/server.pem.seeds" \
99108
--debug \
100109
--test-instance \
101-
--listening-host-port "[::1]:$MONONOKE_SOCKET" \
110+
--listening-host-port "$(mononoke_address)" \
102111
--mononoke-config-path "$TESTTMP/mononoke-config" \
103112
"${COMMON_ARGS[@]}" >> "$TESTTMP/mononoke.out" 2>&1 &
104113
export MONONOKE_PID=$!
@@ -381,7 +390,15 @@ function wait_for_mononoke {
381390

382391
if ! $SSLCURL 2>&1 | grep -q 'Empty reply'; then
383392
echo "Mononoke did not start" >&2
393+
394+
echo ""
395+
echo "Results of curl invocation"
396+
$SSLCURL -v
397+
398+
echo ""
399+
echo "Log of Mononoke server"
384400
cat "$TESTTMP/mononoke.out"
401+
385402
exit 1
386403
fi
387404
}
@@ -985,7 +1002,7 @@ function manual_scrub {
9851002

9861003
function s_client {
9871004
/usr/local/fbcode/platform007/bin/openssl s_client \
988-
-connect localhost:$MONONOKE_SOCKET \
1005+
-connect "$(mononoke_address)" \
9891006
-CAfile "${TEST_CERTDIR}/root-ca.crt" \
9901007
-cert "${TEST_CERTDIR}/localhost.crt" \
9911008
-key "${TEST_CERTDIR}/localhost.key" \
@@ -1041,7 +1058,7 @@ function start_edenapi_server {
10411058
# server. The `sslcurl` function should help with this.
10421059
GLOG_minloglevel=5 "$EDENAPI_SERVER" "$@" \
10431060
--debug \
1044-
--listen-host 127.0.0.1 \
1061+
--listen-host "$LOCALIP" \
10451062
--listen-port "$port" \
10461063
--mononoke-config-path "$TESTTMP/mononoke-config" \
10471064
--test-instance \
@@ -1077,11 +1094,11 @@ function start_edenapi_server {
10771094
}
10781095

10791096
function edenapi_make_req {
1080-
"$EDENAPI_MAKE_REQ" "$@"
1097+
"$EDENAPI_MAKE_REQ" "$@"
10811098
}
10821099

10831100
function edenapi_read_res {
1084-
"$EDENAPI_READ_RES" "$@"
1101+
"$EDENAPI_READ_RES" "$@"
10851102
}
10861103

10871104
function lfs_server {
@@ -1094,7 +1111,7 @@ function lfs_server {
10941111
opts=(
10951112
"${COMMON_ARGS[@]}"
10961113
--mononoke-config-path "$TESTTMP/mononoke-config"
1097-
--listen-host 127.0.0.1
1114+
--listen-host "$LOCALIP"
10981115
--listen-port "$port"
10991116
--test-friendly-logging
11001117
)
@@ -1432,7 +1449,7 @@ function traffic_replay() {
14321449
--loglevel warn \
14331450
--testrun \
14341451
--hgcli "$MONONOKE_HGCLI" \
1435-
--mononoke-address "[::1]:$MONONOKE_SOCKET" \
1452+
--mononoke-address "$(mononoke_address)" \
14361453
--mononoke-server-common-name localhost
14371454
}
14381455

@@ -1744,7 +1761,7 @@ function commitcloud_fill_one() {
17441761
"$MONONOKE_COMMITCLOUD_FILLONE" \
17451762
hg-to-mononoke \
17461763
--hgcli "$MONONOKE_HGCLI" \
1747-
--mononoke-address "[::1]:$MONONOKE_SOCKET" \
1764+
--mononoke-address "$(mononoke_address)" \
17481765
--mononoke-server-common-name localhost \
17491766
--cert-override "$CERTDIR/localhost.crt" \
17501767
--private-key-override "$CERTDIR/localhost.key" \
@@ -1784,7 +1801,7 @@ function commitcloud_forwardfiller_iteration() {
17841801
"$MONONOKE_COMMITCLOUD_FORWARDFILLER" \
17851802
--num-workers 1 \
17861803
--hgcli "$MONONOKE_HGCLI" \
1787-
--mononoke-address "[::1]:$MONONOKE_SOCKET" \
1804+
--mononoke-address "$(mononoke_address)" \
17881805
--mononoke-server-common-name localhost \
17891806
--cert-override "$CERTDIR/localhost.crt" \
17901807
--private-key-override "$CERTDIR/localhost.key" \

eden/mononoke/tests/integration/nossh.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ REPONAME="${REPONAME:-"$(hg config | grep remotefilelog.reponame | cut -d "=" -f
99
CA_PEM=${CA_PEM:-"${TEST_CERTS}/root-ca.crt"}
1010
PRIVATE_KEY=${PRIVATE_KEY:-"${TEST_CERTS}/localhost.key"}
1111
CERT=${CERT:-"${TEST_CERTS}/localhost.crt"}
12-
MONONOKE_PATH="[::]:${MONONOKE_SOCKET}"
12+
if [[ $LOCALIP == *":"* ]]; then
13+
# it is ipv6, surround with brackets
14+
MONONOKE_PATH="[$LOCALIP]:${MONONOKE_SOCKET}"
15+
else
16+
MONONOKE_PATH="$LOCALIP:${MONONOKE_SOCKET}"
17+
fi
1318
COMMON_NAME="localhost"
1419

1520
"$MONONOKE_HGCLI" -R "$REPONAME" serve --stdio --mononoke-path "$MONONOKE_PATH" \

eden/mononoke/tests/integration/test-lfs-server-proxy-skip-upstream.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
# Start a "server" that never responds as the upstream
1414
$ upstream_port="$(get_free_socket)"
15-
$ upstream="http://127.0.0.1:${upstream_port}/"
16-
$ ncat --sh-exec "sleep 1" --keep-open --listen 127.0.0.1 "$upstream_port" &
15+
$ upstream="http://${LOCALIP}:${upstream_port}/"
16+
$ ncat --sh-exec "sleep 1" --keep-open --listen "$LOCALIP" "$upstream_port" &
1717
$ nc_pid="$!"
1818

1919
# Start a LFS server

eden/mononoke/tests/integration/test-metadata-no-network.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ start mononoke
3232
$ wait_for_mononoke
3333

3434
pull from mononoke and log data
35-
$ MOCK_USERNAME=foobar CLIENT_DEBUG=true LOCALIP="127.0.0.1" hgmn pull
35+
$ MOCK_USERNAME=foobar CLIENT_DEBUG=true SSH_IP_OVERRIDE="$LOCALIP" hgmn pull
3636
pulling from ssh://user@dummy/repo
3737
remote: Metadata {
3838
remote: session_id: SessionId(
@@ -58,7 +58,7 @@ pull from mononoke and log data
5858
remote: }
5959
searching for changes
6060
no changes found
61-
$ MOCK_USERNAME=foobar CLIENT_DEBUG=true LOCALIP="2401:db00:31ff:ff1f:face:b00c:0:598" hgmn pull
61+
$ MOCK_USERNAME=foobar CLIENT_DEBUG=true SSH_IP_OVERRIDE="2401:db00:31ff:ff1f:face:b00c:0:598" hgmn pull
6262
pulling from ssh://user@dummy/repo
6363
remote: Metadata {
6464
remote: session_id: SessionId(

eden/mononoke/tests/integration/test-metadata.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ start mononoke
3232
$ wait_for_mononoke
3333

3434
pull from mononoke and log data
35-
$ MOCK_USERNAME=foobar CLIENT_DEBUG=true LOCALIP="127.0.0.1" hgmn pull
35+
$ MOCK_USERNAME=foobar CLIENT_DEBUG=true SSH_IP_OVERRIDE="$LOCALIP" hgmn pull
3636
pulling from ssh://user@dummy/repo
3737
remote: Metadata {
3838
remote: session_id: SessionId(

eden/scm/tests/dummyssh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ while host_index < len(sys.argv) and sys.argv[host_index].startswith("-"):
4949
if sys.argv[host_index] != "user@dummy":
5050
sys.exit(-1)
5151

52-
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get("LOCALIP", "127.0.0.1")
52+
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get(
53+
"SSH_IP_OVERRIDE", os.environ.get("LOCALIP", "127.0.0.1")
54+
)
5355

5456
log = open("dummylog", "ab")
5557
log.write(b"Got arguments")
@@ -77,9 +79,13 @@ if "hgcli" in hgcmd:
7779
cert = os.path.join(certdir, "localhost.crt")
7880
capem = os.path.join(certdir, "root-ca.crt")
7981
privatekey = os.path.join(certdir, "localhost.key")
82+
localip = os.environ.get("LOCALIP", "127.0.0.1")
83+
if ":" in localip:
84+
# this is ipv6, put it in brackets
85+
localip = "[" + localip + "]"
8086

8187
hgcmd += (
82-
" --mononoke-path [::1]:"
88+
(" --mononoke-path %s:" % localip)
8389
+ os.getenv("MONONOKE_SOCKET")
8490
+ (
8591
" --cert %s --ca-pem %s --private-key %s --common-name localhost"

eden/scm/tests/dummyssh3.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def parse_repo_path(path):
5656
if sys.argv[host_index] != "user@dummy":
5757
sys.exit(-1)
5858

59-
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get("LOCALIP", "127.0.0.1")
59+
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get(
60+
"SSH_IP_OVERRIDE", os.environ.get("LOCALIP", "127.0.0.1")
61+
)
6062

6163
log = open("dummylog", "ab")
6264
log.write(b"Got arguments")
@@ -85,9 +87,13 @@ def parse_repo_path(path):
8587
cert = os.path.join(certdir, "localhost.crt")
8688
capem = os.path.join(certdir, "root-ca.crt")
8789
privatekey = os.path.join(certdir, "localhost.key")
90+
localip = os.environ.get("LOCALIP", "127.0.0.1")
91+
if ":" in localip:
92+
# this is ipv6, put it in brackets
93+
localip = "[" + localip + "]"
8894

8995
hgcmd += (
90-
" --mononoke-path [::1]:"
96+
(" --mononoke-path %s:" % localip)
9197
+ none_throws(os.getenv("MONONOKE_SOCKET"))
9298
+ (
9399
" --cert %s --ca-pem %s --private-key %s --common-name localhost"

0 commit comments

Comments
 (0)