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

Smoke testing after deployment #270

Merged
merged 5 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ jobs:
skip_cleanup: true
on:
tags: true
- name: "Build & Deploy Docker for Smoke Tests"
script:
- $TRAVIS_BUILD_DIR/smoke/build.sh travis-build-image-smoke
deploy:
- provider: script
script: bash $TRAVIS_BUILD_DIR/docker/ci-push-smoke $TRAVIS_TAG
skip_cleanup: true
on:
tags: true
- name: "Build & Upload Package"
script:
- docker run -v $TRAVIS_BUILD_DIR/deployment/helm/:/helm -w /helm --entrypoint /helm/build.sh alpine/helm:3.2.1 $TRAVIS_TAG
Expand Down
10 changes: 10 additions & 0 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [Cloud Foundry](#cloud-foundry)
* [Heroku](#heroku)
* [Configuration](#configuration)
* [Testing your deployment](#testing-your-deployment)

## Prerequisites
1. Download and extract the latest package from the [releases page](https://github.com/pivotal/postfacto/releases)
Expand Down Expand Up @@ -198,3 +199,12 @@ You can customise this window with the `SESSION_TIME` env variable to the `env`
```bash
SESSION_TIME=60 ./deploy <app-name>
```

## Testing your deployment

1. Log in to the Postfacto admin dashboard
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
1. Run the smoke test script from the root of the package directory:
```bash
./smoke-test.sh <app-url> <app-admin-url> <test-admin-email> <test-admin-password>
```
32 changes: 32 additions & 0 deletions deployment/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

BASE_DIR="$(dirname "$0")"

if [ $# -lt 4 ]; then
echo "usage: ./smoke-test.sh <base-web-url> <base-admin-url> <admin-email> <admin-password>"
echo "This will run the smoke tests for your deployed instance of Postfacto."
exit 1
fi

export BASE_WEB_URL=${1}
export BASE_ADMIN_URL=${2}
export ADMIN_EMAIL=${3}
export ADMIN_PASSWORD=${4}

APP_VERSION="dev"
if [ -f "$BASE_DIR/VERSION" ]; then
APP_VERSION=$(cat "$BASE_DIR/VERSION")
fi

echo 'Running smoke tests...'

docker run -it --rm \
-e BASE_WEB_URL=$BASE_WEB_URL \
-e BASE_ADMIN_URL=$BASE_ADMIN_URL \
-e ADMIN_EMAIL=$ADMIN_EMAIL \
-e ADMIN_PASSWORD=$ADMIN_PASSWORD \
postfacto/smoke:$APP_VERSION

echo "Smoke tests passed"
21 changes: 21 additions & 0 deletions docker/ci-push-smoke
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e

TAG=$1
REPOSITORY=postfacto/smoke
VERSION_TAG="$REPOSITORY:$TAG"
LATEST_TAG="$REPOSITORY:latest"

echo "Tagging: $VERSION_TAG"
docker tag travis-build-image-smoke $VERSION_TAG

echo "Tagging: $LATEST_TAG"
docker tag travis-build-image-smoke $LATEST_TAG

echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin

echo "Pushing tag: $VERSION_TAG"
docker push $VERSION_TAG

echo "Pushing tag: $LATEST_TAG"
docker push $LATEST_TAG
44 changes: 44 additions & 0 deletions docker/smoke/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ubuntu:18.04
MAINTAINER pivotal

SHELL ["/bin/bash", "-c"]

# Install dependencies
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

# Install Rbenv and Ruby
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && echo 'eval "$(rbenv init -)"' >> ~/.bashrc
RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
ENV PATH $PATH:/root/.rbenv/bin:/root/.rbenv/shims
RUN cd /root/.rbenv/plugins/ruby-build && git pull && cd -
ENV RUBY_VERSION 2.6.3
RUN rbenv install $RUBY_VERSION && rbenv global $RUBY_VERSION && rbenv rehash
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN gem install bundler

# Install Chrome WebDriver
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
RUN CHROMEDRIVER_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
curl -sS -o /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
rm /tmp/chromedriver_linux64.zip && \
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver

# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
RUN apt-get -yqq update && apt-get -yqq install google-chrome-stable && rm -rf /var/lib/apt/lists/*

COPY . /smoke

# Install Nokogiri
RUN apt-get update && \
apt-get install -y pkg-config libxslt-dev libxml2-dev && \
gem install nokogiri -- --use-system-libraries

RUN cd smoke && bundle install

WORKDIR "/smoke"
CMD ["bundle", "exec", "rspec", "--format", "documentation"]
11 changes: 11 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ cp -r deployment/upgrade-heroku.sh package/heroku/upgrade.sh
cp -r deployment/mixpanel.sh package/heroku/mixpanel.sh
chmod u+x package/heroku/*.sh

# Smoke tests

cp -r deployment/smoke-test.sh package
chmod u+x package/smoke-test.sh

# Persist version

if [ $# -gt 0 ]; then
echo $1 > package/VERSION
fi

# Docs

cp deployment/README.md package
Expand Down
1 change: 1 addition & 0 deletions smoke/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.3
40 changes: 40 additions & 0 deletions smoke/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Postfacto, a free, open-source and self-hosted retro tool aimed at helping
# remote teams.
#
# Copyright (C) 2016 - Present Pivotal Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
#
# it under the terms of the GNU Affero General Public License as
#
# published by the Free Software Foundation, either version 3 of the
#
# License, or (at your option) any later version.
#
#
#
# This program is distributed in the hope that it will be useful,
#
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#
# GNU Affero General Public License for more details.
#
#
#
# You should have received a copy of the GNU Affero General Public License
#
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
source 'https://rubygems.org'

ruby '~> 2.6'

group :development, :test do
gem 'rspec'
gem 'rspec-retry'
gem 'capybara', '>= 3.28.0'
gem 'selenium-webdriver', '>= 3.141.0'
end
60 changes: 60 additions & 0 deletions smoke/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
capybara (3.32.2)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
childprocess (3.0.0)
diff-lcs (1.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
public_suffix (4.0.5)
rack (2.2.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
regexp_parser (1.7.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.9.3)
rubyzip (2.3.0)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
xpath (3.2.0)
nokogiri (~> 1.8)

PLATFORMS
ruby

DEPENDENCIES
capybara (>= 3.28.0)
rspec
rspec-retry
selenium-webdriver (>= 3.141.0)

RUBY VERSION
ruby 2.6.3p62

BUNDLED WITH
1.17.3
37 changes: 37 additions & 0 deletions smoke/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
#
# Postfacto, a free, open-source and self-hosted retro tool aimed at helping
# remote teams.
#
# Copyright (C) 2016 - Present Pivotal Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
#
# it under the terms of the GNU Affero General Public License as
#
# published by the Free Software Foundation, either version 3 of the
#
# License, or (at your option) any later version.
#
#
#
# This program is distributed in the hope that it will be useful,
#
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#
# GNU Affero General Public License for more details.
#
#
#
# You should have received a copy of the GNU Affero General Public License
#
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
set -e

TAG=${1:-"postfacto/smoke:dev"}
BASE_DIR="$(dirname "$0")"

docker build $BASE_DIR -f $BASE_DIR/../docker/smoke/Dockerfile -t $TAG
Loading