test: docker: Update to Alpine 3.16 Alpine 3.11 has been EOL since 2021-11-01 and 3.16 is the oldest version that's still supported. This upgrade requires two fixes: 1) Moving to Python 3 2) Working around the OpenSSH 9 scp backwards-incompatible API change For #1, the parent changes removed the inline Python usage and then updated the two Python scripts used by tests to support both Python 2 and 3. Modifying their shebang lines to explicitly use `python3` is all that's needed in this change. For #2, the solution adopted by upstream was to always prefer using curl to download the commit-msg hook script instead of scp. Using that for the tests is a simple fix. Change-Id: I4ea8dfdf98ace06918ee6d680b8a3b77f7523601
diff --git a/test/docker/run_tests/Dockerfile b/test/docker/run_tests/Dockerfile index dd5ba8c..c4a68c6 100755 --- a/test/docker/run_tests/Dockerfile +++ b/test/docker/run_tests/Dockerfile
@@ -1,4 +1,4 @@ -FROM alpine:3.11 +FROM alpine:3.16 ARG UID=1000 ARG GID=1000 @@ -7,7 +7,7 @@ ENV RUN_TESTS_DIR task/test/docker/run_tests ENV WORKSPACE $USER_HOME/workspace -RUN apk --update add --no-cache openssh bash git python2 shadow util-linux openssl xxd curl jq +RUN apk --update add --no-cache openssh bash git python3 shadow util-linux openssl xxd curl jq RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config RUN groupadd -f -g $GID users2
diff --git a/test/docker/run_tests/create-test-project-and-changes.sh b/test/docker/run_tests/create-test-project-and-changes.sh index 6192461..fbf3ba7 100755 --- a/test/docker/run_tests/create-test-project-and-changes.sh +++ b/test/docker/run_tests/create-test-project-and-changes.sh
@@ -1,21 +1,28 @@ #!/usr/bin/env bash -PORT=29418 +SSH_PORT=29418 +HTTP_PORT=8080 -gssh() { ssh -x -p "$PORT" "$GERRIT_HOST" gerrit "$@" ; } # cmd [args]... +gssh() { ssh -x -p "$SSH_PORT" "$GERRIT_HOST" gerrit "$@" ; } # cmd [args]... create_project() { # project echo "Creating a test project ..." gssh create-project "$1" --owner "Administrators" --submit-type "MERGE_IF_NECESSARY" - cd "$WORKSPACE" && git clone ssh://"$GERRIT_HOST":"$PORT"/"$1" "$1" && cd "$1" - gitdir=$(git rev-parse --git-dir) - scp -p -P "$PORT" "$USER"@"$GERRIT_HOST":hooks/commit-msg "$gitdir"/hooks/ + cd "$WORKSPACE" && git clone ssh://"$GERRIT_HOST":"$SSH_PORT"/"$1" "$1" && cd "$1" + install_changeid_hook +} + +install_changeid_hook() { + local hook=$(git rev-parse --git-dir)/hooks/commit-msg + mkdir -p "$(dirname "$hook")" + curl -Lo "$hook" "http://$GERRIT_HOST:$HTTP_PORT/tools/hooks/commit-msg" + chmod +x "$hook" } create_change() { # subject project touch readme.txt && echo "$(date)" >> readme.txt git add . && git commit -m "$1" - git push ssh://"$GERRIT_HOST":"$PORT"/"$2" HEAD:refs/for/master + git push ssh://"$GERRIT_HOST":"$SSH_PORT"/"$2" HEAD:refs/for/master } create_project 'test'
diff --git a/test/lib/lib_helper.sh b/test/lib/lib_helper.sh index 3e6f0b5..cccf432 100644 --- a/test/lib/lib_helper.sh +++ b/test/lib/lib_helper.sh
@@ -258,9 +258,10 @@ echo "${url##*\/}" | tr -d -c '[:digit:]' } -install_changeid_hook() { # repo +install_changeid_hook() { local hook=$(git rev-parse --git-dir)/hooks/commit-msg - scp -p -P "$PORT" "$SERVER":hooks/commit-msg "$hook" + mkdir -p "$(dirname "$hook")" + curl -Lo "$hook" "http://$SERVER:$HTTP_PORT/tools/hooks/commit-msg" chmod +x "$hook" } @@ -269,7 +270,7 @@ git init "$repo" ( cd "$repo" - install_changeid_hook "$repo" + install_changeid_hook git fetch "$remote" "$ref" if ! git checkout FETCH_HEAD ; then if [ "$init" = "--initial-commit" ] ; then
diff --git a/test/strip_non_applicable.py b/test/strip_non_applicable.py index 4ba3b9c..a0ce4fa 100755 --- a/test/strip_non_applicable.py +++ b/test/strip_non_applicable.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2021 The Android Open Source Project #
diff --git a/test/strip_non_invalid.py b/test/strip_non_invalid.py index 4889a50..0227c79 100755 --- a/test/strip_non_invalid.py +++ b/test/strip_non_invalid.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2021 The Android Open Source Project #