From fc439c30bf8e328e40f38e8fe34c70b3518f8685 Mon Sep 17 00:00:00 2001 From: Ethan Vizitei Date: Tue, 2 Nov 2021 11:48:37 -0500 Subject: [PATCH] parameterize class caching in test closes FOO-2539 flag=none TEST PLAN: 1) specs pass Change-Id: Ibd4030767a8f015b3c197a568d7bb26a91dca92d Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277273 Reviewed-by: Cody Cutrer Product-Review: Cody Cutrer Tested-by: Service Cloud Jenkins QA-Review: Ethan Vizitei --- Jenkinsfile | 10 ++++++++++ config/environments/test.rb | 7 ++++++- docker-compose.new-jenkins.yml | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0c635b82b53..6cb1d9387ee 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -303,6 +303,16 @@ pipeline { CANVAS_LMS_REFSPEC = getCanvasLmsRefspec() DOCKER_WORKDIR = getDockerWorkDir() LOCAL_WORKDIR = getLocalWorkDir() + + // TEST_CACHE_CLASSES is consumed by config/environments/test.rb + // to decide whether to allow class reloading or not. + // in local development we usually want this unset or set to '0' because + // we want spring to be able to reload classes between + // spec runs, but this is expensive when running all the + // specs for the build. EVERYWHERE in the build we want + // to be able to cache classes because they don't change while the build + // is running and should never be reloaded. + TEST_CACHE_CLASSES = '1' } stages { diff --git a/config/environments/test.rb b/config/environments/test.rb index c34b093d22e..73c12f9877e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -24,7 +24,12 @@ environment_configuration(defined?(config) && config) do |config| # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true + # In local development we usually want this unset or set to '0' because + # we want spring to be able to reload classes between + # spec runs, but this is expensive when running all the + # specs for the build, so this ENV var can be provided by + # any harness to turn class caching on for performance. + config.cache_classes = (ENV.fetch("TEST_CACHE_CLASSES", "0") == "1") # Show formatted error reports and disable caching config.consider_all_requests_local = false diff --git a/docker-compose.new-jenkins.yml b/docker-compose.new-jenkins.yml index 91c42e06c37..c2a1ce9ea53 100644 --- a/docker-compose.new-jenkins.yml +++ b/docker-compose.new-jenkins.yml @@ -19,6 +19,7 @@ services: FORCE_FAILURE: CANVAS_RAILS6_0: CANVAS_ZEITWERK: + TEST_CACHE_CLASSES: # parallel_tests CI_NODE_TOTAL: