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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-19 21:06:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-19 21:06:18 +0300
commit81f7adf08b4557c38ac2ef1c730e72e07db2f1a3 (patch)
tree37239c312903ca5e6ca079b64c35a6e0e01b18c4 /spec
parent383daa1200fb0b8859e2b6ec0eb55f4615538749 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/jobs/components/log/collapsible_section_spec.js60
-rw-r--r--spec/frontend/jobs/components/log/mock_data.js70
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb10
-rw-r--r--spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb26
-rw-r--r--spec/workers/object_pool/destroy_worker_spec.rb4
5 files changed, 148 insertions, 22 deletions
diff --git a/spec/frontend/jobs/components/log/collapsible_section_spec.js b/spec/frontend/jobs/components/log/collapsible_section_spec.js
new file mode 100644
index 00000000000..6c1ebf0a7c1
--- /dev/null
+++ b/spec/frontend/jobs/components/log/collapsible_section_spec.js
@@ -0,0 +1,60 @@
+import { mount } from '@vue/test-utils';
+import CollpasibleSection from '~/jobs/components/log/collapsible_section.vue';
+import { nestedSectionOpened, nestedSectionClosed } from './mock_data';
+
+describe('Job Log Collapsible Section', () => {
+ let wrapper;
+
+ const traceEndpoint = 'jobs/335';
+
+ const findCollapsibleLine = () => wrapper.find('.collapsible-line');
+
+ const createComponent = (props = {}) => {
+ wrapper = mount(CollpasibleSection, {
+ sync: true,
+ propsData: {
+ ...props,
+ },
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('with closed nested section', () => {
+ beforeEach(() => {
+ createComponent({
+ section: nestedSectionClosed,
+ traceEndpoint,
+ });
+ });
+
+ it('renders clickable header line', () => {
+ expect(findCollapsibleLine().attributes('role')).toBe('button');
+ });
+ });
+
+ describe('with opened nested section', () => {
+ beforeEach(() => {
+ createComponent({
+ section: nestedSectionOpened,
+ traceEndpoint,
+ });
+ });
+
+ it('renders all sections opened', () => {
+ expect(wrapper.findAll('.collapsible-line').length).toBe(2);
+ });
+ });
+
+ it('emits onClickCollapsibleLine on click', () => {
+ createComponent({
+ section: nestedSectionOpened,
+ traceEndpoint,
+ });
+
+ findCollapsibleLine().trigger('click');
+ expect(wrapper.emitted('onClickCollapsibleLine').length).toBe(1);
+ });
+});
diff --git a/spec/frontend/jobs/components/log/mock_data.js b/spec/frontend/jobs/components/log/mock_data.js
index db42644de77..0dae306dcc7 100644
--- a/spec/frontend/jobs/components/log/mock_data.js
+++ b/spec/frontend/jobs/components/log/mock_data.js
@@ -150,3 +150,73 @@ export const collapsibleTraceIncremental = [
sections: ['section'],
},
];
+
+export const nestedSectionClosed = {
+ offset: 5,
+ section_header: true,
+ isHeader: true,
+ isClosed: true,
+ line: {
+ content: [{ text: 'foo' }],
+ sections: ['prepare-script'],
+ lineNumber: 1,
+ },
+ section_duration: '00:03',
+ lines: [
+ {
+ section_header: true,
+ section_duration: '00:02',
+ isHeader: true,
+ isClosed: true,
+ line: {
+ offset: 52,
+ content: [{ text: 'bar' }],
+ sections: ['prepare-script', 'prepare-script-nested'],
+ lineNumber: 2,
+ },
+ lines: [
+ {
+ offset: 80,
+ content: [{ text: 'this is a collapsible nested section' }],
+ sections: ['prepare-script', 'prepare-script-nested'],
+ lineNumber: 3,
+ },
+ ],
+ },
+ ],
+};
+
+export const nestedSectionOpened = {
+ offset: 5,
+ section_header: true,
+ isHeader: true,
+ isClosed: false,
+ line: {
+ content: [{ text: 'foo' }],
+ sections: ['prepare-script'],
+ lineNumber: 1,
+ },
+ section_duration: '00:03',
+ lines: [
+ {
+ section_header: true,
+ section_duration: '00:02',
+ isHeader: true,
+ isClosed: false,
+ line: {
+ offset: 52,
+ content: [{ text: 'bar' }],
+ sections: ['prepare-script', 'prepare-script-nested'],
+ lineNumber: 2,
+ },
+ lines: [
+ {
+ offset: 80,
+ content: [{ text: 'this is a collapsible nested section' }],
+ sections: ['prepare-script', 'prepare-script-nested'],
+ lineNumber: 3,
+ },
+ ],
+ },
+ ],
+};
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index 1c5f72a4396..ea3bb12d049 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -182,24 +182,24 @@ describe Gitlab::GitalyClient do
end
it 'sets the gitaly-session-id in the metadata' do
- results = described_class.request_kwargs('default', nil)
+ results = described_class.request_kwargs('default', timeout: 1)
expect(results[:metadata]).to include('gitaly-session-id')
end
context 'when RequestStore is not enabled' do
it 'sets a different gitaly-session-id per request' do
- gitaly_session_id = described_class.request_kwargs('default', nil)[:metadata]['gitaly-session-id']
+ gitaly_session_id = described_class.request_kwargs('default', timeout: 1)[:metadata]['gitaly-session-id']
- expect(described_class.request_kwargs('default', nil)[:metadata]['gitaly-session-id']).not_to eq(gitaly_session_id)
+ expect(described_class.request_kwargs('default', timeout: 1)[:metadata]['gitaly-session-id']).not_to eq(gitaly_session_id)
end
end
context 'when RequestStore is enabled', :request_store do
it 'sets the same gitaly-session-id on every outgoing request metadata' do
- gitaly_session_id = described_class.request_kwargs('default', nil)[:metadata]['gitaly-session-id']
+ gitaly_session_id = described_class.request_kwargs('default', timeout: 1)[:metadata]['gitaly-session-id']
3.times do
- expect(described_class.request_kwargs('default', nil)[:metadata]['gitaly-session-id']).to eq(gitaly_session_id)
+ expect(described_class.request_kwargs('default', timeout: 1)[:metadata]['gitaly-session-id']).to eq(gitaly_session_id)
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb b/spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb
index 3b3fcfc89d7..756c7947df0 100644
--- a/spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb
+++ b/spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb
@@ -75,12 +75,6 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
end
end
- it 'invoke rss_within_range? twice' do
- expect(memory_killer).to receive(:rss_within_range?).twice
-
- subject
- end
-
it 'not invoke restart_sidekiq when rss in range' do
expect(memory_killer).to receive(:rss_within_range?).twice.and_return(true)
@@ -128,7 +122,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:soft_limit_rss).and_return(200)
expect(memory_killer).to receive(:hard_limit_rss).and_return(300)
- expect(Time).to receive(:now).and_call_original
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_call_original
expect(memory_killer).not_to receive(:log_rss_out_of_range)
expect(subject).to be true
@@ -139,7 +133,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:soft_limit_rss).at_least(:once).and_return(200)
expect(memory_killer).to receive(:hard_limit_rss).at_least(:once).and_return(300)
- expect(Time).to receive(:now).and_call_original
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_call_original
expect(memory_killer).to receive(:log_rss_out_of_range).with(400, 300, 200)
@@ -151,7 +145,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:soft_limit_rss).at_least(:once).and_return(200)
expect(memory_killer).to receive(:hard_limit_rss).at_least(:once).and_return(300)
- expect(Time).to receive(:now).twice.and_call_original
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).twice.and_call_original
expect(memory_killer).to receive(:sleep).with(check_interval_seconds)
expect(memory_killer).to receive(:log_rss_out_of_range).with(400, 300, 200)
@@ -164,7 +158,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:soft_limit_rss).and_return(200, 200)
expect(memory_killer).to receive(:hard_limit_rss).and_return(300, 300)
- expect(Time).to receive(:now).twice.and_call_original
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).twice.and_call_original
expect(memory_killer).to receive(:sleep).with(check_interval_seconds)
expect(memory_killer).not_to receive(:log_rss_out_of_range)
@@ -177,7 +171,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:soft_limit_rss).exactly(5).times.and_return(200)
expect(memory_killer).to receive(:hard_limit_rss).exactly(5).times.and_return(300)
- expect(Time).to receive(:now).exactly(5).times.and_call_original
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).exactly(5).times.and_call_original
expect(memory_killer).to receive(:sleep).exactly(3).times.with(check_interval_seconds).and_call_original
expect(memory_killer).to receive(:log_rss_out_of_range).with(250, 300, 200)
@@ -219,7 +213,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
it 'send signal and return when all jobs finished' do
expect(Process).to receive(:kill).with(signal, pid).ordered
- expect(Time).to receive(:now).and_call_original
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_call_original
expect(memory_killer).to receive(:enabled?).and_return(true)
expect(memory_killer).to receive(:any_jobs?).and_return(false)
@@ -231,7 +225,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
it 'send signal and wait till deadline if any job not finished' do
expect(Process).to receive(:kill).with(signal, pid).ordered
- expect(Time).to receive(:now).and_call_original.at_least(:once)
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_call_original.at_least(:once)
expect(memory_killer).to receive(:enabled?).and_return(true).at_least(:once)
expect(memory_killer).to receive(:any_jobs?).and_return(true).at_least(:once)
@@ -351,7 +345,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
subject { memory_killer.send(:rss_increase_by_job, job) }
before do
- stub_const("#{described_class}::MAX_MEMORY_KB", max_memory_kb)
+ stub_const("#{described_class}::DEFAULT_MAX_MEMORY_GROWTH_KB", max_memory_kb)
end
it 'return 0 if memory_growth_kb return 0' do
@@ -366,7 +360,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:get_job_options).with(job, 'memory_killer_memory_growth_kb', 0).and_return(10)
expect(memory_killer).to receive(:get_job_options).with(job, 'memory_killer_max_memory_growth_kb', max_memory_kb).and_return(100)
- expect(Time).to receive(:now).and_return(323)
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(323)
expect(subject).to eq(20)
end
@@ -374,7 +368,7 @@ describe Gitlab::SidekiqDaemon::MemoryKiller do
expect(memory_killer).to receive(:get_job_options).with(job, 'memory_killer_memory_growth_kb', 0).and_return(10)
expect(memory_killer).to receive(:get_job_options).with(job, 'memory_killer_max_memory_growth_kb', max_memory_kb).and_return(100)
- expect(Time).to receive(:now).and_return(332)
+ expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(332)
expect(subject).to eq(100)
end
end
diff --git a/spec/workers/object_pool/destroy_worker_spec.rb b/spec/workers/object_pool/destroy_worker_spec.rb
index ef74f0ba87c..52d457b4b71 100644
--- a/spec/workers/object_pool/destroy_worker_spec.rb
+++ b/spec/workers/object_pool/destroy_worker_spec.rb
@@ -16,7 +16,9 @@ describe ObjectPool::DestroyWorker do
subject { described_class.new }
it 'requests Gitaly to remove the object pool' do
- expect(Gitlab::GitalyClient).to receive(:call).with(pool.shard_name, :object_pool_service, :delete_object_pool, Object)
+ expect(Gitlab::GitalyClient).to receive(:call)
+ .with(pool.shard_name, :object_pool_service, :delete_object_pool,
+ Object, timeout: Gitlab::GitalyClient.long_timeout)
subject.perform(pool.id)
end