From 1b54c74621607de55fdadfc7823f2ce5390dea50 Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Thu, 13 Jun 2019 23:09:09 +0200 Subject: [PATCH] Remove the remaining integration tests bash scripts (#7153) Since #7073 for Certbot and letsencrypt/boulder@3918714 for Boulder have landed, the bash scripts that remained after certbot-ci are not useful anymore outside of Certbot. Only remaining place is the apacheconftest-with-pebble tox target, which leverages pebble-fetch.py script to expose a running ACME server to the apache-conf-test script. This PR refactor apacheconftest-with-pebble to use certbot-ci instead. Finally, this PR remove the remaining integration tests bash scripts, that are _common.sh, boulder-fetch.py and pebble-fetch.py. * Disconnect common and boulder-fetch * Prepare reconnection of apacheconftest to new pebble deployment logic * Finish the configuration for apacheconftest * Add executable flag to python script * Fix shebang * Delete pebble-fetch.sh --- .../apache-conf-test-pebble.py | 27 +++++++ docs/contributing.rst | 1 - tests/boulder-fetch.sh | 32 -------- tests/integration/_common.sh | 74 ------------------- tests/pebble-fetch.sh | 30 -------- tox.ini | 11 +-- 6 files changed, 29 insertions(+), 146 deletions(-) create mode 100755 certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test-pebble.py delete mode 100755 tests/boulder-fetch.sh delete mode 100755 tests/integration/_common.sh delete mode 100755 tests/pebble-fetch.sh diff --git a/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test-pebble.py b/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test-pebble.py new file mode 100755 index 000000000..34f32f2d7 --- /dev/null +++ b/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test-pebble.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +""" +This executable script wraps the apache-conf-test bash script, in order to setup a pebble instance +before its execution. Directory URL is passed through the SERVER environment variable. +""" +import os +import subprocess +import sys + +from certbot_integration_tests.utils import acme_server + +SCRIPT_DIRNAME = os.path.dirname(__file__) + + +def main(args=None): + if not args: + args = sys.argv[1:] + with acme_server.setup_acme_server('pebble', [], False) as acme_xdist: + environ = os.environ.copy() + environ['SERVER'] = acme_xdist['directory_url'] + command = [os.path.join(SCRIPT_DIRNAME, 'apache-conf-test')] + command.extend(args) + return subprocess.call(command, env=environ) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/docs/contributing.rst b/docs/contributing.rst index dad886da9..8685a0dd5 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -302,7 +302,6 @@ virtualenv like this: .. code-block:: shell . venv/bin/activate - . tests/integration/_common.sh pip install -e examples/plugins/ certbot_test plugins diff --git a/tests/boulder-fetch.sh b/tests/boulder-fetch.sh deleted file mode 100755 index f34deb74e..000000000 --- a/tests/boulder-fetch.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Download and run Boulder instance for integration testing -set -xe - -# Clone Boulder into a GOPATH-style directory structure even if Go isn't -# installed, because Boulder's docker-compose.yml file wll look for it there. -export GOPATH=${GOPATH:-$HOME/gopath} -BOULDERPATH=${BOULDERPATH:-$GOPATH/src/github.com/letsencrypt/boulder} -if [ ! -d ${BOULDERPATH} ]; then - git clone --depth=1 https://github.com/letsencrypt/boulder ${BOULDERPATH} -fi - -cd ${BOULDERPATH} - -docker-compose up -d boulder - -set +x # reduce verbosity while waiting for boulder -for n in `seq 1 150` ; do - if curl http://localhost:4000/directory 2>/dev/null; then - break - else - sleep 1 - fi -done - -if ! curl http://localhost:4000/directory 2>/dev/null; then - echo "timed out waiting for boulder to start" - exit 1 -fi - -# Setup the DNS resolution used by boulder instance to docker host -curl -X POST -d '{"ip":"10.77.77.1"}' http://localhost:8055/set-default-ipv4 diff --git a/tests/integration/_common.sh b/tests/integration/_common.sh deleted file mode 100755 index a0cf3d1b4..000000000 --- a/tests/integration/_common.sh +++ /dev/null @@ -1,74 +0,0 @@ -# The -t is required on macOS. It provides a template file path for -# the kernel to use. -root=${root:-$(mktemp -d -t leitXXXX)} -echo "Root integration tests directory: $root" -config_dir="$root/conf" -https_port=5001 -http_01_port=5002 -sources="acme/,$(ls -dm certbot*/ | tr -d ' \n')" -export root config_dir https_port http_01_port sources -certbot_path="$(command -v certbot)" -# Flags that are added here will be added to Certbot calls within -# certbot_test_no_force_renew. -other_flags="--config-dir $config_dir --work-dir $root/work" -other_flags="$other_flags --logs-dir $root/logs" - -certbot_test () { - certbot_test_no_force_renew \ - --renew-by-default \ - "$@" -} - -# Succeeds if Certbot version is at least the given version number and fails -# otherwise. This is useful for making sure Certbot has certain features -# available. The patch version is currently ignored. -# -# Arguments: -# First argument is the minimum major version -# Second argument is the minimum minor version -version_at_least () { - # Certbot major and minor version (e.g. 0.30) - major_minor=$("$certbot_path" --version 2>&1 | cut -d' ' -f2 | cut -d. -f1,2) - major=$(echo "$major_minor" | cut -d. -f1) - minor=$(echo "$major_minor" | cut -d. -f2) - # Test that either the major version is greater or major version is equal - # and minor version is greater than or equal to. - [ \( "$major" -gt "$1" \) -o \( "$major" -eq "$1" -a "$minor" -ge "$2" \) ] -} - -# Use local ACMEv2 endpoint if requested and SERVER isn't already set. -if [ "${BOULDER_INTEGRATION:-v1}" = "v2" -a -z "${SERVER:+x}" ]; then - SERVER="http://localhost:4001/directory" -fi - -# --no-random-sleep-on-renew was added in -# https://github.com/certbot/certbot/pull/6599 and first released in Certbot -# 0.30.0. -if version_at_least 0 30; then - other_flags="$other_flags --no-random-sleep-on-renew" -fi - -certbot_test_no_force_renew () { - omit_patterns="*/*.egg-info/*,*/dns_common*,*/setup.py,*/test_*,*/tests/*" - omit_patterns="$omit_patterns,*_test.py,*_test_*,certbot-apache/*" - omit_patterns="$omit_patterns,certbot-compatibility-test/*,certbot-dns*/" - omit_patterns="$omit_patterns,certbot-nginx/certbot_nginx/parser_obj.py" - coverage run \ - --append \ - --source $sources \ - --omit $omit_patterns \ - "$certbot_path" \ - --server "${SERVER:-http://localhost:4000/directory}" \ - --no-verify-ssl \ - --http-01-port $http_01_port \ - --https-port $https_port \ - --manual-public-ip-logging-ok \ - $other_flags \ - --non-interactive \ - --no-redirect \ - --agree-tos \ - --register-unsafely-without-email \ - --debug \ - -vv \ - "$@" -} diff --git a/tests/pebble-fetch.sh b/tests/pebble-fetch.sh deleted file mode 100755 index 52a7d8c98..000000000 --- a/tests/pebble-fetch.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# Download and run Pebble instance for integration testing -set -xe - -export GOPATH=${GOPATH:-$HOME/gopath} -PEBBLEPATH=${PEBBLEPATH:-$GOPATH/pebble} -if [[ ! -d ${PEBBLEPATH} ]]; then - git clone --depth=1 https://github.com/letsencrypt/pebble ${PEBBLEPATH} -fi - -cd ${PEBBLEPATH} - -docker-compose up -d - -set +x # reduce verbosity while waiting for pebble -for n in `seq 1 150` ; do - if curl -k https://localhost:14000/dir 2>/dev/null; then - break - else - sleep 1 - fi -done - -if ! curl -k https://localhost:14000/dir 2>/dev/null; then - echo "timed out waiting for pebble to start" - exit 1 -fi - -# Setup the DNS resolution used by pebble instance to docker host -curl -X POST -d '{"ip":"10.30.50.1"}' http://localhost:8055/set-default-ipv4 diff --git a/tox.ini b/tox.ini index fed30976f..404afc165 100644 --- a/tox.ini +++ b/tox.ini @@ -138,7 +138,6 @@ commands = mypy {[base]source_paths} [testenv:apacheconftest] -#basepython = python2.7 commands = {[base]pip_install} acme . certbot-apache certbot-compatibility-test {toxinidir}/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test --debian-modules @@ -147,14 +146,8 @@ passenv = [testenv:apacheconftest-with-pebble] commands = - {toxinidir}/tests/pebble-fetch.sh - {[testenv:apacheconftest]commands} -passenv = - HOME - GOPATH - PEBBLEPATH -setenv = - SERVER=https://localhost:14000/dir + {[base]pip_install} acme . certbot-apache certbot-ci certbot-compatibility-test + {toxinidir}/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test-pebble.py --debian-modules [testenv:nginxroundtrip] commands =