Commit 3c43f31f authored by Rémy Coutable's avatar Rémy Coutable

Improve the 'retrieve-tests-metadata' and 'update-tests-metadata' jobs

Also, consolidate the Knapsack report into a single file, and
consolidate the RSpec EE-specific job from the RSpec base job.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 78192233
...@@ -17,8 +17,7 @@ variables: ...@@ -17,8 +17,7 @@ variables:
GIT_DEPTH: "20" GIT_DEPTH: "20"
GIT_SUBMODULE_STRATEGY: "none" GIT_SUBMODULE_STRATEGY: "none"
GET_SOURCES_ATTEMPTS: "3" GET_SOURCES_ATTEMPTS: "3"
KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/${CI_PROJECT_NAME}/rspec_report-master.json KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/report-master.json
EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/${CI_PROJECT_NAME}/rspec_report-master-ee.json
FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/report-suite.json FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/report-suite.json
BUILD_ASSETS_IMAGE: "false" BUILD_ASSETS_IMAGE: "false"
ES_JAVA_OPTS: "-Xms256m -Xmx256m" ES_JAVA_OPTS: "-Xms256m -Xmx256m"
......
...@@ -77,7 +77,7 @@ gitlab:assets:compile pull-cache: ...@@ -77,7 +77,7 @@ gitlab:assets:compile pull-cache:
- .default-before_script - .default-before_script
- .assets-compile-cache - .assets-compile-cache
- .only-code-qa-changes - .only-code-qa-changes
- .use-pg - .use-pg9
stage: prepare stage: prepare
script: script:
- node --version - node --version
...@@ -120,7 +120,7 @@ compile-assets pull-cache: ...@@ -120,7 +120,7 @@ compile-assets pull-cache:
- .default-only - .default-only
- .default-before_script - .default-before_script
- .only-code-changes - .only-code-changes
- .use-pg - .use-pg9
dependencies: ["compile-assets", "compile-assets pull-cache", "setup-test-env"] dependencies: ["compile-assets", "compile-assets pull-cache", "setup-test-env"]
karma: karma:
......
...@@ -110,19 +110,34 @@ ...@@ -110,19 +110,34 @@
- $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" - $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org"
kubernetes: active kubernetes: active
.use-pg: .use-pg9:
services: services:
- name: postgres:9.6.14 - name: postgres:9.6
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine - name: redis:alpine
.use-pg-10: .use-pg10:
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.3-golang-1.11-git-2.22-chrome-73.0-node-12.x-yarn-1.16-postgresql-10-graphicsmagick-1.3.33" image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.3-golang-1.11-git-2.22-chrome-73.0-node-12.x-yarn-1.16-postgresql-10-graphicsmagick-1.3.33"
services: services:
- name: postgres:10.9 - name: postgres:10.9
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine - name: redis:alpine
.use-pg9-ee:
services:
- name: postgres:9.6
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine
- name: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
.use-pg10-ee:
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.3-golang-1.11-git-2.22-chrome-73.0-node-12.x-yarn-1.16-postgresql-10-graphicsmagick-1.3.33"
services:
- name: postgres:10.9
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine
- name: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
.only-ee: .only-ee:
only: only:
variables: variables:
......
...@@ -36,7 +36,7 @@ memory-static: ...@@ -36,7 +36,7 @@ memory-static:
memory-on-boot: memory-on-boot:
extends: extends:
- .only-code-memory-job-base - .only-code-memory-job-base
- .use-pg-10 - .use-pg10
variables: variables:
NODE_ENV: "production" NODE_ENV: "production"
RAILS_ENV: "production" RAILS_ENV: "production"
......
...@@ -33,31 +33,29 @@ ...@@ -33,31 +33,29 @@
- .default-before_script - .default-before_script
- .only-code-qa-changes - .only-code-qa-changes
setup-test-env:
extends:
- .only-code-qa-rails-job-base
- .use-pg9
stage: prepare
script:
- bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
- scripts/gitaly-test-build # Do not use 'bundle exec' here
artifacts:
expire_in: 7d
paths:
- tmp/tests
- config/secrets.yml
- vendor/gitaly-ruby
cache:
policy: pull-push
.rspec-base: .rspec-base:
extends: .only-code-rails-job-base extends: .only-code-rails-job-base
stage: test stage: test
script: script:
- JOB_NAME=( $CI_JOB_NAME ) - source scripts/rspec_helpers.sh
- TEST_TOOL=${JOB_NAME[0]} - rspec_paralellized_job "--tag ~quarantine --tag ~geo"
- TEST_LEVEL=${JOB_NAME[1]}
- DATABASE=${JOB_NAME[2]}
- export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${TEST_TOOL}_${TEST_LEVEL}_${DATABASE}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
- export KNAPSACK_GENERATE_REPORT=true KNAPSACK_LOG_LEVEL=debug KNAPSACK_TEST_DIR=spec
- export SUITE_FLAKY_RSPEC_REPORT_PATH=${FLAKY_RSPEC_SUITE_REPORT_PATH}
- export FLAKY_RSPEC_REPORT_PATH=rspec_flaky/all_${TEST_TOOL}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
- export NEW_FLAKY_RSPEC_REPORT_PATH=rspec_flaky/new_${TEST_TOOL}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
- export FLAKY_RSPEC_GENERATE_REPORT=true
- export CACHE_CLASSES=true
- cp ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
- '[[ -f $FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_REPORT_PATH}'
- '[[ -f $NEW_FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${NEW_FLAKY_RSPEC_REPORT_PATH}'
- scripts/gitaly-test-spawn
- date
- 'export KNAPSACK_TEST_FILE_PATTERN=$(ruby -r./lib/quality/test_level.rb -e "puts Quality::TestLevel.new.pattern(:${TEST_LEVEL})")'
- mkdir -p tmp/memory_test
- export MEMORY_TEST_PATH="tmp/memory_test/${TEST_TOOL}_${TEST_LEVEL}_${DATABASE}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_memory.csv"
- knapsack rspec "--color --format documentation --format RspecJunitFormatter --out junit_rspec.xml --tag level:${TEST_LEVEL} --tag ~geo"
- date
artifacts: artifacts:
expire_in: 31d expire_in: 31d
when: always when: always
...@@ -71,78 +69,145 @@ ...@@ -71,78 +69,145 @@
reports: reports:
junit: junit_rspec.xml junit: junit_rspec.xml
.rspec-base-pg: .rspec-base-pg9:
extends: extends:
- .rspec-base - .rspec-base
- .use-pg - .use-pg9
.rspec-base-pg-10: .rspec-base-pg10:
extends: extends:
- .rspec-base - .rspec-base
- .use-pg-10 - .use-pg10
- .only-master
setup-test-env: rspec unit pg9:
extends: extends: .rspec-base-pg9
- .only-code-qa-rails-job-base parallel: 20
- .use-pg
stage: prepare rspec integration pg9:
script: extends: .rspec-base-pg9
- bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init' parallel: 6
- scripts/gitaly-test-build # Do not use 'bundle exec' here
artifacts:
expire_in: 7d
paths:
- tmp/tests
- config/secrets.yml
- vendor/gitaly-ruby
cache:
policy: pull-push
rspec unit pg: rspec system pg9:
extends: .rspec-base-pg extends: .rspec-base-pg9
parallel: 24
rspec unit pg10:
extends: .rspec-base-pg10
parallel: 20 parallel: 20
rspec integration pg: rspec integration pg10:
extends: .rspec-base-pg extends: .rspec-base-pg10
parallel: 6 parallel: 6
rspec system pg: rspec system pg10:
extends: .rspec-base-pg extends: .rspec-base-pg10
parallel: 24 parallel: 24
rspec unit pg-10: .rspec-ee-base-pg9:
extends:
- .rspec-base
- .only-ee
- .use-pg9-ee
.rspec-ee-base-pg10:
extends:
- .rspec-base
- .only-ee
- .use-pg10-ee
rspec-ee unit pg9:
extends: .rspec-ee-base-pg9
parallel: 7
rspec-ee integration pg9:
extends: .rspec-ee-base-pg9
parallel: 3
rspec-ee system pg9:
extends: .rspec-ee-base-pg9
parallel: 5
rspec-ee unit pg10:
extends: extends:
- .rspec-base-pg-10 - .rspec-ee-base-pg10
- .only-master - .only-master
parallel: 20 parallel: 7
rspec integration pg-10: rspec-ee integration pg10:
extends: extends:
- .rspec-base-pg-10 - .rspec-ee-base-pg10
- .only-master - .only-master
parallel: 6 parallel: 3
rspec system pg-10: rspec-ee system pg10:
extends: extends:
- .rspec-base-pg-10 - .rspec-ee-base-pg10
- .only-master - .only-master
parallel: 24 parallel: 5
rspec-fast-spec-helper: .rspec-ee-base-geo:
extends: .rspec-base-pg extends:
- .rspec-base
- .only-ee
script: script:
- bundle exec rspec spec/fast_spec_helper.rb - source scripts/rspec_helpers.sh
- scripts/prepare_postgres_fdw.sh
- rspec_paralellized_job "--tag ~quarantine --tag geo"
.rspec-ee-base-geo-pg9:
extends:
- .rspec-ee-base-geo
- .use-pg9-ee
.rspec-ee-base-geo-pg10:
extends:
- .rspec-ee-base-geo
- .use-pg10-ee
rspec-ee unit pg9 geo:
extends: .rspec-ee-base-geo-pg9
parallel: 2
rspec-ee integration pg9 geo:
extends: .rspec-ee-base-geo-pg9
rspec quarantine pg: rspec-ee system pg9 geo:
extends: .rspec-ee-base-geo-pg9
rspec-ee unit pg10 geo:
extends: .rspec-ee-base-geo-pg10
parallel: 2
rspec-ee integration pg10 geo:
extends: .rspec-ee-base-geo-pg10
rspec-ee system pg10 geo:
extends: .rspec-ee-base-geo-pg10
rspec quarantine pg9:
extends: extends:
- .rspec-base-pg - .rspec-base-pg9
- .only-master - .only-master
variables:
RSPEC_OPTS: "--tag quarantine -- spec/"
script: script:
- export NO_KNAPSACK=1 CACHE_CLASSES=true - source scripts/rspec_helpers.sh
- scripts/gitaly-test-spawn - rspec_simple_job "${RSPEC_OPTS}"
- bin/rspec --color --format documentation --tag quarantine -- spec/
allow_failure: true allow_failure: true
rspec-ee quarantine pg9:
extends:
- rspec quarantine pg9
- .only-ee
variables:
RSPEC_OPTS: "--tag quarantine -- ee/spec/"
rspec fast_spec_helper:
extends: .rspec-base-pg9
script:
- bin/rspec spec/fast_spec_helper.rb
static-analysis: static-analysis:
extends: .only-code-qa-rails-job-base extends: .only-code-qa-rails-job-base
dependencies: ["setup-test-env", "compile-assets", "compile-assets pull-cache"] dependencies: ["setup-test-env", "compile-assets", "compile-assets pull-cache"]
...@@ -174,7 +239,7 @@ downtime_check: ...@@ -174,7 +239,7 @@ downtime_check:
.db-job-base: .db-job-base:
extends: extends:
- .only-code-rails-job-base - .only-code-rails-job-base
- .use-pg - .use-pg9
stage: test stage: test
dependencies: ["setup-test-env"] dependencies: ["setup-test-env"]
needs: ["setup-test-env"] needs: ["setup-test-env"]
...@@ -258,108 +323,6 @@ coverage: ...@@ -258,108 +323,6 @@ coverage:
- coverage/assets/ - coverage/assets/
- tmp/memory_test/ - tmp/memory_test/
## EE-specific content
.rspec-base-ee:
extends:
- .rspec-base
- .only-ee
script:
- JOB_NAME=( $CI_JOB_NAME )
- TEST_TOOL=${JOB_NAME[0]}
- TEST_LEVEL=${JOB_NAME[1]}
- DATABASE=${JOB_NAME[2]}
- export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${TEST_TOOL}_${TEST_LEVEL}_${DATABASE}_ee_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
- export KNAPSACK_GENERATE_REPORT=true KNAPSACK_LOG_LEVEL=debug KNAPSACK_TEST_DIR=spec
- export CACHE_CLASSES=true
- cp ${EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
- scripts/gitaly-test-spawn
- date
- 'export KNAPSACK_TEST_FILE_PATTERN=$(ruby -r./lib/quality/test_level.rb -e "puts Quality::TestLevel.new(%(ee/)).pattern(:${TEST_LEVEL})")'
- mkdir -p tmp/memory_test
- export MEMORY_TEST_PATH="tmp/memory_test/ee_${TEST_TOOL}_${TEST_LEVEL}_${DATABASE}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_memory.csv"
- knapsack rspec "--color --format documentation --format RspecJunitFormatter --out junit_rspec.xml --tag level:${TEST_LEVEL} --tag ~geo"
- date
.rspec-base-pg-ee:
extends: .rspec-base-ee
services:
- name: postgres:9.6
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine
- name: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
rspec unit pg ee:
extends: .rspec-base-pg-ee
parallel: 7
rspec integration pg ee:
extends: .rspec-base-pg-ee
parallel: 3
rspec system pg ee:
extends: .rspec-base-pg-ee
parallel: 5
.rspec-base-geo:
extends: .rspec-base-ee
parallel: 3
script:
- JOB_NAME=( $CI_JOB_NAME )
- TEST_TOOL=${JOB_NAME[0]}
- TEST_LEVEL=${JOB_NAME[1]}
- DATABASE=${JOB_NAME[2]}
- export KNAPSACK_TEST_FILE_PATTERN="ee/spec/**{,/*/**}/*_spec.rb" KNAPSACK_GENERATE_REPORT=true CACHE_CLASSES=true
- export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${TEST_TOOL}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
- cp ${EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
- source scripts/prepare_postgres_fdw.sh
- scripts/gitaly-test-spawn
- mkdir -p tmp/memory_test
- export MEMORY_TEST_PATH="tmp/memory_test/ee_${TEST_TOOL}_${TEST_LEVEL}_${DATABASE}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_memory.csv"
- knapsack rspec "-Ispec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml --tag geo"
rspec geo pg ee:
extends:
- .rspec-base-geo
- .use-pg
except:
variables:
- $CI_COMMIT_REF_NAME =~ /(^geo[\/-].*|.*-geo$)/
rspec geo pg-10 ee:
extends:
- .rspec-base-geo
- .use-pg-10
except:
variables:
- $CI_COMMIT_REF_NAME =~ /(^geo[\/-].*|.*-geo$)/
quick-rspec geo pg ee:
extends:
- .rspec-base-geo
- .use-pg
stage: quick-test
only:
variables:
- $CI_COMMIT_REF_NAME =~ /(^geo[\/-].*|.*-geo$)/
quick-rspec geo pg-10 ee:
extends:
- .rspec-base-geo
- .use-pg-10
stage: quick-test
only:
variables:
- $CI_COMMIT_REF_NAME =~ /(^geo[\/-].*|.*-geo$)/
rspec quarantine pg ee:
extends:
- rspec quarantine pg
- .only-ee
script:
- export NO_KNAPSACK=1 CACHE_CLASSES=true
- scripts/gitaly-test-spawn
- bin/rspec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml --tag quarantine -- ee/spec/
db:rollback geo: db:rollback geo:
extends: extends:
- db:rollback - db:rollback
...@@ -367,5 +330,3 @@ db:rollback geo: ...@@ -367,5 +330,3 @@ db:rollback geo:
script: script:
- bundle exec rake geo:db:migrate VERSION=20170627195211 - bundle exec rake geo:db:migrate VERSION=20170627195211
- bundle exec rake geo:db:migrate - bundle exec rake geo:db:migrate
## END of EE-specific content
.tests-metadata-state: .tests-metadata-state:
extends: extends:
- .default-only - .default-only
- .only-code-changes
variables: variables:
TESTS_METADATA_S3_BUCKET: "gitlab-ce-cache" TESTS_METADATA_S3_BUCKET: "gitlab-ce-cache"
before_script: before_script:
- source scripts/utils.sh - source scripts/utils.sh
cache:
key: tests_metadata
paths:
- knapsack/
- rspec_flaky/
artifacts: artifacts:
expire_in: 31d expire_in: 31d
paths: paths:
...@@ -13,55 +19,29 @@ ...@@ -13,55 +19,29 @@
- rspec_profiling/ - rspec_profiling/
retrieve-tests-metadata: retrieve-tests-metadata:
extends: extends: .tests-metadata-state
- .tests-metadata-state
- .only-code-changes
stage: prepare stage: prepare
cache: cache:
key: tests_metadata
policy: pull policy: pull
script: script:
- mkdir -p knapsack/${CI_PROJECT_NAME}/ - source scripts/rspec_helpers.sh
- wget -O $KNAPSACK_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || rm $KNAPSACK_RSPEC_SUITE_REPORT_PATH - retrieve_tests_metadata
- '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
- mkdir -p rspec_flaky/
- mkdir -p rspec_profiling/
- wget -O $FLAKY_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$FLAKY_RSPEC_SUITE_REPORT_PATH || rm $FLAKY_RSPEC_SUITE_REPORT_PATH
- '[[ -f $FLAKY_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_SUITE_REPORT_PATH}'
- '[[ ! -d "ee/" ]] || wget -O $EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH || rm $EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH'
- '[[ ! -d "ee/" ]] || [[ -f $EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
update-tests-metadata: update-tests-metadata:
extends: extends: .tests-metadata-state
- .tests-metadata-state
- .only-code-changes
stage: post-test stage: post-test
cache: cache:
key: tests_metadata
paths:
- knapsack/
- rspec_flaky/
policy: push policy: push
script: script:
- retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document - retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document
- echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} - source scripts/rspec_helpers.sh
- scripts/merge-reports ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/rspec_*_pg_node_*.json - update_tests_metadata
- '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $KNAPSACK_RSPEC_SUITE_REPORT_PATH'
- '[[ ! -d "ee/" ]] || echo "{}" > ${EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
- '[[ ! -d "ee/" ]] || scripts/merge-reports ${EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/rspec_*_pg_ee_*node_*.json'
- '[[ ! -d "ee/" ]] || [[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $EE_KNAPSACK_RSPEC_SUITE_REPORT_PATH'
- rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
- scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
- FLAKY_RSPEC_GENERATE_REPORT=1 scripts/prune-old-flaky-specs ${FLAKY_RSPEC_SUITE_REPORT_PATH}
- '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $FLAKY_RSPEC_SUITE_REPORT_PATH'
- rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
- scripts/insert-rspec-profiling-data
only: only:
refs: refs:
- master - schedules
variables: variables:
- $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" # Only update the Knapsack metadata on GitLab.com/gitlab-org/gitlab
- $CI_SERVER_HOST == "dev.gitlab.org" - $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab"
flaky-examples-check: flaky-examples-check:
extends: extends:
......
...@@ -4,27 +4,24 @@ ...@@ -4,27 +4,24 @@
Our current CI parallelization setup is as follows: Our current CI parallelization setup is as follows:
1. The `knapsack` job in the prepare stage that is supposed to ensure we have a 1. The `retrieve-tests-metadata` job in the `prepare` stage ensures we have a
`knapsack/${CI_PROJECT_NAME}/rspec_report-master.json` file: `knapsack/report-master.json` file:
- The `knapsack/${CI_PROJECT_NAME}/rspec_report-master.json` file is fetched - The `knapsack/report-master.json` file is fetched from S3, if it's not here
from S3, if it's not here we initialize the file with `{}`. we initialize the file with `{}`.
1. Each `rspec x y` job are run with `knapsack rspec` and should have an evenly 1. Each `[rspec|rspec-ee] [unit|integration|system|geo] n m` job are run with
distributed share of tests: `knapsack rspec` and should have an evenly distributed share of tests:
- It works because the jobs have access to the - It works because the jobs have access to the `knapsack/report-master.json`
`knapsack/${CI_PROJECT_NAME}/rspec_report-master.json` since the "artifacts since the "artifacts from all previous stages are passed by default".
from all previous stages are passed by default".
- the jobs set their own report path to - the jobs set their own report path to
`KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${JOB_NAME[0]}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json`. `"knapsack/${TEST_TOOL}_${TEST_LEVEL}_${DATABASE}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"`.
- if knapsack is doing its job, test files that are run should be listed under - if knapsack is doing its job, test files that are run should be listed under
`Report specs`, not under `Leftover specs`. `Report specs`, not under `Leftover specs`.
1. The `update-knapsack` job takes all the 1. The `update-tests-metadata` job (which only runs on scheduled pipelines for
`knapsack/${CI_PROJECT_NAME}/${JOB_NAME[0]}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json` [the canonical project](https://gitlab.com/gitlab-org/gitlab) takes all the
files from the `rspec x y` jobs and merge them all together into a single `knapsack/rspec*_pg_*.json` files and merge them all together into a single
`knapsack/${CI_PROJECT_NAME}/rspec_report-master.json` file that is then `knapsack/report-master.json` file that is then uploaded to S3.
uploaded to S3.
After that, the next pipeline will use the up-to-date `knapsack/report-master.json` file.
After that, the next pipeline will use the up-to-date
`knapsack/${CI_PROJECT_NAME}/rspec_report-master.json` file.
## Monitoring ## Monitoring
......
...@@ -53,11 +53,11 @@ module Quality ...@@ -53,11 +53,11 @@ module Quality
end end
def pattern(level) def pattern(level)
@patterns[level] ||= "#{prefix}spec/{#{TEST_LEVEL_FOLDERS.fetch(level).join(',')}}{,/**/}*_spec.rb" @patterns[level] ||= "#{prefix}spec/#{folders_pattern(level)}{,/**/}*_spec.rb"
end end
def regexp(level) def regexp(level)
@regexps[level] ||= Regexp.new("#{prefix}spec/(#{TEST_LEVEL_FOLDERS.fetch(level).join('|')})").freeze @regexps[level] ||= Regexp.new("#{prefix}spec/#{folders_regex(level)}").freeze
end end
def level_for(file_path) def level_for(file_path)
...@@ -72,5 +72,27 @@ module Quality ...@@ -72,5 +72,27 @@ module Quality
raise UnknownTestLevelError, "Test level for #{file_path} couldn't be set. Please rename the file properly or change the test level detection regexes in #{__FILE__}." raise UnknownTestLevelError, "Test level for #{file_path} couldn't be set. Please rename the file properly or change the test level detection regexes in #{__FILE__}."
end end
end end
private
def folders_pattern(level)
case level
# Geo specs aren't in a specific folder, but they all have the :geo tag, so we must search for them globally
when :all, :geo
'**'
else
"{#{TEST_LEVEL_FOLDERS.fetch(level).join(',')}}"
end
end
def folders_regex(level)
case level
# Geo specs aren't in a specific folder, but they all have the :geo tag, so we must search for them globally
when :all, :geo
''
else
"(#{TEST_LEVEL_FOLDERS.fetch(level).join('|')})"
end
end
end end
end end
#!/bin/bash
function retrieve_tests_metadata() {
mkdir -p knapsack/ rspec_flaky/ rspec_profiling/
if [[ ! -f "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" ]]; then
wget -O "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" || echo "{}" > "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
fi
if [[ ! -f "${FLAKY_RSPEC_SUITE_REPORT_PATH}" ]]; then
wget -O "${FLAKY_RSPEC_SUITE_REPORT_PATH}" "http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/${FLAKY_RSPEC_SUITE_REPORT_PATH}" || echo "{}" > "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
fi
}
function update_tests_metadata() {
echo "{}" > "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
scripts/merge-reports "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "knapsack/rspec*_pg9_*.json"
if [[ -n "${TESTS_METADATA_S3_BUCKET}" ]]; then
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
fi
rm -f "knapsack/rspec*.json"
scripts/merge-reports "${FLAKY_RSPEC_SUITE_REPORT_PATH}" "rspec_flaky/all_*.json"
export FLAKY_RSPEC_GENERATE_REPORT="1"
scripts/prune-old-flaky-specs "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
if [[ -n ${TESTS_METADATA_S3_BUCKET} ]]; then
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
fi
rm -f "rspec_flaky/all_*.json" "rspec_flaky/new_*.json"
scripts/insert-rspec-profiling-data
}
function rspec_simple_job() {
local rspec_opts="${1}"
export NO_KNAPSACK="1"
export CACHE_CLASSES="true"
scripts/gitaly-test-spawn
bin/rspec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml "${rspec_opts}"
}
function rspec_paralellized_job() {
read -ra job_name <<< "$CI_JOB_NAME"
local test_tool="${job_name[0]}"
local test_level="${job_name[1]}"
local database="${job_name[2]}"
local rspec_opts="${1}"
local spec_folder_prefix=""
if [[ "${test_tool}" =~ "-ee" ]]; then
spec_folder_prefix="ee/"
fi
export CACHE_CLASSES="true"
export KNAPSACK_LOG_LEVEL="debug"
export KNAPSACK_REPORT_PATH="knapsack/${test_tool}_${test_level}_${database}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"
if [[ -z "${KNAPSACK_TEST_FILE_PATTERN}" ]]; then
pattern=$(ruby -r./lib/quality/test_level.rb -e "puts Quality::TestLevel.new(%(${spec_folder_prefix})).pattern(:${test_level})")
export KNAPSACK_TEST_FILE_PATTERN="${pattern}"
fi
echo "KNAPSACK_TEST_FILE_PATTERN: ${KNAPSACK_TEST_FILE_PATTERN}"
if [[ -d "ee/" ]]; then
export KNAPSACK_GENERATE_REPORT="true"
export FLAKY_RSPEC_GENERATE_REPORT="true"
export SUITE_FLAKY_RSPEC_REPORT_PATH="${FLAKY_RSPEC_SUITE_REPORT_PATH}"
export FLAKY_RSPEC_REPORT_PATH="rspec_flaky/all_${test_tool}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"
export NEW_FLAKY_RSPEC_REPORT_PATH="rspec_flaky/new_${test_tool}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"
cp "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "${KNAPSACK_REPORT_PATH}"
if [[ ! -f $FLAKY_RSPEC_REPORT_PATH ]]; then
echo "{}" > "${FLAKY_RSPEC_REPORT_PATH}"
fi
if [[ ! -f $NEW_FLAKY_RSPEC_REPORT_PATH ]]; then
echo "{}" > "${NEW_FLAKY_RSPEC_REPORT_PATH}"
fi
fi
scripts/gitaly-test-spawn
mkdir -p tmp/memory_test
export MEMORY_TEST_PATH="tmp/memory_test/${test_tool}_${test_level}_${database}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_memory.csv"
knapsack rspec "-Ispec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml ${rspec_opts}"
date
}
...@@ -4,6 +4,20 @@ require 'fast_spec_helper' ...@@ -4,6 +4,20 @@ require 'fast_spec_helper'
RSpec.describe Quality::TestLevel do RSpec.describe Quality::TestLevel do
describe '#pattern' do describe '#pattern' do
context 'when level is all' do
it 'returns a pattern' do
expect(subject.pattern(:all))
.to eq("spec/**{,/**/}*_spec.rb")
end
end
context 'when level is geo' do
it 'returns a pattern' do
expect(subject.pattern(:geo))
.to eq("spec/**{,/**/}*_spec.rb")
end
end
context 'when level is unit' do context 'when level is unit' do
it 'returns a pattern' do it 'returns a pattern' do
expect(subject.pattern(:unit)) expect(subject.pattern(:unit))
...@@ -44,6 +58,20 @@ RSpec.describe Quality::TestLevel do ...@@ -44,6 +58,20 @@ RSpec.describe Quality::TestLevel do
end end
describe '#regexp' do describe '#regexp' do
context 'when level is all' do
it 'returns a regexp' do
expect(subject.regexp(:all))
.to eq(%r{spec/})
end
end
context 'when level is geo' do
it 'returns a regexp' do
expect(subject.regexp(:geo))
.to eq(%r{spec/})
end
end
context 'when level is unit' do context 'when level is unit' do
it 'returns a regexp' do it 'returns a regexp' do
expect(subject.regexp(:unit)) expect(subject.regexp(:unit))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment