Adding integration tests.

Travis:
  * Downloads the Let's Encrypt client
  * Installs system requirements for client
  * Sets up virtualenv

Dockerfile:
  * Buildout for development
  * Includes numerous pacakges needed for integration testing
    (including all of the above in Travis)

test.sh:
  * If no path is defined for the LE client
    * Download the Let's Encrypt client
    * Set up virtualenv

test/amqp-integration-test.py:
  * Run client test with sensible defaults
  * One test: auth for foo.com
This commit is contained in:
William Budington 2015-06-18 15:06:25 -07:00
parent cabc5b5d1d
commit 76d76d33cd
5 changed files with 97 additions and 6 deletions

View File

@ -11,7 +11,16 @@ sudo: required
matrix:
fast_finish: true
# Only build pushes to the master branch (and PRs)
branches:
only:
- master
sudo: required
before_install:
- sudo mkdir /etc/letsencrypt
- sudo chown $USER /etc/letsencrypt
- go get golang.org/x/tools/cmd/vet
- go get golang.org/x/tools/cmd/cover
- go get github.com/golang/lint/golint
@ -24,6 +33,15 @@ before_install:
# we add a symlink.
- mkdir -p $TRAVIS_BUILD_DIR $GOPATH/src/github.com/letsencrypt
- test ! -d $GOPATH/src/github.com/letsencrypt/boulder && ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/letsencrypt/boulder || true
- git clone https://www.github.com/letsencrypt/lets-encrypt-preview.git /tmp/letsencrypt
- cd /tmp/letsencrypt
- sudo ./bootstrap/debian.sh
- virtualenv --no-site-packages -p python2 ./venv
- travis_retry ./venv/bin/pip install -r requirements.txt -e .
- "cd -"
env:
- LETSENCRYPT_VENV=/tmp/letsencrypt/venv
script:
- make -j4 # Travis has 2 cores per build instance

View File

@ -3,11 +3,23 @@ FROM golang:1.4.2
MAINTAINER J.C. Jones "jjones@letsencrypt.org"
MAINTAINER William Budington "bill@eff.org"
# Add node.js key to apt-key safely
RUN curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --import && \
gpg --export 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280 | apt-key add -
# Install dependencies packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https && \
echo deb https://deb.nodesource.com/node_0.12 jessie main > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
libltdl-dev \
rsyslog && \
rsyslog \
nodejs \
lsb-release \
rabbitmq-server \
git-core && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* \
/tmp/* \
@ -19,6 +31,17 @@ EXPOSE 4000
# Assume the configuration is in /etc/boulder
ENV BOULDER_CONFIG /go/src/github.com/letsencrypt/boulder/test/boulder-config.json
# Get the Let's Encrypt client
RUN git clone https://www.github.com/letsencrypt/lets-encrypt-preview.git /letsencrypt
WORKDIR /letsencrypt
RUN ./bootstrap/debian.sh && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* \
/tmp/* \
/var/tmp/*
RUN virtualenv --no-site-packages -p python2 venv && \
./venv/bin/pip install -r requirements.txt -e .[dev,docs,testing]
# Copy in the Boulder sources
COPY . /go/src/github.com/letsencrypt/boulder
@ -32,4 +55,5 @@ RUN go install -tags pkcs11 \
github.com/letsencrypt/boulder/cmd/boulder-va \
github.com/letsencrypt/boulder/cmd/boulder-wfe
WORKDIR /go/src/github.com/letsencrypt/boulder
CMD ["bash", "-c", "rsyslogd && /go/bin/boulder"]

21
test.sh
View File

@ -23,7 +23,12 @@ TESTDIRS="analysis \
run() {
echo "$*"
$* || FAILURE=1
if $*; then
echo "success: $*"
else
FAILURE=1
echo "failure: $*"
fi
}
@ -63,6 +68,20 @@ else
run go test -tags pkcs11 ${dirlist}
fi
if [ -z "$LETSENCRYPT_VENV" ]; then
DEFAULT_LETSENCRYPT_PATH="/tmp/letsencrypt"
LETSENCRYPT_VENV="$DEFAULT_LETSENCRYPT_PATH/venv"
run git clone https://www.github.com/letsencrypt/lets-encrypt-preview.git $DEFAULT_LETSENCRYPT_PATH
cd $DEFAULT_LETSENCRYPT_PATH
run virtualenv --no-site-packages -p python2 ./venv && \
./venv/bin/pip install -r requirements.txt -e .
cd -
fi
export LETSENCRYPT_VENV
[ ${FAILURE} == 0 ] && run python test/amqp-integration-test.py
unformatted=$(find . -name "*.go" -not -path "./Godeps/*" -print | xargs -n1 gofmt -l)

View File

@ -36,7 +36,7 @@ def start():
run('./cmd/boulder-ca')
run('./cmd/boulder-va')
def run_test():
def run_node_test():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(('localhost', 4300))
@ -64,9 +64,40 @@ def run_test():
return 0
def run_client_tests():
letsencrypt_bin = os.path.join(os.environ.get("LETSENCRYPT_VENV"), 'bin', 'letsencrypt')
tempconfig = os.path.join(tempdir, "conf")
os.mkdir(tempconfig, 0755)
tempwork = os.path.join(tempdir, "work")
os.mkdir(tempwork, 0755)
tempkey = os.path.join(tempdir, "key")
os.mkdir(tempkey, 0700)
base_cmd = letsencrypt_bin + ''' \
-a standalone \
--server http://localhost:4300/acme/new-reg \
--dvsni-port 5001 \
--config-dir "''' + tempconfig + '''" \
--work-dir "''' + tempwork + '''" \
--key-dir "''' + tempkey + '''" \
--text \
--agree-tos \
--email "" \
-vvvvvvv '''
client_run(base_cmd, '--domains foo.com auth')
def client_run(base_cmd, cmd):
if subprocess.Popen(base_cmd + cmd, shell=True).wait() != 0:
die()
try:
start()
run_test()
run_node_test()
run_client_tests()
except Exception as e:
exit_status = 1
print e

View File

@ -38,8 +38,7 @@ def run_test():
s.connect(('localhost', 4300))
break
except socket.error, e:
pass
time.sleep(1)
time.sleep(1)
if subprocess.Popen('npm install', shell=True).wait() != 0:
die()