Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 4b1ee64

Browse files
j-leath3n3rd
andauthored
Smoke testing after deployment (#270)
* Introduce smoke test and script to run it. * Run smoke tests in Dockerfile so they can be run without installing dependencies * Build smoke test docker image in travis and update documentation with how to run the smoke tests. * Fix hardcoded email and password strings in smoke test spec helpers. Signed-off-by: Othman Alkhamra <[email protected]> Co-authored-by: Marco Garofalo <[email protected]>
1 parent 5631cd6 commit 4b1ee64

12 files changed

+519
-0
lines changed

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ jobs:
3333
skip_cleanup: true
3434
on:
3535
tags: true
36+
- name: "Build & Deploy Docker for Smoke Tests"
37+
script:
38+
- $TRAVIS_BUILD_DIR/smoke/build.sh travis-build-image-smoke
39+
deploy:
40+
- provider: script
41+
script: bash $TRAVIS_BUILD_DIR/docker/ci-push-smoke $TRAVIS_TAG
42+
skip_cleanup: true
43+
on:
44+
tags: true
3645
- name: "Build & Upload Package"
3746
script:
3847
- docker run -v $TRAVIS_BUILD_DIR/deployment/helm/:/helm -w /helm --entrypoint /helm/build.sh alpine/helm:3.2.1 $TRAVIS_TAG

deployment/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [Cloud Foundry](#cloud-foundry)
88
* [Heroku](#heroku)
99
* [Configuration](#configuration)
10+
* [Testing your deployment](#testing-your-deployment)
1011

1112
## Prerequisites
1213
1. Download and extract the latest package from the [releases page](https://github.com/pivotal/postfacto/releases)
@@ -198,3 +199,12 @@ You can customise this window with the `SESSION_TIME` env variable to the `env`
198199
```bash
199200
SESSION_TIME=60 ./deploy <app-name>
200201
```
202+
203+
## Testing your deployment
204+
205+
1. Log in to the Postfacto admin dashboard
206+
1. Create a new admin user for the test to use by clicking on 'Admin Users' and then 'New Admin User'. Take note of the email and password you use, as these will be used in the next step
207+
1. Run the smoke test script from the root of the package directory:
208+
```bash
209+
./smoke-test.sh <app-url> <app-admin-url> <test-admin-email> <test-admin-password>
210+
```

deployment/smoke-test.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BASE_DIR="$(dirname "$0")"
6+
7+
if [ $# -lt 4 ]; then
8+
echo "usage: ./smoke-test.sh <base-web-url> <base-admin-url> <admin-email> <admin-password>"
9+
echo "This will run the smoke tests for your deployed instance of Postfacto."
10+
exit 1
11+
fi
12+
13+
export BASE_WEB_URL=${1}
14+
export BASE_ADMIN_URL=${2}
15+
export ADMIN_EMAIL=${3}
16+
export ADMIN_PASSWORD=${4}
17+
18+
APP_VERSION="dev"
19+
if [ -f "$BASE_DIR/VERSION" ]; then
20+
APP_VERSION=$(cat "$BASE_DIR/VERSION")
21+
fi
22+
23+
echo 'Running smoke tests...'
24+
25+
docker run -it --rm \
26+
-e BASE_WEB_URL=$BASE_WEB_URL \
27+
-e BASE_ADMIN_URL=$BASE_ADMIN_URL \
28+
-e ADMIN_EMAIL=$ADMIN_EMAIL \
29+
-e ADMIN_PASSWORD=$ADMIN_PASSWORD \
30+
postfacto/smoke:$APP_VERSION
31+
32+
echo "Smoke tests passed"

docker/ci-push-smoke

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TAG=$1
5+
REPOSITORY=postfacto/smoke
6+
VERSION_TAG="$REPOSITORY:$TAG"
7+
LATEST_TAG="$REPOSITORY:latest"
8+
9+
echo "Tagging: $VERSION_TAG"
10+
docker tag travis-build-image-smoke $VERSION_TAG
11+
12+
echo "Tagging: $LATEST_TAG"
13+
docker tag travis-build-image-smoke $LATEST_TAG
14+
15+
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
16+
17+
echo "Pushing tag: $VERSION_TAG"
18+
docker push $VERSION_TAG
19+
20+
echo "Pushing tag: $LATEST_TAG"
21+
docker push $LATEST_TAG

docker/smoke/Dockerfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM ubuntu:18.04
2+
MAINTAINER pivotal
3+
4+
SHELL ["/bin/bash", "-c"]
5+
6+
# Install dependencies
7+
RUN apt-get update && apt-get install -y autoconf bison build-essential curl git libfontconfig libpq-dev libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev libnss3 libxi6 libgconf-2-4 unzip wget
8+
9+
# Install Rbenv and Ruby
10+
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && echo 'eval "$(rbenv init -)"' >> ~/.bashrc
11+
RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
12+
ENV PATH $PATH:/root/.rbenv/bin:/root/.rbenv/shims
13+
RUN cd /root/.rbenv/plugins/ruby-build && git pull && cd -
14+
ENV RUBY_VERSION 2.6.3
15+
RUN rbenv install $RUBY_VERSION && rbenv global $RUBY_VERSION && rbenv rehash
16+
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
17+
RUN gem install bundler
18+
19+
# Install Chrome WebDriver
20+
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
21+
RUN CHROMEDRIVER_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
22+
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
23+
curl -sS -o /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
24+
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
25+
rm /tmp/chromedriver_linux64.zip && \
26+
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
27+
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
28+
29+
# Install Google Chrome
30+
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
31+
echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
32+
RUN apt-get -yqq update && apt-get -yqq install google-chrome-stable && rm -rf /var/lib/apt/lists/*
33+
34+
COPY . /smoke
35+
36+
# Install Nokogiri
37+
RUN apt-get update && \
38+
apt-get install -y pkg-config libxslt-dev libxml2-dev && \
39+
gem install nokogiri -- --use-system-libraries
40+
41+
RUN cd smoke && bundle install
42+
43+
WORKDIR "/smoke"
44+
CMD ["bundle", "exec", "rspec", "--format", "documentation"]

package.sh

+11
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ cp -r deployment/upgrade-heroku.sh package/heroku/upgrade.sh
111111
cp -r deployment/mixpanel.sh package/heroku/mixpanel.sh
112112
chmod u+x package/heroku/*.sh
113113

114+
# Smoke tests
115+
116+
cp -r deployment/smoke-test.sh package
117+
chmod u+x package/smoke-test.sh
118+
119+
# Persist version
120+
121+
if [ $# -gt 0 ]; then
122+
echo $1 > package/VERSION
123+
fi
124+
114125
# Docs
115126

116127
cp deployment/README.md package

smoke/.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.3

smoke/Gemfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Postfacto, a free, open-source and self-hosted retro tool aimed at helping
3+
# remote teams.
4+
#
5+
# Copyright (C) 2016 - Present Pivotal Software, Inc.
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
#
9+
# it under the terms of the GNU Affero General Public License as
10+
#
11+
# published by the Free Software Foundation, either version 3 of the
12+
#
13+
# License, or (at your option) any later version.
14+
#
15+
#
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
#
19+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
#
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
#
23+
# GNU Affero General Public License for more details.
24+
#
25+
#
26+
#
27+
# You should have received a copy of the GNU Affero General Public License
28+
#
29+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
30+
#
31+
source 'https://rubygems.org'
32+
33+
ruby '~> 2.6'
34+
35+
group :development, :test do
36+
gem 'rspec'
37+
gem 'rspec-retry'
38+
gem 'capybara', '>= 3.28.0'
39+
gem 'selenium-webdriver', '>= 3.141.0'
40+
end

smoke/Gemfile.lock

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.7.0)
5+
public_suffix (>= 2.0.2, < 5.0)
6+
capybara (3.32.2)
7+
addressable
8+
mini_mime (>= 0.1.3)
9+
nokogiri (~> 1.8)
10+
rack (>= 1.6.0)
11+
rack-test (>= 0.6.3)
12+
regexp_parser (~> 1.5)
13+
xpath (~> 3.2)
14+
childprocess (3.0.0)
15+
diff-lcs (1.3)
16+
mini_mime (1.0.2)
17+
mini_portile2 (2.4.0)
18+
nokogiri (1.10.9)
19+
mini_portile2 (~> 2.4.0)
20+
public_suffix (4.0.5)
21+
rack (2.2.2)
22+
rack-test (1.1.0)
23+
rack (>= 1.0, < 3)
24+
regexp_parser (1.7.0)
25+
rspec (3.9.0)
26+
rspec-core (~> 3.9.0)
27+
rspec-expectations (~> 3.9.0)
28+
rspec-mocks (~> 3.9.0)
29+
rspec-core (3.9.2)
30+
rspec-support (~> 3.9.3)
31+
rspec-expectations (3.9.2)
32+
diff-lcs (>= 1.2.0, < 2.0)
33+
rspec-support (~> 3.9.0)
34+
rspec-mocks (3.9.1)
35+
diff-lcs (>= 1.2.0, < 2.0)
36+
rspec-support (~> 3.9.0)
37+
rspec-retry (0.6.2)
38+
rspec-core (> 3.3)
39+
rspec-support (3.9.3)
40+
rubyzip (2.3.0)
41+
selenium-webdriver (3.142.7)
42+
childprocess (>= 0.5, < 4.0)
43+
rubyzip (>= 1.2.2)
44+
xpath (3.2.0)
45+
nokogiri (~> 1.8)
46+
47+
PLATFORMS
48+
ruby
49+
50+
DEPENDENCIES
51+
capybara (>= 3.28.0)
52+
rspec
53+
rspec-retry
54+
selenium-webdriver (>= 3.141.0)
55+
56+
RUBY VERSION
57+
ruby 2.6.3p62
58+
59+
BUNDLED WITH
60+
1.17.3

smoke/build.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
#
3+
# Postfacto, a free, open-source and self-hosted retro tool aimed at helping
4+
# remote teams.
5+
#
6+
# Copyright (C) 2016 - Present Pivotal Software, Inc.
7+
#
8+
# This program is free software: you can redistribute it and/or modify
9+
#
10+
# it under the terms of the GNU Affero General Public License as
11+
#
12+
# published by the Free Software Foundation, either version 3 of the
13+
#
14+
# License, or (at your option) any later version.
15+
#
16+
#
17+
#
18+
# This program is distributed in the hope that it will be useful,
19+
#
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
#
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
#
24+
# GNU Affero General Public License for more details.
25+
#
26+
#
27+
#
28+
# You should have received a copy of the GNU Affero General Public License
29+
#
30+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
31+
#
32+
set -e
33+
34+
TAG=${1:-"postfacto/smoke:dev"}
35+
BASE_DIR="$(dirname "$0")"
36+
37+
docker build $BASE_DIR -f $BASE_DIR/../docker/smoke/Dockerfile -t $TAG

0 commit comments

Comments
 (0)