Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement integration tests running inside Docker container
- Loading branch information
Showing
13 changed files
with
231 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
tmp/* | ||
!tmp/.keep | ||
log/* | ||
!log/.keep | ||
.git | ||
Dockerfile | ||
Dockerfile.test | ||
Jenkinsfile | ||
.codeclimate.yml | ||
.travis.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
FROM registry.scc.suse.de/suse/sles15:ga | ||
|
||
RUN useradd --no-log-init --create-home scc | ||
|
||
ARG REGCODE | ||
RUN SUSEConnect -r $REGCODE | ||
RUN zypper --non-interactive ar http://download.opensuse.org/repositories/openSUSE:/Tools/SLE_15/openSUSE:Tools.repo | ||
RUN zypper --non-interactive --gpg-auto-import-keys ref | ||
RUN zypper --non-interactive up | ||
RUN zypper --non-interactive in -t pattern devel_osc_build | ||
RUN zypper --non-interactive install --no-recommend wget curl timezone \ | ||
gcc-c++ libffi-devel git-core zlib-devel libxml2-devel libxslt-devel libmariadb-devel \ | ||
mariadb-client ruby2.5-rubygem-bundler make build sudo ruby-devel | ||
|
||
|
||
ENV DOCKERIZE_VERSION v0.6.0 | ||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
|
||
ARG OBS_USER | ||
ARG OBS_PASSWORD | ||
RUN printf "[general]\n\ | ||
build-root = /oscbuild/%(repo)s-%(arch)s\n\ | ||
packagecachedir = /oscbuild/packagecache\n\ | ||
[https://api.suse.de]\n\ | ||
user=$OBS_USER\n\ | ||
pass=$OBS_PASSWORD\n\ | ||
sslcertck = 0\n\ | ||
trusted_prj=SLE_12 SUSE:SLE-12:GA\n\ | ||
[https://api.opensuse.org]\n\ | ||
user=$OBS_USER\n\ | ||
pass=$OBS_PASSWORD\n\ | ||
sslcertck = 0\n\ | ||
trusted_prj=SLE_12 SUSE:SLE-12:GA\n\ | ||
" >> ~/.oscrc | ||
|
||
RUN mkdir /tmp/rmt-server | ||
WORKDIR /tmp/rmt-server | ||
ADD . /tmp/rmt-server | ||
RUN chown -R scc /tmp/rmt-server | ||
ARG MYSQL_HOST | ||
ARG MYSQL_USER | ||
ARG MYSQL_PASSWORD | ||
ARG MYSQL_DATABASE | ||
ARG SCC_USERNAME | ||
ARG SCC_PASSWORD | ||
RUN printf "database:\n\ | ||
host: $MYSQL_HOST\n\ | ||
username: $MYSQL_USER\n\ | ||
password: $MYSQL_PASSWORD\n\ | ||
database: $MYSQL_DATABASE\n\ | ||
scc:\n\ | ||
username: $SCC_USERNAME\n\ | ||
password: $SCC_PASSWORD\n\ | ||
" >> /etc/rmt.conf | ||
|
||
RUN bundle | ||
|
||
CMD dockerize -wait tcp://$MYSQL_HOST:3306 -timeout 60s true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: '2' | ||
volumes: | ||
db_storage: | ||
driver: local | ||
networks: | ||
default: | ||
driver: bridge | ||
driver_opts: | ||
com.docker.network.driver.mtu: 1350 | ||
|
||
services: | ||
db: | ||
image: mariadb:10.2 | ||
restart: always | ||
volumes: | ||
- db_storage:/var/lib/mysql | ||
extends: | ||
service: base | ||
file: docker-compose-base.yml | ||
|
||
rmt_test: | ||
privileged: true | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test | ||
args: | ||
REGCODE: ${REGCODE} | ||
OBS_USER: ${OBS_USER} | ||
OBS_PASSWORD: ${OBS_PASSWORD} | ||
SCC_USERNAME: ${SCC_USERNAME} | ||
SCC_PASSWORD: ${SCC_PASSWORD} | ||
MYSQL_HOST: ${MYSQL_HOST} | ||
MYSQL_USER: ${MYSQL_USER} | ||
MYSQL_PASSWORD: ${MYSQL_PASSWORD} | ||
MYSQL_DATABASE: ${MYSQL_DATABASE} | ||
environment: | ||
- MYSQL_HOST=db | ||
- SECRET_KEY_BASE=8ea53ad3bc6c03923e376c8bdd85059c1885524947a7efe53d5e9c9d4e39861106ffd6a2ece82b803072ed701e6c960bade91644979e679416c5f255007237ae | ||
depends_on: | ||
- db | ||
extends: | ||
service: base | ||
file: docker-compose-base.yml | ||
command: /bin/bash -c 'bundle.ruby2.5 exec rails db:migrate' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require File.expand_path('../support/command_rspec_helper', __FILE__) | ||
|
||
describe 'rmt-cli' do | ||
before(:example) { system '/usr/bin/rmt-cli sync > /dev/null &' } | ||
# kill running process to let further specs pass | ||
after(:example) { system 'kill -9 $(cat /tmp/rmt.lock)' } | ||
|
||
describe 'lockfile' do | ||
command '/usr/bin/rmt-cli sync', allow_error: true | ||
|
||
its(:stderr) { is_expected.to eq("Process is locked by the application with \ | ||
pid #{File.read('/tmp/rmt.lock')}. Close this application or wait for it \ | ||
to finish before trying again\n") } | ||
|
||
its(:exitstatus) { is_expected.to eq 1 } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require File.expand_path('../support/command_rspec_helper', __FILE__) | ||
|
||
describe 'mirror' do | ||
command '/usr/bin/rmt-cli mirror' | ||
its(:exitstatus) { is_expected.to eq 0 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.expand_path('../support/command_rspec_helper', __FILE__) | ||
|
||
[3114, 3115, 3116, 2705, 2707].each do |repo_id| | ||
describe 'enable repos' do | ||
command "/usr/bin/rmt-cli repos enable #{repo_id}" | ||
its(:stdout) { is_expected.to eq("Repository successfully enabled.\n") } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rspec_command' | ||
|
||
RSpec.configure do |config| | ||
config.include RSpecCommand | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path('../support/command_rspec_helper', __FILE__) | ||
|
||
describe 'rmt-cli' do | ||
describe 'sync' do | ||
command '/usr/bin/rmt-cli sync' | ||
its(:exitstatus) { is_expected.to eq 0 } | ||
its(:stdout) { is_expected.to include("INFO -- : Cleaning up the database\n") } | ||
its(:stdout) { is_expected.to include("INFO -- : Downloading data from SCC\n") } | ||
its(:stdout) { is_expected.to include("INFO -- : Updating products\n") } | ||
its(:stdout) { is_expected.to include("INFO -- : Updating repositories\n") } | ||
its(:stdout) { is_expected.to include("INFO -- : Updating subscriptions\n") } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh -xe | ||
make dist | ||
mkdir ~/obs | ||
cd ~/obs | ||
osc co systemsmanagement:SCC:RMT rmt-server | ||
cd /tmp/rmt-server/package | ||
cp * ~/obs/systemsmanagement:SCC:RMT/rmt-server | ||
cd ~/obs/systemsmanagement:SCC:RMT/rmt-server && osc build SLE_15 x86_64 --no-verify --trust-all-projects && cd .. && | ||
zypper --non-interactive --no-gpg-checks in /oscbuild/SLE_15-x86_64/home/abuild/rpmbuild/RPMS/x86_64/* | ||
cd /tmp/rmt-server/ | ||
cp /etc/rmt.conf config/rmt.yml | ||
RAILS_ENV=production /usr/share/rmt/bin/rails db:create db:migrate | ||
/usr/bin/rmt-cli sync | ||
NO_COVERAGE=true rspec features/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pipeline { | ||
agent { | ||
label 'scc-happy-customer' | ||
} | ||
|
||
stages { | ||
stage('checkout') { | ||
steps { | ||
script { | ||
currentBuild.displayName = "#${BUILD_NUMBER}: ${branch}" | ||
} | ||
|
||
git url: 'git@github.com:SUSE/rmt.git', branch: "${branch}" | ||
} | ||
} | ||
stage('docker-compose build') { | ||
steps { | ||
sh 'docker-compose -f docker-compose-test.yml build' | ||
} | ||
} | ||
|
||
stage('rmt integration tests') { | ||
steps { | ||
sh 'docker-compose -f docker-compose-test.yml run rmt_test ./integration.sh' | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
sh 'docker-compose down' | ||
sh 'docker system prune -f' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace :package do | ||
package_dir = 'package/' | ||
package_name = 'rmt-server' | ||
obs_project = 'systemsmanagement:SCC:RMT' | ||
local_spec_file = "#{package_name}.spec" | ||
root_path = File.join(File.dirname(__FILE__), '../..') | ||
|
||
desc 'Checkout from OBS' | ||
task :checkout do | ||
Dir.chdir "#{root_path}/#{package_dir}" do | ||
unless Dir['.osc'].any? | ||
sh 'mkdir .tmp; mv * .tmp/' | ||
sh "osc co #{obs_project} #{package_name} -o ." | ||
puts 'Checkout successful.' if $CHILD_STATUS.exitstatus.zero? | ||
end | ||
end | ||
end | ||
end |