Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-04-02 17:11:48 +0300
committerShinya Maeda <shinya@gitlab.com>2018-04-05 08:14:54 +0300
commit1de5b8db5a684d367a1555c754220ba6b9f1e268 (patch)
tree1e0ef14fe418b7bcb4d3e38f713d3407b87fc239 /spec/support/chunked_io
parent3a99a6b9033b669d062e7aa63a680c86240fac6e (diff)
Fix Live trace
Diffstat (limited to 'spec/support/chunked_io')
-rw-r--r--spec/support/chunked_io/chunked_io_helpers.rb29
-rw-r--r--spec/support/chunked_io/live_trace_helpers.rb32
2 files changed, 8 insertions, 53 deletions
diff --git a/spec/support/chunked_io/chunked_io_helpers.rb b/spec/support/chunked_io/chunked_io_helpers.rb
index 35b13bccdb4..e9dd2e77538 100644
--- a/spec/support/chunked_io/chunked_io_helpers.rb
+++ b/spec/support/chunked_io/chunked_io_helpers.rb
@@ -6,31 +6,14 @@ module ChunkedIOHelpers
end
def sample_trace_raw
- if chunk_store == Gitlab::Ci::Trace::ChunkedFile::ChunkStore::Redis
- File.read(expand_fixture_path('trace/sample_trace'))
+ # ChunkStore::Database doesn't support appending, so the test data size has to be least common multiple
+ if chunk_stores.first == Gitlab::Ci::Trace::ChunkedFile::ChunkStore::Database
+ '01234567' * 32 # 256 bytes
else
- '01234567' * 32
+ File.read(expand_fixture_path('trace/sample_trace'))
end
end
- # def sample_trace_raw_for_live_trace
- # File.read(expand_fixture_path('trace/sample_trace'))
- # end
-
- # def sample_trace_size_for_live_trace
- # sample_trace_raw_for_live_trace.length
- # end
-
- # def fill_trace_to_chunks_for_live_trace(data)
- # stream = described_class.new(job_id, 'a+b')
- # stream.write(data)
- # stream.close
- # end
-
- # def stub_chunk_store_get_failed
- # allow_any_instance_of(chunk_store).to receive(:get).and_return(nil)
- # end
-
def set_smaller_buffer_size_than(file_size)
blocks = (file_size / 128)
new_size = (blocks / 2) * 128
@@ -42,4 +25,8 @@ module ChunkedIOHelpers
new_size = (blocks * 2) * 128
allow_any_instance_of(described_class).to receive(:buffer_size).and_return(new_size)
end
+
+ def set_half_buffer_size_of(file_size)
+ allow_any_instance_of(described_class).to receive(:buffer_size).and_return(file_size / 2)
+ end
end
diff --git a/spec/support/chunked_io/live_trace_helpers.rb b/spec/support/chunked_io/live_trace_helpers.rb
deleted file mode 100644
index 8ff85daff28..00000000000
--- a/spec/support/chunked_io/live_trace_helpers.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-module LiveTraceHelpers
- def fill_trace_to_chunks(data)
- stream = described_class.new(job_id, 'wb')
- stream.write(data)
- stream.close
- end
-
- def sample_trace_raw
- File.read(expand_fixture_path('trace/sample_trace'))
- end
-
- def sample_trace_size
- sample_trace_raw.length
- end
-
- def stub_chunk_store_get_failed
- allow_any_instance_of(Gitlab::Ci::Trace::ChunkedFile::ChunkStore::Redis).to receive(:get).and_return(nil)
- allow_any_instance_of(Gitlab::Ci::Trace::ChunkedFile::ChunkStore::Database).to receive(:get).and_return(nil)
- end
-
- def set_smaller_buffer_size_than(file_size)
- blocks = (file_size / 128)
- new_size = (blocks / 2) * 128
- allow_any_instance_of(described_class).to receive(:buffer_size).and_return(new_size)
- end
-
- def set_larger_buffer_size_than(file_size)
- blocks = (file_size / 128)
- new_size = (blocks * 2) * 128
- allow_any_instance_of(described_class).to receive(:buffer_size).and_return(new_size)
- end
-end