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-01 07:34:29 +0300
committerShinya Maeda <shinya@gitlab.com>2018-04-05 08:14:54 +0300
commitd1632da8c30b69ff915e78a86a661282b8ef24e6 (patch)
tree5bb19e4a8f1bb27d4eb24eb34f565985d5daa904 /spec/support/chunked_io
parent8a1c2bc4748dd5b210261905fd84466c25233959 (diff)
Implement basic live trace feature
Diffstat (limited to 'spec/support/chunked_io')
-rw-r--r--spec/support/chunked_io/chunked_io_helpers.rb20
-rw-r--r--spec/support/chunked_io/live_trace_helpers.rb32
2 files changed, 49 insertions, 3 deletions
diff --git a/spec/support/chunked_io/chunked_io_helpers.rb b/spec/support/chunked_io/chunked_io_helpers.rb
index d35968e460c..c12ad743c00 100644
--- a/spec/support/chunked_io/chunked_io_helpers.rb
+++ b/spec/support/chunked_io/chunked_io_helpers.rb
@@ -1,6 +1,6 @@
module ChunkedIOHelpers
def fill_trace_to_chunks(data)
- stream = Gitlab::Ci::Trace::ChunkedFile::ChunkedIO.new(job_id, data.length, 'wb')
+ stream = described_class.new(job_id, data.length, 'wb')
stream.write(data)
stream.close
end
@@ -17,6 +17,20 @@ module ChunkedIOHelpers
sample_trace_raw.length
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, 'wb')
+ 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
@@ -24,12 +38,12 @@ module ChunkedIOHelpers
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)
+ 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
- stub_const("Gitlab::Ci::Trace::ChunkedFile::ChunkedIO::BUFFER_SIZE", new_size)
+ allow_any_instance_of(described_class).to receive(:buffer_size).and_return(new_size)
end
end
diff --git a/spec/support/chunked_io/live_trace_helpers.rb b/spec/support/chunked_io/live_trace_helpers.rb
new file mode 100644
index 00000000000..8ff85daff28
--- /dev/null
+++ b/spec/support/chunked_io/live_trace_helpers.rb
@@ -0,0 +1,32 @@
+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