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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 21:08:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 21:08:54 +0300
commit0d6fa033121a9bef708b8f2de186c4034c61d4a3 (patch)
tree851d65a09efbffa114c9a273e590d55cfb1436ab /spec/lib/gitlab/runtime_spec.rb
parent0eb3d2f799ce4f4de87fb9fc6fd98e592323bc89 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/runtime_spec.rb')
-rw-r--r--spec/lib/gitlab/runtime_spec.rb128
1 files changed, 32 insertions, 96 deletions
diff --git a/spec/lib/gitlab/runtime_spec.rb b/spec/lib/gitlab/runtime_spec.rb
index 52976d925b9..f6e8ad8ae79 100644
--- a/spec/lib/gitlab/runtime_spec.rb
+++ b/spec/lib/gitlab/runtime_spec.rb
@@ -3,6 +3,23 @@
require 'spec_helper'
describe Gitlab::Runtime do
+ shared_examples "valid runtime" do |runtime, max_threads|
+ it "identifies itself" do
+ expect(subject.identify).to eq(runtime)
+ expect(subject.public_send("#{runtime}?")).to be(true)
+ end
+
+ it "does not identify as others" do
+ (described_class::AVAILABLE_RUNTIMES - [runtime]).each do |runtime|
+ expect(subject.public_send("#{runtime}?")).to eq(false)
+ end
+ end
+
+ it "reports its maximum concurrency" do
+ expect(subject.max_threads).to eq(max_threads)
+ end
+ end
+
before do
allow(described_class).to receive(:process_name).and_return('ruby')
stub_rails_env('production')
@@ -27,117 +44,42 @@ describe Gitlab::Runtime do
context "puma" do
let(:puma_type) { double('::Puma') }
- let(:options) do
- {
- max_threads: 2
- }
- end
before do
stub_const('::Puma', puma_type)
- allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(options)
- end
-
- it "identifies itself" do
- expect(subject.identify).to eq(:puma)
- expect(subject.puma?).to be(true)
+ allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(max_threads: 2)
end
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.console?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
- end
-
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(2)
- end
+ it_behaves_like "valid runtime", :puma, 2
end
context "unicorn" do
- let(:unicorn_type) { Module.new }
- let(:unicorn_server_type) { Class.new }
-
before do
- stub_const('::Unicorn', unicorn_type)
- stub_const('::Unicorn::HttpServer', unicorn_server_type)
+ stub_const('::Unicorn', Module.new)
+ stub_const('::Unicorn::HttpServer', Class.new)
end
- it "identifies itself" do
- expect(subject.identify).to eq(:unicorn)
- expect(subject.unicorn?).to be(true)
- end
-
- it "does not identify as others" do
- expect(subject.puma?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.console?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
- end
-
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(1)
- end
+ it_behaves_like "valid runtime", :unicorn, 1
end
context "sidekiq" do
let(:sidekiq_type) { double('::Sidekiq') }
- let(:options) do
- {
- concurrency: 2
- }
- end
before do
stub_const('::Sidekiq', sidekiq_type)
allow(sidekiq_type).to receive(:server?).and_return(true)
- allow(sidekiq_type).to receive(:options).and_return(options)
+ allow(sidekiq_type).to receive(:options).and_return(concurrency: 2)
end
- it "identifies itself" do
- expect(subject.identify).to eq(:sidekiq)
- expect(subject.sidekiq?).to be(true)
- end
-
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.puma?).to be(false)
- expect(subject.console?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
- end
-
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(2)
- end
+ it_behaves_like "valid runtime", :sidekiq, 2
end
context "console" do
- let(:console_type) { double('::Rails::Console') }
-
before do
- stub_const('::Rails::Console', console_type)
- end
-
- it "identifies itself" do
- expect(subject.identify).to eq(:console)
- expect(subject.console?).to be(true)
- end
-
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.puma?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
+ stub_const('::Rails::Console', double('::Rails::Console'))
end
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(1)
- end
+ it_behaves_like "valid runtime", :console, 1
end
context "test suite" do
@@ -145,20 +87,14 @@ describe Gitlab::Runtime do
stub_rails_env('test')
end
- it "identifies itself" do
- expect(subject.identify).to eq(:test_suite)
- expect(subject.test_suite?).to be(true)
- end
+ it_behaves_like "valid runtime", :test_suite, 1
+ end
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.puma?).to be(false)
+ context "geo log cursor" do
+ before do
+ stub_const('::GeoLogCursorOptionParser', double('::GeoLogCursorOptionParser'))
end
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(1)
- end
+ it_behaves_like "valid runtime", :geo_log_cursor, 1
end
end