summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-11-25 04:16:39 +0000
committerRobert Speicher <robert@gitlab.com>2016-11-25 04:16:39 +0000
commit40fa5604f38409f12d709c425286a6047d2c8e06 (patch)
treebd4ff5e4258d3642c8d37d73da1bb543f3e40ad8 /spec
parent5522b9dc0e488a4561e7791c8d85e39615da2901 (diff)
parent71ad3d294ec6ddfb36346e19e6b50ec5eb8d4ef2 (diff)
downloadgitlab-ce-40fa5604f38409f12d709c425286a6047d2c8e06.tar.gz
Merge branch 'fix/invalid-storage-cleanup-affecting-test-suite' into 'master'
Make test suite deterministic when storage is involved ## What does this MR do? This MR fixes our RSpec test harness because one test example could affect subsequent examples if objects created with `let` had associated files stored in `tmp/tests`. We store files using CarrierWave, but we also have some custom storage rules for CI builds. Some time ago we introduced MR that purged CarrierWave uploads after each run of entire test suite https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3435, but this is not enough, as we should isolate each test example to be able to rely on deterministic test suite. Not cleaning uploads between each test example run, makes it impossible to know if preconditions are correct before test example starts to run, therefore it makes test examples, that use storage, unreliable. This MR is an attempt to improve that. ## What are the relevant issue numbers? Closes #24808 See merge request !7695
Diffstat (limited to 'spec')
-rw-r--r--spec/support/carrierwave.rb2
-rw-r--r--spec/support/setup_builds_storage.rb17
2 files changed, 9 insertions, 10 deletions
diff --git a/spec/support/carrierwave.rb b/spec/support/carrierwave.rb
index aa89afd8fb3..72af2c70324 100644
--- a/spec/support/carrierwave.rb
+++ b/spec/support/carrierwave.rb
@@ -1,7 +1,7 @@
CarrierWave.root = 'tmp/tests/uploads'
RSpec.configure do |config|
- config.after(:suite) do
+ config.after(:each) do
FileUtils.rm_rf('tmp/tests/uploads')
end
end
diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb
index a4f21e95338..2e7c88bfc09 100644
--- a/spec/support/setup_builds_storage.rb
+++ b/spec/support/setup_builds_storage.rb
@@ -1,19 +1,18 @@
RSpec.configure do |config|
def builds_path
- Rails.root.join('tmp/builds')
+ Rails.root.join('tmp/tests/builds')
end
- config.before(:each) do
- FileUtils.mkdir_p(builds_path)
- FileUtils.touch(File.join(builds_path, ".gitkeep"))
+ config.before(:suite) do
Settings.gitlab_ci['builds_path'] = builds_path
end
- config.after(:suite) do
- Dir[File.join(builds_path, '*')].each do |path|
- next if File.basename(path) == '.gitkeep'
+ config.before(:all) do
+ FileUtils.mkdir_p(builds_path)
+ end
- FileUtils.rm_rf(path)
- end
+ config.before(:each) do
+ FileUtils.rm_rf(builds_path)
+ FileUtils.mkdir_p(builds_path)
end
end