Skip to content
Snippets Groups Projects
Commit 114249e4 authored by Balasankar C's avatar Balasankar C
Browse files

Add knapsack for running specs parallely

parent 35754dbc
No related branches found
No related tags found
No related merge requests found
stages:
- prepare
- tests
- post-test
- package
- notification_fail
- extra
Loading
Loading
@@ -13,14 +15,92 @@ before_script:
- bundle install -j $(nproc) --binstubs --path gems
- if [ -n "$NIGHTLY" ] ; then export NIGHTLY_REPO=nightly-builds ;fi
 
.knapsack-state: &knapsack-state
services: []
cache:
key: "knapsack"
paths:
- knapsack/
artifacts:
expire_in: 31d
paths:
- knapsack/
.knapsack: &prepare_knapsack
<<: *knapsack-state
stage: prepare
before_script: []
script:
- JOB_NAME=( $CI_BUILD_NAME )
- export DISTRO_NAME=${JOB_NAME[0]}
- export DISTRO_VERSION=${JOB_NAME[1]}
- mkdir -p knapsack/
- '[[ -f knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json ]] || echo "{}" > knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json'
- cp knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json.bak
- rm -f knapsack/*.json
- mv knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json.bak knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json
only:
- tags@gitlab-org/omnibus-gitlab
- branches@gitlab-org/omnibus-gitlab
Centos 6 knapsack: *prepare_knapsack
Centos 7 knapsack: *prepare_knapsack
Debian 7 knapsack: *prepare_knapsack
Debian 8 knapsack: *prepare_knapsack
OpenSUSE 13.2 knapsack: *prepare_knapsack
OpenSUSE 42.1 knapsack: *prepare_knapsack
Ubuntu 12.04 knapsack: *prepare_knapsack
Ubuntu 14.04 knapsack: *prepare_knapsack
Ubuntu 16.04 knapsack: *prepare_knapsack
# Runs on GitLab.com only
.spec_template: &run_rspec
stage: tests
script:
- bundle exec rspec -f documentation
- JOB_NAME=( $CI_BUILD_NAME )
- export DISTRO_NAME=${JOB_NAME[0]}
- export DISTRO_VERSION=${JOB_NAME[1]}
- export CI_NODE_INDEX=${JOB_NAME[3]}
- export CI_NODE_TOTAL=${JOB_NAME[4]}
- export KNAPSACK_REPORT_PATH=knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
- export KNAPSACK_GENERATE_REPORT=true
- cp knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json ${KNAPSACK_REPORT_PATH}.bak
- rm -f knapsack/*.json
- mv ${KNAPSACK_REPORT_PATH}.bak ${KNAPSACK_REPORT_PATH}
- bundle exec rake knapsack:rspec
only:
- tags@gitlab-org/omnibus-gitlab
- branches@gitlab-org/omnibus-gitlab
artifacts:
expire_in: 31d
paths:
- knapsack/
.update-knapsack: &update_knapsack
<<: *knapsack-state
stage: post-test
before_script: []
script:
- JOB_NAME=( $CI_BUILD_NAME )
- export DISTRO_NAME=${JOB_NAME[0]}
- export DISTRO_VERSION=${JOB_NAME[1]}
- scripts/merge-reports knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_node_*.json
- mv knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json.bak
- rm -f knapsack/*.json
- mv knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json.bak knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json
only:
- tags@gitlab-org/omnibus-gitlab
- branches@gitlab-org/omnibus-gitlab
Centos 6 update-knapsack: *update_knapsack
Centos 7 update-knapsack: *update_knapsack
Debian 7 update-knapsack: *update_knapsack
Debian 8 update-knapsack: *update_knapsack
OpenSUSE 13.2 update-knapsack: *update_knapsack
OpenSUSE 42.1 update-knapsack: *update_knapsack
Ubuntu 12.04 update-knapsack: *update_knapsack
Ubuntu 14.04 update-knapsack: *update_knapsack
Ubuntu 16.04 update-knapsack: *update_knapsack
 
# Runs on dev.gitlab.org
.branch_template: &branch_build
Loading
Loading
@@ -122,55 +202,163 @@ Docker:
- tags@gitlab/omnibus-gitlab
 
# GitLab.com only
Ubuntu 12.04 specs:
Ubuntu 12.04 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:precise"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 12.04 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:precise"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 12.04 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:precise"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 14.04 specs:
Ubuntu 14.04 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:trusty"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 16.04 specs:
Ubuntu 14.04 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:trusty"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 14.04 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:trusty"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 16.04 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:xenial"
cache:
paths:
- gems
<<: *run_rspec
Debian 7 specs:
Ubuntu 16.04 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:xenial"
cache:
paths:
- gems
<<: *run_rspec
Ubuntu 16.04 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:xenial"
cache:
paths:
- gems
<<: *run_rspec
Debian 7 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:wheezy"
cache:
paths:
- gems
<<: *run_rspec
Debian 8 specs:
Debian 7 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:wheezy"
cache:
paths:
- gems
<<: *run_rspec
Debian 7 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:wheezy"
cache:
paths:
- gems
<<: *run_rspec
Debian 8 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:jessie"
cache:
paths:
- gems
<<: *run_rspec
Debian 8 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:jessie"
cache:
paths:
- gems
<<: *run_rspec
Centos 6 specs:
Debian 8 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:jessie"
cache:
paths:
- gems
<<: *run_rspec
Centos 6 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:centos6"
cache:
paths:
- gems
<<: *run_rspec
Centos 7 specs:
Centos 6 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:centos6"
cache:
paths:
- gems
<<: *run_rspec
Centos 6 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:centos6"
cache:
paths:
- gems
<<: *run_rspec
Centos 7 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:centos7"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 13.2 specs:
Centos 7 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:centos7"
cache:
paths:
- gems
<<: *run_rspec
Centos 7 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:centos7"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 13.2 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:opensuse13.2"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 13.2 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:opensuse13.2"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 13.2 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:opensuse13.2"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 42.1 specs:
OpenSUSE 42.1 specs 0 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:opensuse42.1"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 42.1 specs 1 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:opensuse42.1"
cache:
paths:
- gems
<<: *run_rspec
OpenSUSE 42.1 specs 2 3:
image: "registry.gitlab.com/gitlab-org/omnibus-gitlab:opensuse42.1"
cache:
paths:
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@ gem 'thor', '0.18.1' # This specific version is required by package_cloud
gem 'json'
gem 'rspec'
gem 'rake'
gem 'knapsack'
 
group :test do
gem 'byebug'
Loading
Loading
Loading
Loading
@@ -95,6 +95,9 @@ GEM
jmespath (1.3.1)
json (2.0.2)
json_pure (1.8.1)
knapsack (1.13.1)
rake
timecop (>= 0.1.0)
libyajl2 (1.2.0)
mime-types (1.25.1)
mixlib-archive (0.2.0)
Loading
Loading
@@ -177,6 +180,7 @@ GEM
syslog-logger (1.6.8)
systemu (2.6.5)
thor (0.18.1)
timecop (0.8.1)
uuidtools (2.1.5)
wmi-lite (1.0.0)
 
Loading
Loading
@@ -187,6 +191,7 @@ DEPENDENCIES
byebug
chefspec
json
knapsack
ohai
omnibus!
omnibus-software!
Loading
Loading
@@ -194,3 +199,6 @@ DEPENDENCIES
rake
rspec
thor (= 0.18.1)
BUNDLED WITH
1.13.6
# All tasks in files placed in lib/gitlab/tasks ending in .rake will be loaded
# automatically
require 'knapsack'
Rake.add_rakelib 'lib/gitlab/tasks'
Knapsack.load_tasks
#!/usr/bin/env ruby
require 'json'
require 'yaml'
main_report_file = ARGV.shift
unless main_report_file
puts 'usage: merge_reports <main-report> [extra reports...]'
exit 1
end
puts "Loading #{main_report_file}..."
main_report = JSON.parse(File.read(main_report_file))
new_report = main_report.dup
ARGV.each do |report_file|
report = JSON.parse(File.read(report_file))
# Remove existing values
updates = report.delete_if do |key, value|
main_report[key] && main_report[key] == value
end
new_report.merge!(updates)
puts "Merged #{report_file} adding #{updates.size} results."
end
File.write(main_report_file, JSON.pretty_generate(new_report))
puts "Saved #{main_report_file}."
require 'chefspec'
require 'ohai'
 
require 'knapsack'
Knapsack::Adapters::RSpecAdapter.bind
# Load our cookbook libraries so we can stub them in our tests
Dir[File.join(__dir__, '../files/gitlab-cookbooks/gitlab/libraries/*.rb')].each { |f| require f }
Dir[File.join(__dir__, '../files/gitlab-cookbooks/gitlab-ee/libraries/*.rb')].each { |f| require f }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment