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-09-19 04:45:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/tasks
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb9
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb26
-rw-r--r--spec/tasks/gitlab/usage_data_rake_spec.rb35
3 files changed, 65 insertions, 5 deletions
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index 6ac46712aa3..a2cc2b12e5e 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -160,7 +160,8 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
expect(raw_repo.empty?).to be(false)
end
end
- end # backup_restore task
+ end
+ # backup_restore task
describe 'backup' do
before do
@@ -391,7 +392,8 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
end
end
- end # backup_create task
+ end
+ # backup_create task
describe "Skipping items" do
before do
@@ -486,4 +488,5 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
expect(backup_tar).to match(/\d+_\d{4}_\d{2}_\d{2}_\d+\.\d+\.\d+.*_gitlab_backup.tar$/)
end
end
-end # gitlab:app namespace
+end
+# gitlab:app namespace
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index a78506803be..99efd394e83 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -164,9 +164,31 @@ RSpec.describe 'gitlab:db namespace rake task' do
end
end
- def run_rake_task(task_name)
+ describe 'reindex' do
+ context 'when no index_name is given' do
+ it 'raises an error' do
+ expect do
+ run_rake_task('gitlab:db:reindex', '')
+ end.to raise_error(ArgumentError, /must give the index name/)
+ end
+ end
+
+ it 'calls the index rebuilder with the proper arguments' do
+ reindex = double('rebuilder')
+
+ expect(Gitlab::Database::ConcurrentReindex).to receive(:new)
+ .with('some_index_name', logger: instance_of(Logger))
+ .and_return(reindex)
+
+ expect(reindex).to receive(:execute)
+
+ run_rake_task('gitlab:db:reindex', '[some_index_name]')
+ end
+ end
+
+ def run_rake_task(task_name, arguments = '')
Rake::Task[task_name].reenable
- Rake.application.invoke_task task_name
+ Rake.application.invoke_task("#{task_name}#{arguments}")
end
def expect_multiple_executions_of_task(test_task_name, task_to_invoke, count: 2)
diff --git a/spec/tasks/gitlab/usage_data_rake_spec.rb b/spec/tasks/gitlab/usage_data_rake_spec.rb
new file mode 100644
index 00000000000..0ee6fbef53f
--- /dev/null
+++ b/spec/tasks/gitlab/usage_data_rake_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'rake_helper'
+
+RSpec.describe 'gitlab:usage data take tasks' do
+ before do
+ Rake.application.rake_require 'tasks/gitlab/usage_data'
+ # stub prometheus external http calls https://gitlab.com/gitlab-org/gitlab/-/issues/245277
+ stub_request(:get, %r{^http[s]?://::1:9090/-/ready})
+ .to_return(
+ status: 200,
+ body: [{}].to_json,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+
+ stub_request(:get, %r{^http[s]?://::1:9090/api/v1/query\?query=.*})
+ .to_return(
+ status: 200,
+ body: [{}].to_json,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+ end
+
+ describe 'dump_sql_in_yaml' do
+ it 'dumps SQL queries in yaml format' do
+ expect { run_rake_task('gitlab:usage_data:dump_sql_in_yaml') }.to output(/.*recorded_at:.*/).to_stdout
+ end
+ end
+
+ describe 'dump_sql_in_json' do
+ it 'dumps SQL queries in json format' do
+ expect { run_rake_task('gitlab:usage_data:dump_sql_in_json') }.to output(/.*"recorded_at":.*/).to_stdout
+ end
+ end
+end