diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 00:09:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 00:09:24 +0000 |
commit | 2711c26beaca6c3a5a3be4b65e01557faf0185b6 (patch) | |
tree | 25d0c2ddb47e87712044884f558a9104c686805f /spec | |
parent | 8a7aaf86831d2a556578ae558a4fcab8bb659b20 (diff) | |
download | gitlab-ce-2711c26beaca6c3a5a3be4b65e01557faf0185b6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/commit/pipelines/pipelines_spec.js (renamed from spec/javascripts/commit/pipelines/pipelines_spec.js) | 40 | ||||
-rw-r--r-- | spec/frontend/logs/stores/actions_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/monitoring/store/actions_spec.js | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb | 10 | ||||
-rw-r--r-- | spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/prometheus_client_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/application_setting_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/pod_logs/elasticsearch_service_spec.rb | 20 | ||||
-rw-r--r-- | spec/support/helpers/prometheus_helpers.rb | 18 |
11 files changed, 61 insertions, 61 deletions
diff --git a/spec/javascripts/commit/pipelines/pipelines_spec.js b/spec/frontend/commit/pipelines/pipelines_spec.js index 29bdf05b8cf..b88cba90b87 100644 --- a/spec/javascripts/commit/pipelines/pipelines_spec.js +++ b/spec/frontend/commit/pipelines/pipelines_spec.js @@ -1,11 +1,11 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; -import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import mountComponent from 'helpers/vue_mount_component_helper'; import axios from '~/lib/utils/axios_utils'; import Api from '~/api'; import pipelinesTable from '~/commit/pipelines/pipelines_table.vue'; -describe('Pipelines table in Commits and Merge requests', function() { +describe('Pipelines table in Commits and Merge requests', () => { const jsonFixtureName = 'pipelines/pipelines.json'; let pipeline; let PipelinesTable; @@ -37,19 +37,19 @@ describe('Pipelines table in Commits and Merge requests', function() { describe('successful request', () => { describe('without pipelines', () => { - beforeEach(function() { + beforeEach(() => { mock.onGet('endpoint.json').reply(200, []); vm = mountComponent(PipelinesTable, props); }); - it('should render the empty state', function(done) { - setTimeout(() => { + it('should render the empty state', done => { + setImmediate(() => { expect(vm.$el.querySelector('.empty-state')).toBeDefined(); expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null); done(); - }, 0); + }); }); }); @@ -60,19 +60,19 @@ describe('Pipelines table in Commits and Merge requests', function() { }); it('should render a table with the received pipelines', done => { - setTimeout(() => { + setImmediate(() => { expect(vm.$el.querySelectorAll('.ci-table .commit').length).toEqual(1); expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.empty-state')).toBe(null); expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null); done(); - }, 0); + }); }); describe('with pagination', () => { it('should make an API request when using pagination', done => { - setTimeout(() => { - spyOn(vm, 'updateContent'); + setImmediate(() => { + jest.spyOn(vm, 'updateContent').mockImplementation(() => {}); vm.store.state.pageInfo = { page: 1, @@ -135,7 +135,7 @@ describe('Pipelines table in Commits and Merge requests', function() { }), ); - setTimeout(() => { + setImmediate(() => { expect(vm.$el.querySelector('.js-run-mr-pipeline')).not.toBeNull(); done(); }); @@ -156,7 +156,7 @@ describe('Pipelines table in Commits and Merge requests', function() { }), ); - setTimeout(() => { + setImmediate(() => { expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull(); done(); }); @@ -177,7 +177,7 @@ describe('Pipelines table in Commits and Merge requests', function() { }), ); - setTimeout(() => { + setImmediate(() => { expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull(); done(); }); @@ -198,7 +198,7 @@ describe('Pipelines table in Commits and Merge requests', function() { }), ); - setTimeout(() => { + setImmediate(() => { expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull(); done(); }); @@ -222,15 +222,15 @@ describe('Pipelines table in Commits and Merge requests', function() { }); it('updates the loading state', done => { - spyOn(Api, 'postMergeRequestPipeline').and.returnValue(Promise.resolve()); + jest.spyOn(Api, 'postMergeRequestPipeline').mockReturnValue(Promise.resolve()); - setTimeout(() => { + setImmediate(() => { vm.$el.querySelector('.js-run-mr-pipeline').click(); vm.$nextTick(() => { expect(vm.state.isRunningMergeRequestPipeline).toBe(true); - setTimeout(() => { + setImmediate(() => { expect(vm.state.isRunningMergeRequestPipeline).toBe(false); done(); @@ -248,14 +248,14 @@ describe('Pipelines table in Commits and Merge requests', function() { vm = mountComponent(PipelinesTable, props); }); - it('should render error state', function(done) { - setTimeout(() => { + it('should render error state', done => { + setImmediate(() => { expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined(); expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.js-empty-state')).toBe(null); expect(vm.$el.querySelector('.ci-table')).toBe(null); done(); - }, 0); + }); }); }); }); diff --git a/spec/frontend/logs/stores/actions_spec.js b/spec/frontend/logs/stores/actions_spec.js index 1754931bcaf..303737a11cd 100644 --- a/spec/frontend/logs/stores/actions_spec.js +++ b/spec/frontend/logs/stores/actions_spec.js @@ -202,8 +202,8 @@ describe('Logs Store actions', () => { return testAction(fetchLogs, null, state, expectedMutations, expectedActions, () => { expect(latestGetParams()).toEqual({ pod_name: mockPodName, - start: mockFixedRange.start, - end: mockFixedRange.end, + start_time: mockFixedRange.start, + end_time: mockFixedRange.end, cursor: mockCursor, }); }); @@ -280,8 +280,8 @@ describe('Logs Store actions', () => { () => { expect(latestGetParams()).toEqual({ pod_name: mockPodName, - start: mockFixedRange.start, - end: mockFixedRange.end, + start_time: mockFixedRange.start, + end_time: mockFixedRange.end, cursor: mockCursor, }); }, diff --git a/spec/frontend/monitoring/store/actions_spec.js b/spec/frontend/monitoring/store/actions_spec.js index ba41a75ceec..203bc6f4e0e 100644 --- a/spec/frontend/monitoring/store/actions_spec.js +++ b/spec/frontend/monitoring/store/actions_spec.js @@ -509,8 +509,8 @@ describe('Monitoring store actions', () => { }); describe('fetchPrometheusMetric', () => { const params = { - start: '2019-08-06T12:40:02.184Z', - end: '2019-08-06T20:40:02.184Z', + start_time: '2019-08-06T12:40:02.184Z', + end_time: '2019-08-06T20:40:02.184Z', }; let metric; let state; diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb index 15edc649702..55e89395452 100644 --- a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb @@ -14,8 +14,8 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do it 'queries using specific time' do expect(client).to receive(:query_range).with(anything, - start: (deployment.created_at - 30.minutes).to_f, - stop: (deployment.created_at + 30.minutes).to_f) + start_time: (deployment.created_at - 30.minutes).to_f, + end_time: (deployment.created_at + 30.minutes).to_f) expect(query_result).not_to be_nil end diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb index 35dbdd55cfa..95df8880b90 100644 --- a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb @@ -12,7 +12,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do it 'queries using specific time' do expect(client).to receive(:query_range) - .with(anything, start: 8.hours.ago.to_f, stop: Time.now.to_f) + .with(anything, start_time: 8.hours.ago.to_f, end_time: Time.now.to_f) expect(query_result).not_to be_nil end @@ -25,7 +25,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do it 'queries using the provided times' do expect(client).to receive(:query_range) - .with(anything, start: start_time, stop: end_time) + .with(anything, start_time: start_time, end_time: end_time) expect(query_result).not_to be_nil end end @@ -36,7 +36,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do it 'queries using the provided times converted to unix' do expect(client).to receive(:query_range) - .with(anything, start: start_time.to_f, stop: end_time.to_f) + .with(anything, start_time: start_time.to_f, end_time: end_time.to_f) expect(query_result).not_to be_nil end end diff --git a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb index d82b7665f85..4af233291f6 100644 --- a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb @@ -16,22 +16,22 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do it 'sends appropriate queries to prometheus' do start_time = (deployment.created_at - 30.minutes).to_f - stop_time = (deployment.created_at + 30.minutes).to_f + end_time = (deployment.created_at + 30.minutes).to_f created_at = deployment.created_at.to_f expect(client).to receive(:query_range).with('avg(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}) / 2^20', - start: start_time, stop: stop_time) + start_time: start_time, end_time: end_time) expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))', time: created_at) expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))', - time: stop_time) + time: end_time) expect(client).to receive(:query_range).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[2m])) * 100', - start: start_time, stop: stop_time) + start_time: start_time, end_time: end_time) expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100', time: created_at) expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100', - time: stop_time) + time: end_time) expect(subject.query(deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil, cpu_values: nil, cpu_before: nil, cpu_after: nil) diff --git a/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb b/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb index ad254d3c50a..8eefd22bd29 100644 --- a/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb @@ -22,7 +22,7 @@ describe Gitlab::Prometheus::Queries::KnativeInvocationQuery do it 'has the query, but no data' do expect(client).to receive(:query_range).with( 'sum(ceil(rate(istio_requests_total{destination_service_namespace="test-ns", destination_service=~"test-name.*"}[1m])*60))', - hash_including(:start, :stop) + hash_including(:start_time, :end_time) ) subject.query(serverless_func.id) diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 4f9315e28e9..5eb133a5bf4 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -193,23 +193,23 @@ describe Gitlab::PrometheusClient do let(:time_stop) { Time.now.in_time_zone("Warsaw") } let(:time_start) { time_stop - 8.hours } - let(:query_url) { prometheus_query_range_url(prometheus_query, start: time_start.utc.to_f, stop: time_stop.utc.to_f) } + let(:query_url) { prometheus_query_range_url(prometheus_query, start_time: time_start.utc.to_f, end_time: time_stop.utc.to_f) } it 'passed dates are properly converted to utc' do req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector')) - subject.query_range(prometheus_query, start: time_start, stop: time_stop) + subject.query_range(prometheus_query, start_time: time_start, end_time: time_stop) expect(req_stub).to have_been_requested end end context 'when a start time is passed' do - let(:query_url) { prometheus_query_range_url(prometheus_query, start: 2.hours.ago) } + let(:query_url) { prometheus_query_range_url(prometheus_query, start_time: 2.hours.ago) } it 'passed it in the requested URL' do req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector')) - subject.query_range(prometheus_query, start: 2.hours.ago) + subject.query_range(prometheus_query, start_time: 2.hours.ago) expect(req_stub).to have_been_requested end end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 9dad6b1e766..4c96b0079df 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -715,7 +715,7 @@ describe ApplicationSetting do subject.email_restrictions = '+' expect(subject).not_to be_valid - expect(subject.errors.messages[:email_restrictions].first).to eq(_('is not a valid regular expression')) + expect(subject.errors.messages[:email_restrictions].first).to eq(_('not valid RE2 syntax: no argument for repetition operator: +')) end end diff --git a/spec/services/pod_logs/elasticsearch_service_spec.rb b/spec/services/pod_logs/elasticsearch_service_spec.rb index 1387d2cfb8e..39aa910d878 100644 --- a/spec/services/pod_logs/elasticsearch_service_spec.rb +++ b/spec/services/pod_logs/elasticsearch_service_spec.rb @@ -27,8 +27,8 @@ describe ::PodLogs::ElasticsearchService do context 'with start and end provided and valid' do let(:params) do { - 'start' => start_time, - 'end' => end_time + 'start_time' => start_time, + 'end_time' => end_time } end @@ -36,8 +36,8 @@ describe ::PodLogs::ElasticsearchService do result = subject.send(:check_times, {}) expect(result[:status]).to eq(:success) - expect(result[:start]).to eq(start_time) - expect(result[:end]).to eq(end_time) + expect(result[:start_time]).to eq(start_time) + expect(result[:end_time]).to eq(end_time) end end @@ -57,8 +57,8 @@ describe ::PodLogs::ElasticsearchService do context 'with start valid and end invalid' do let(:params) do { - 'start' => start_time, - 'end' => 'invalid date' + 'start_time' => start_time, + 'end_time' => 'invalid date' } end @@ -73,8 +73,8 @@ describe ::PodLogs::ElasticsearchService do context 'with start invalid and end valid' do let(:params) do { - 'start' => 'invalid date', - 'end' => end_time + 'start_time' => 'invalid date', + 'end_time' => end_time } end @@ -153,8 +153,8 @@ describe ::PodLogs::ElasticsearchService do pod_name: pod_name, container_name: container_name, search: search, - start: start_time, - end: end_time, + start_time: start_time, + end_time: end_time, cursor: cursor } end diff --git a/spec/support/helpers/prometheus_helpers.rb b/spec/support/helpers/prometheus_helpers.rb index 7c03746a395..0fdc4de1b36 100644 --- a/spec/support/helpers/prometheus_helpers.rb +++ b/spec/support/helpers/prometheus_helpers.rb @@ -31,15 +31,15 @@ module PrometheusHelpers "https://prometheus.example.com/api/v1/query?#{query}" end - def prometheus_query_range_url(prometheus_query, start: 8.hours.ago, stop: Time.now, step: nil) - start = start.to_f - stop = stop.to_f - step ||= Gitlab::PrometheusClient.compute_step(start, stop) + def prometheus_query_range_url(prometheus_query, start_time: 8.hours.ago, end_time: Time.now, step: nil) + start_time = start_time.to_f + end_time = end_time.to_f + step ||= Gitlab::PrometheusClient.compute_step(start_time, end_time) query = { query: prometheus_query, - start: start, - end: stop, + start: start_time, + end: end_time, step: step }.to_query @@ -50,11 +50,11 @@ module PrometheusHelpers "https://prometheus.example.com/api/v1/label/#{name}/values" end - def prometheus_series_url(*matches, start: 8.hours.ago, stop: Time.now) + def prometheus_series_url(*matches, start_time: 8.hours.ago, end_time: Time.now) query = { match: matches, - start: start.to_f, - end: stop.to_f + start: start_time.to_f, + end: end_time.to_f }.to_query "https://prometheus.example.com/api/v1/series?#{query}" end |