summaryrefslogtreecommitdiff
path: root/spec/support/chunked_io
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-03-30 01:44:41 +0900
committerShinya Maeda <shinya@gitlab.com>2018-04-05 14:14:53 +0900
commit1a05c60ee650fce76b7359464c36cc22f917ba62 (patch)
tree49980ff8fb22857f511ca433366d053df090d966 /spec/support/chunked_io
parent1108df181ccba91454cbe122bcf7af05c6d76fe3 (diff)
downloadgitlab-ce-1a05c60ee650fce76b7359464c36cc22f917ba62.tar.gz
Add spec for chunked_io
Diffstat (limited to 'spec/support/chunked_io')
-rw-r--r--spec/support/chunked_io/chunked_io_helpers.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/support/chunked_io/chunked_io_helpers.rb b/spec/support/chunked_io/chunked_io_helpers.rb
new file mode 100644
index 00000000000..d87483620e5
--- /dev/null
+++ b/spec/support/chunked_io/chunked_io_helpers.rb
@@ -0,0 +1,32 @@
+module ChunkedIOHelpers
+ def fill_trace_to_chunks(data)
+ stream = Gitlab::Ci::Trace::ChunkedFile::ChunkedIO.new(job_id, data.length, 'wb')
+ stream.write(data)
+ stream.close
+ end
+
+ def sample_trace_raw
+ @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_redis_get_failed
+ allow_any_instance_of(Gitlab::Ci::Trace::ChunkedFile::ChunkStore::Redis)
+ .to receive(:get).and_return(nil)
+ end
+
+ def set_smaller_buffer_size_than(file_size)
+ blocks = (file_size / 128)
+ new_size = (blocks / 2) * 128
+ stub_const("Gitlab::Ci::Trace::ChunkedFile::ChunkedIO::BUFFER_SIZE", new_size)
+ end
+
+ def set_larger_buffer_size_than(file_size)
+ blocks = (file_size / 128)
+ new_size = (blocks * 2) * 128
+ stub_const("Gitlab::Ci::Trace::ChunkedFile::ChunkedIO::BUFFER_SIZE", new_size)
+ end
+end