-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from SUSE/integration-tests
CLI integration tests
- Loading branch information
Showing
16 changed files
with
257 additions
and
10 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,62 @@ | ||
FROM registry.scc.suse.de/suse/sles15:ga | ||
|
||
RUN useradd --no-log-init --create-home scc | ||
|
||
ARG REGCODE | ||
ARG OBS_USER | ||
ARG OBS_PASSWORD | ||
ARG MYSQL_HOST | ||
ARG MYSQL_USER | ||
ARG MYSQL_PASSWORD | ||
ARG MYSQL_DATABASE | ||
ARG SCC_USERNAME | ||
ARG SCC_PASSWORD | ||
|
||
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 | ||
|
||
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 | ||
RUN mkdir /etc/rmt | ||
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
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 { `/usr/bin/rmt-cli sync > /dev/null &` } | ||
# kill running process to let further specs pass | ||
after { `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,23 @@ | ||
require File.expand_path('../support/command_rspec_helper', __FILE__) | ||
|
||
describe 'mirror' do | ||
let(:files) { %w'repomd.xml repomd.xml.asc repomd.xml.key *-primary.xml.gz *-filelists.xml.gz *-other.xml.gz' } | ||
|
||
before do | ||
`/usr/bin/rmt-cli repos enable 3114` | ||
`/usr/bin/rmt-cli mirror` | ||
end | ||
|
||
after do | ||
`/usr/bin/rmt-cli repos disable 3114` | ||
|
||
# cleanup files | ||
FileUtils.rm_r('/var/lib/rmt/public/repo/SUSE/Updates/SLE-Product-SLES/15') | ||
end | ||
|
||
it do | ||
files.each do |filename_pattern| | ||
expect(`find /var/lib/rmt/public/ -name \'#{filename_pattern}\'`).to include(filename_pattern.gsub('*', '')) | ||
end | ||
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,19 @@ | ||
describe 'enable repos' do | ||
let(:repos) { [3114, 3115, 3116, 2705, 2707] } | ||
|
||
before do | ||
repos.each do |repo_id| | ||
`/usr/bin/rmt-cli repos enable #{repo_id}` | ||
end | ||
end | ||
|
||
after do | ||
repos.each do |repo_id| | ||
`/usr/bin/rmt-cli repos disable #{repo_id}` | ||
end | ||
end | ||
|
||
it do | ||
expect(`/usr/bin/rmt-cli repos list --csv | wc -l`.strip&.to_i ).to eq(5) | ||
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 } | ||
|
||
it do | ||
expect(`/usr/bin/rmt-cli products list --all | wc -l`.strip&.to_i ).to be >= 361 | ||
expect(`/usr/bin/rmt-cli repos list --all | wc -l`.strip&.to_i ).to be >= 839 | ||
end | ||
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 /usr/share/rmt | ||
RAILS_ENV=production /usr/share/rmt/bin/rails db:create db:migrate | ||
/usr/bin/rmt-cli sync | ||
cd /tmp/rmt-server/ | ||
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
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