remove docker_processes from core rspec and selenium test runs

refs DE-467

it is no longer possible to spin up multiple docker containers
ona  single rspec or selenium agent when running tests. parallelization
is now exclusively done through multple rspec processes on
a single container.

test plan:
- setting docker_processes ENV variable has no effect
- settting rspec_processes still runs multiple test threads
- tests continue to run as expected given that docker_processes has
been set to 1 for multiple months.

Change-Id: I604d953a71ad220373b6a71d558f46bff29f820e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/263701
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Butters <jbutters@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: James Butters <jbutters@instructure.com>
This commit is contained in:
Kyle Rosenbaum 2021-04-26 14:28:15 -07:00 committed by James Butters
parent 51e5ca0c35
commit 347f73b172
16 changed files with 23 additions and 59 deletions

View File

@ -52,7 +52,6 @@ pipeline {
environment {
BUILD_REGISTRY_FQDN = configuration.buildRegistryFQDN()
COMPOSE_FILE = 'docker-compose.new-jenkins.yml:docker-compose.new-jenkins-contract-tests.yml'
DOCKER_PROCESSES = '1'
POSTGRES_PASSWORD = 'sekret'
PACT_BROKER = credentials('PACT_BROKER')
PACT_BROKER_USERNAME="${env.PACT_BROKER_USR}"

View File

@ -92,7 +92,7 @@ def computeTestCount() {
}
sh """
docker-compose --project-name canvas-lms0 run --rm -v \$(pwd)/\$LOCAL_WORKDIR/tmp:\$DOCKER_WORKDIR/tmp \
docker-compose run --rm -v \$(pwd)/\$LOCAL_WORKDIR/tmp:\$DOCKER_WORKDIR/tmp \
canvas \
bash -c "bundle exec rspec --dry-run ${changed_tests_arr.join(' ')} --require ./build/new-jenkins/rspec_location.rb --format RSpecLocationFormatter --out ${env.DOCKER_WORKDIR}/tmp/test_list_split"
"""
@ -204,7 +204,6 @@ pipeline {
// repeats each test FSC_REPEAT_FACTOR times.
// Assumption: non-selenium tests take 500ms / test
// Assumption: selenium tests take 500ms * SELENIUM_RATIO / test
DOCKER_PROCESSES = 1
FSC_REPEAT_FACTOR = 10
MAX_NODES = configuration.getString('fsc-max-nodes', '10')
RSPEC_PROCESSES = 3

View File

@ -1,17 +1,12 @@
#!/bin/bash
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
# ':' is a bash "no-op" and then we pass an empty argument which isn't used
parallel --will-cite ::: :
PROCESSES=$((${DOCKER_PROCESSES:=1}-1))
docker-compose build
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} up -d"
docker-compose up -d
for service in cassandra:9160 dynamodb:8000 redis:6379; do
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T canvas ./build/new-jenkins/wait-for-it ${service}"
docker-compose exec -T canvas ./build/new-jenkins/wait-for-it ${service}
done
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T postgres /bin/bash -c /wait-for-it"
docker-compose exec -T postgres /bin/bash -c /wait-for-it

View File

@ -1,7 +0,0 @@
#!/bin/bash
set -o errexit -o errtrace -o pipefail -o xtrace
# ':' is a bash "no-op" and then we pass an empty argument which isn't used
parallel --will-cite ::: :
# Run each group of tests in separate docker container
seq 0 $((DOCKER_PROCESSES-1)) | parallel -u "docker-compose --project-name canvas-lms{} exec -T -e RSPEC_PROCESSES -e ENABLE_AXE_SELENIUM canvas bash -c 'build/new-jenkins/rspec-with-retries.sh'"

View File

@ -1,14 +0,0 @@
#!/bin/bash
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
# ':' is a bash "no-op" and then we pass an empty argument which isn't used
parallel --will-cite ::: :
PROCESSES=$((${DOCKER_PROCESSES:=1}-1))
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T canvas ./build/new-jenkins/wait-for-it cassandra:9160"
create_cmd=""
for keyspace in auditors global_lookups page_views; do
create_cmd+="CREATE KEYSPACE IF NOT EXISTS ${keyspace} WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
done
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T cassandra cqlsh -e \"${create_cmd[@]}\""

View File

@ -4,7 +4,6 @@ set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
# ':' is a bash "no-op" and then we pass an empty argument which isn't used
parallel --will-cite ::: :
PROCESSES=$((${DOCKER_PROCESSES:=1}-1))
DATABASE_PROCESSES=$((${RSPEC_PROCESSES:=1}-1))
create_cmd=""
@ -12,17 +11,14 @@ for keyspace in auditors global_lookups page_views; do
create_cmd+="CREATE KEYSPACE IF NOT EXISTS ${keyspace} WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
done
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T cassandra cqlsh -e \"${create_cmd[@]}\""
docker-compose exec -T cassandra cqlsh -e "${create_cmd[@]}"
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T canvas bin/rails db:migrate >> ./migrate-{}.log"
seq 0 $PROCESSES | parallel "docker-compose --project-name canvas-lms{} exec -T canvas bin/rails runner \"require 'switchman/test_helper'; Switchman::TestHelper.recreate_persistent_test_shards\""
docker-compose exec -T canvas bin/rails db:migrate >> ./migrate.log
docker-compose exec -T canvas bin/rails runner "require 'switchman/test_helper'; Switchman::TestHelper.recreate_persistent_test_shards"
for i in $(seq 0 $PROCESSES); do
for keyspace in auditors global_lookups page_views; do
seq 0 $DATABASE_PROCESSES | parallel "docker-compose --project-name canvas-lms${i} exec -T cassandra bash -c 'cqlsh -e \"DESCRIBE KEYSPACE ${keyspace}\" | sed \"s/CREATE KEYSPACE ${keyspace}/CREATE KEYSPACE ${keyspace}{}/g ; s/CREATE TABLE ${keyspace}/CREATE TABLE ${keyspace}{}/g\" > ${keyspace}{} && cqlsh -f \"${keyspace}{}\"'"
done
for keyspace in auditors global_lookups page_views; do
seq 0 $DATABASE_PROCESSES | parallel "docker-compose exec -T cassandra bash -c 'cqlsh -e \"DESCRIBE KEYSPACE ${keyspace}\" | sed \"s/CREATE KEYSPACE ${keyspace}/CREATE KEYSPACE ${keyspace}{}/g ; s/CREATE TABLE ${keyspace}/CREATE TABLE ${keyspace}{}/g\" > ${keyspace}{} && cqlsh -f \"${keyspace}{}\"'"
done
for i in $(seq 0 $PROCESSES); do
seq 0 $DATABASE_PROCESSES | parallel "docker-compose --project-name canvas-lms${i} exec -T postgres sh -c 'createdb -U postgres -T canvas_test canvas_test_{}'"
done
seq 0 $DATABASE_PROCESSES | parallel "docker-compose exec -T postgres sh -c 'createdb -U postgres -T canvas_test canvas_test_{}'"

View File

@ -37,7 +37,6 @@ def runSeleniumSuite(total, index) {
config.reruns_retry,
'^./(spec|gems/plugins/.*/spec_canvas)/selenium',
'.*/performance',
'1',
'3',
config.force_failure,
config.patchsetTag
@ -65,7 +64,6 @@ def runRSpecSuite(total, index) {
config.reruns_retry,
'^./(spec|gems/plugins/.*/spec_canvas)/',
'.*/(selenium|contracts)',
'1',
'4',
config.force_failure,
config.patchsetTag
@ -81,7 +79,6 @@ def _runRspecTestSuite(
rerunsRetry,
testFilePattern,
excludeRegex,
dockerProcesses,
rspecProcesses,
forceFailure,
patchsetTag
@ -94,7 +91,6 @@ def _runRspecTestSuite(
"TEST_PATTERN=$testFilePattern",
"EXCLUDE_TESTS=$excludeRegex",
"CI_NODE_TOTAL=$total",
"DOCKER_PROCESSES=$dockerProcesses",
"RSPEC_PROCESSES=$rspecProcesses",
"FORCE_FAILURE=$forceFailure",
'POSTGRES_PASSWORD=sekret',
@ -109,7 +105,7 @@ def _runRspecTestSuite(
sh(script: 'build/new-jenkins/docker-compose-pull.sh', label: 'Pull Images')
}
sh(script: 'build/new-jenkins/docker-compose-build-up.sh', label: 'Start Containers')
sh(script: 'build/new-jenkins/docker-compose-rspec-parallel.sh', label: 'Run Tests')
sh(script: 'docker-compose exec -T -e RSPEC_PROCESSES -e ENABLE_AXE_SELENIUM canvas bash -c \'build/new-jenkins/rspec-with-retries.sh\'', label: 'Run Tests')
}
} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
if (e.causes[0] instanceof org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.ExceededTimeout) {

View File

@ -2,4 +2,4 @@
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
docker-compose --project-name "canvas-lms0" exec -T -e RSPEC_PROCESSES=$RSPEC_PROCESSES -e FORCE_FAILURE=$FORCE_FAILURE -e FSC_REPEAT_FACTOR=$FSC_REPEAT_FACTOR -e FSC_TESTS=$FSC_TESTS canvas bash -c 'build/new-jenkins/rspec-flakey-spec-catcher-parallel.sh'
docker-compose exec -T -e RSPEC_PROCESSES=$RSPEC_PROCESSES -e FORCE_FAILURE=$FORCE_FAILURE -e FSC_REPEAT_FACTOR=$FSC_REPEAT_FACTOR -e FSC_TESTS=$FSC_TESTS canvas bash -c 'build/new-jenkins/rspec-flakey-spec-catcher-parallel.sh'

View File

@ -7,7 +7,7 @@ parallel_index=$1
only_failures=${2-}
# calculate which group to run
max=$((CI_NODE_TOTAL * (DOCKER_PROCESSES * RSPEC_PROCESSES)))
max=$((CI_NODE_TOTAL * RSPEC_PROCESSES))
group=$(((max-CI_NODE_TOTAL * $parallel_index) - CI_NODE_INDEX))
maybeOnlyFailures=()
if [ "${only_failures}" = 'only-failures' ] && [ ! "${RSPEC_LOG:-}" == "1" ]; then

View File

@ -19,11 +19,11 @@ while true; do
if [[ $reruns_started ]]; then
if [ $1 ] && [ $1 = 'performance' ]; then
commands+=("docker-compose --project-name canvas-lms0 exec -T canvas bundle exec rspec --options spec/spec.opts spec/selenium/performance/ --only-failures --failure-exit-code 99")
commands+=("docker-compose exec -T canvas bundle exec rspec --options spec/spec.opts spec/selenium/performance/ --only-failures --failure-exit-code 99")
fi
else
if [ $1 ] && [ $1 = 'performance' ]; then
commands+=("docker-compose --project-name canvas-lms0 exec -T canvas bundle exec rspec --options spec/spec.opts spec/selenium/performance/ --failure-exit-code 99")
commands+=("docker-compose exec -T canvas bundle exec rspec --options spec/spec.opts spec/selenium/performance/ --failure-exit-code 99")
else
for i in $(seq 0 $PROCESSES); do
commands+=("build/new-jenkins/rspec-tests.sh $i")

View File

@ -2,4 +2,4 @@
set -x -o errexit -o errtrace -o nounset -o pipefail
docker-compose --project-name canvas-lms0 exec -T canvas ./engines/test_all_engines.sh
docker-compose exec -T canvas ./engines/test_all_engines.sh

View File

@ -2,4 +2,4 @@
set -x -o errexit -o errtrace -o nounset -o pipefail
docker-compose --project-name canvas-lms0 exec -T canvas ./gems/test_all_gems.sh
docker-compose exec -T canvas ./gems/test_all_gems.sh

View File

@ -2,4 +2,4 @@
set -x -o errexit -o errtrace -o nounset -o pipefail
docker-compose --project-name canvas-lms0 exec -T canvas bundle exec rspec --options spec/spec.opts --tag xbrowser spec/selenium/
docker-compose exec -T canvas bundle exec rspec --options spec/spec.opts --tag xbrowser spec/selenium/

View File

@ -23,7 +23,7 @@ services:
# parallel_tests
CI_NODE_TOTAL:
CI_NODE_INDEX:
DOCKER_PROCESSES:
RSPEC_PROCESSES:
EXCLUDE_TESTS:
TEST_PATTERN:
# rspec-parallel-log build

View File

@ -28,7 +28,7 @@ class CoverageTool
# no formatting by default, just get the json
SimpleCov.at_exit {
# generate an HTML report if this is running locally / not on jenkins:
SimpleCov.result.format! unless ENV['DOCKER_PROCESSES']
SimpleCov.result.format! unless ENV['RSPEC_PROCESSES']
SimpleCov.result
}
end

View File

@ -354,8 +354,8 @@ RSpec.configure do |config|
config.include PGCollkeyHelper
config.project_source_dirs << "gems" # so that failures here are reported properly
# DOCKER_PROCESSES is only used on Jenkins and we only care to have RspecJunitFormatter on Jenkins.
if ENV['DOCKER_PROCESSES']
# RSPEC_PROCESSES is only used on Jenkins and we only care to have RspecJunitFormatter on Jenkins.
if ENV['RSPEC_PROCESSES']
file = "log/results/results-#{ENV.fetch('PARALLEL_INDEX', '0').to_i}.xml"
# if file already exists this is a rerun of a failed spec, don't generate new xml.
config.add_formatter "RspecJunitFormatter", file unless File.file?(file)