From 8ceb51f38eef66adc10a43538f1251e4c1ca669f Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Thu, 21 Dec 2017 18:21:01 +0100 Subject: [PATCH 01/16] initial wip --- qa/qa/runtime/admin_user.rb | 15 ++++ .../features/ee/api/geo_status_node_spec.rb | 72 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 qa/qa/runtime/admin_user.rb create mode 100644 qa/qa/specs/features/ee/api/geo_status_node_spec.rb diff --git a/qa/qa/runtime/admin_user.rb b/qa/qa/runtime/admin_user.rb new file mode 100644 index 00000000000000..a54d58833f3f98 --- /dev/null +++ b/qa/qa/runtime/admin_user.rb @@ -0,0 +1,15 @@ +module QA + module Runtime + module AdminUser + extend self + + def name + ENV['GITLAB_USERNAME'] || 'myadmin' + end + + def password + ENV['GITLAB_PASSWORD'] || 'myadmin!!' + end + end + end +end diff --git a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb new file mode 100644 index 00000000000000..19cd0f8a75f5e6 --- /dev/null +++ b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb @@ -0,0 +1,72 @@ +require "pry-byebug" +require 'faraday' + +# describe 'test', :core, api: true do +# # include ApiHelpers +# # include ::EE::GeoHelpers +# +# # set(:primary) { create(:geo_node, :primary) } +# # set(:secondary) { create(:geo_node) } +# # set(:another_secondary) { create(:geo_node) } +# # +# # set(:secondary_status) { create(:geo_node_status, :healthy, geo_node_id: secondary.id) } +# # set(:another_secondary_status) { create(:geo_node_status, :healthy, geo_node_id: another_secondary.id) } +# # +# # let(:admin) { create(:admin) } +# # let(:user) { create(:user) } +# +# describe 'GET /geo_nodes' do +# it 'retrieves the Geo nodes if admin is logged in' do +# # get api("/geo_nodes", admin) +# binding.pry +# response = Faraday.get 'http://sushi.com/nigiri/sake.json' +# get "/geo_nodes" +# +# expect(response).to have_gitlab_http_status(200) +# expect(response).to match_response_schema('geo_nodes') +# end +# +# # it 'denies access if not admin' do +# # get api('/geo_nodes', user) +# # +# # expect(response).to have_gitlab_http_status(403) +# # end +# end +# end + +module QA + feature 'get Geo Node status', :core do + context 'with regular account over http' do + + scenario 'xxxx' do + Runtime::API.get(:gitlab, '/geo_nodes') + # get "/api/v1/items/1",:formate =>:json + expect(1).to eq 2 + end + + # scenario 'user pushes code to the repository' do + # Runtime::Browser.visit(:gitlab, Page::Main::Login) + # Page::Main::Login.act { sign_in_using_credentials } + # + # Factory::Resource::Project.fabricate! do |scenario| + # scenario.name = 'project_with_code' + # scenario.description = 'project with repository' + # end + # + # Factory::Repository::Push.fabricate! do |scenario| + # scenario.file_name = 'README.md' + # scenario.file_content = '# This is test project' + # scenario.commit_message = 'Add README.md' + # end + # + # Page::Project::Show.act do + # wait_for_push + # refresh + # end + # + # expect(page).to have_content('README.md') + # expect(page).to have_content('This is test project') + # end + end + end +end -- GitLab From d9aaef26feac884400ed44b4f40647a43eb1caf6 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Thu, 21 Dec 2017 18:26:28 +0100 Subject: [PATCH 02/16] initial wip --- .../features/ee/api/geo_status_node_spec.rb | 66 ++----------------- 1 file changed, 4 insertions(+), 62 deletions(-) diff --git a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb index 19cd0f8a75f5e6..bbd1518ebfdaa5 100644 --- a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb @@ -1,72 +1,14 @@ -require "pry-byebug" +require 'pry-byebug' require 'faraday' -# describe 'test', :core, api: true do -# # include ApiHelpers -# # include ::EE::GeoHelpers -# -# # set(:primary) { create(:geo_node, :primary) } -# # set(:secondary) { create(:geo_node) } -# # set(:another_secondary) { create(:geo_node) } -# # -# # set(:secondary_status) { create(:geo_node_status, :healthy, geo_node_id: secondary.id) } -# # set(:another_secondary_status) { create(:geo_node_status, :healthy, geo_node_id: another_secondary.id) } -# # -# # let(:admin) { create(:admin) } -# # let(:user) { create(:user) } -# -# describe 'GET /geo_nodes' do -# it 'retrieves the Geo nodes if admin is logged in' do -# # get api("/geo_nodes", admin) -# binding.pry -# response = Faraday.get 'http://sushi.com/nigiri/sake.json' -# get "/geo_nodes" -# -# expect(response).to have_gitlab_http_status(200) -# expect(response).to match_response_schema('geo_nodes') -# end -# -# # it 'denies access if not admin' do -# # get api('/geo_nodes', user) -# # -# # expect(response).to have_gitlab_http_status(403) -# # end -# end -# end - module QA feature 'get Geo Node status', :core do context 'with regular account over http' do - scenario 'xxxx' do - Runtime::API.get(:gitlab, '/geo_nodes') - # get "/api/v1/items/1",:formate =>:json - expect(1).to eq 2 + scenario 'get geo node status' do + response = Runtime::API.get(:gitlab, '/geo_nodes') + expect(response.status).to eq 200 end - - # scenario 'user pushes code to the repository' do - # Runtime::Browser.visit(:gitlab, Page::Main::Login) - # Page::Main::Login.act { sign_in_using_credentials } - # - # Factory::Resource::Project.fabricate! do |scenario| - # scenario.name = 'project_with_code' - # scenario.description = 'project with repository' - # end - # - # Factory::Repository::Push.fabricate! do |scenario| - # scenario.file_name = 'README.md' - # scenario.file_content = '# This is test project' - # scenario.commit_message = 'Add README.md' - # end - # - # Page::Project::Show.act do - # wait_for_push - # refresh - # end - # - # expect(page).to have_content('README.md') - # expect(page).to have_content('This is test project') - # end end end end -- GitLab From a8c3d81a51d64b08447e7d3b545801b342c95307 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Sat, 23 Dec 2017 10:16:12 +0100 Subject: [PATCH 03/16] allow the Geo scenario to accept a specific spec file to be run --- qa/qa/ee/scenario/test/geo.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/qa/qa/ee/scenario/test/geo.rb b/qa/qa/ee/scenario/test/geo.rb index 49f0a742733316..1bdf9048c99044 100644 --- a/qa/qa/ee/scenario/test/geo.rb +++ b/qa/qa/ee/scenario/test/geo.rb @@ -27,6 +27,7 @@ def perform(options, *files) Specs::Runner.perform do |specs| specs.tty = true specs.tags = %w[geo] + specs.files = files.any? ? files : 'qa/specs/features' end end -- GitLab From 64a0392b10412bfdbaa2dc18709cb701f0aab3b7 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Sat, 23 Dec 2017 10:17:02 +0100 Subject: [PATCH 04/16] Add GeoInstance scenario for easier targeting of local GDK instances --- qa/qa/ee.rb | 1 + qa/qa/ee/scenario/test/geo_instance.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 qa/qa/ee/scenario/test/geo_instance.rb diff --git a/qa/qa/ee.rb b/qa/qa/ee.rb index 829e58ee40fdc7..1e63e6a6213695 100644 --- a/qa/qa/ee.rb +++ b/qa/qa/ee.rb @@ -41,6 +41,7 @@ module Geo module Scenario module Test autoload :Geo, 'qa/ee/scenario/test/geo' + autoload :GeoInstance, 'qa/ee/scenario/test/geo_instance' end end end diff --git a/qa/qa/ee/scenario/test/geo_instance.rb b/qa/qa/ee/scenario/test/geo_instance.rb new file mode 100644 index 00000000000000..c22a9cf3e5022b --- /dev/null +++ b/qa/qa/ee/scenario/test/geo_instance.rb @@ -0,0 +1,19 @@ +module QA + module EE + module Scenario + module Test + class GeoInstance < Geo + attribute :geo_primary_address, '--primary-address PRIMARY' + attribute :geo_primary_name, '--primary-name PRIMARY_NAME' + attribute :geo_secondary_address, '--secondary-address SECONDARY' + attribute :geo_secondary_name, '--secondary-name SECONDARY_NAME' + + def perform(options, *files) + options[:geo_skip_setup?] = true + super(options, *files) + end + end + end + end + end +end -- GitLab From 4487f822350ae49ba256603e48d7a986514ddb94 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Sat, 23 Dec 2017 10:17:30 +0100 Subject: [PATCH 05/16] use Faraday gem for driving API calls --- qa/qa/specs/features/ee/api/geo_status_node_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb index bbd1518ebfdaa5..929b3e358c5cab 100644 --- a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb @@ -2,7 +2,7 @@ require 'faraday' module QA - feature 'get Geo Node status', :core do + feature 'get Geo Node status', :geo do context 'with regular account over http' do scenario 'get geo node status' do -- GitLab From 9e30f0c6ddd4a398e4b02269a8c0fb17e011b82d Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Tue, 30 Jan 2018 16:28:22 +0100 Subject: [PATCH 06/16] add QA specs for the Geo Node API --- doc/api/geo_nodes.md | 76 ++++- ee/lib/api/geo_nodes.rb | 2 +- qa/qa/specs/features/ee/api/geo_nodes_spec.rb | 313 ++++++++++++++++++ .../features/ee/api/geo_status_node_spec.rb | 14 - 4 files changed, 388 insertions(+), 17 deletions(-) create mode 100644 qa/qa/specs/features/ee/api/geo_nodes_spec.rb delete mode 100644 qa/qa/specs/features/ee/api/geo_status_node_spec.rb diff --git a/doc/api/geo_nodes.md b/doc/api/geo_nodes.md index f5e82e654621af..63b08976267fe9 100644 --- a/doc/api/geo_nodes.md +++ b/doc/api/geo_nodes.md @@ -69,6 +69,8 @@ Example response: Updates an existing Geo secondary node. The primary node cannot be edited. +_This can only be run against a primary Geo node._ + ``` PUT /geo_nodes/:id ``` @@ -112,6 +114,8 @@ DELETE /geo_nodes/:id To repair the OAuth authentication of a Geo node. +_This can only be run against a primary Geo node._ + ``` POST /geo_nodes/:id/repair ``` @@ -131,7 +135,7 @@ Example response: } ``` -## Retrieve status about all secondary Geo nodes +## Retrieve status about all Geo nodes ``` GET /geo_nodes/status @@ -145,6 +149,62 @@ Example response: ```json [ + { + "geo_node_id": 1, + "healthy": true, + "health": "Healthy", + "health_status": "Healthy", + "missing_oauth_application": false, + "attachments_count": 1, + "attachments_synced_count": nil, + "attachments_failed_count": nil, + "attachments_synced_missing_on_primary_count": 0, + "attachments_synced_in_percentage": "0.00%", + "db_replication_lag_seconds": nil, + "lfs_objects_count": 0, + "lfs_objects_synced_count": nil, + "lfs_objects_failed_count": nil, + "lfs_objects_synced_missing_on_primary_count": 0, + "lfs_objects_synced_in_percentage": "0.00%", + "job_artifacts_count": 2, + "job_artifacts_synced_count": nil, + "job_artifacts_failed_count": nil, + "job_artifacts_synced_missing_on_primary_count": 0, + "job_artifacts_synced_in_percentage": "0.00%", + "repositories_count": 41, + "repositories_failed_count": nil, + "repositories_synced_count": nil, + "repositories_synced_in_percentage": "0.00%", + "wikis_count": 41, + "wikis_failed_count": nil, + "wikis_synced_count": nil, + "wikis_synced_in_percentage": "0.00%", + "replication_slots_count": 1, + "replication_slots_used_count": 1, + "replication_slots_used_in_percentage": "100.00%", + "replication_slots_max_retained_wal_bytes": 0, + "repositories_checksummed_count": 20, + "repositories_checksum_failed_count": 5, + "repositories_checksummed_in_percentage": "48.78%", + "wikis_checksummed_count": 10, + "wikis_checksum_failed_count": 3, + "wikis_checksummed_in_percentage": "24.39%", + "repositories_verified_count": 20, + "repositories_verification_failed_count": 5, + "repositories_verified_in_percentage": "48.78%", + "repositories_checksum_mismatch_count": 3, + "wikis_verified_count": 10, + "wikis_verification_failed_count": 3, + "wikis_verified_in_percentage": "24.39%", + "wikis_checksum_mismatch_count": 1, + "last_event_id": 23, + "last_event_timestamp": 1509681166, + "cursor_last_event_id": nil, + "cursor_last_event_timestamp": 0, + "last_successful_status_check_timestamp": 1510125024, + "version": "10.3.0", + "revision": "33d33a096a", + }, { "geo_node_id": 2, "healthy": true, @@ -175,6 +235,10 @@ Example response: "wikis_failed_count": 0, "wikis_synced_count": 41, "wikis_synced_in_percentage": "100.00%", + "replication_slots_count": nil, + "replication_slots_used_count": nil, + "replication_slots_used_in_percentage": "0.00%", + "replication_slots_max_retained_wal_bytes": nil, "repositories_checksummed_count": 20, "repositories_checksum_failed_count": 5, "repositories_checksummed_in_percentage": "48.78%", @@ -200,7 +264,7 @@ Example response: ] ``` -## Retrieve status about a specific secondary Geo node +## Retrieve status about a specific Geo node ``` GET /geo_nodes/:id/status @@ -239,6 +303,14 @@ Example response: "repositories_failed_count": 1, "repositories_synced_count": 40, "repositories_synced_in_percentage": "97.56%", + "wikis_count": 41, + "wikis_failed_count": 0, + "wikis_synced_count": 41, + "wikis_synced_in_percentage": "100.00%", + "replication_slots_count": nil, + "replication_slots_used_count": nil, + "replication_slots_used_in_percentage": "0.00%", + "replication_slots_max_retained_wal_bytes": nil, "last_event_id": 23, "last_event_timestamp": 1509681166, "cursor_last_event_id": 23, diff --git a/ee/lib/api/geo_nodes.rb b/ee/lib/api/geo_nodes.rb index 8875d02e772101..4989c313f14c7b 100644 --- a/ee/lib/api/geo_nodes.rb +++ b/ee/lib/api/geo_nodes.rb @@ -48,7 +48,7 @@ class GeoNodes < Grape::API get '/current/failures' do geo_node = Gitlab::Geo.current_node - not_found('Geo node not found') unless geo_node + not_found!('Geo node not found') unless geo_node finder = ::Geo::ProjectRegistryFinder.new(current_node: geo_node) project_registries = paginate(finder.find_failed_project_registries(params[:type])) diff --git a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb new file mode 100644 index 00000000000000..f893b4b1ed4a75 --- /dev/null +++ b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb @@ -0,0 +1,313 @@ +module QA + feature 'Geo Nodes API on primary node', :geo do + before(:context) do + @api_client = Runtime::API::Client.new(:geo_primary) + end + + let(:request) { Runtime::API::Request.new(@api_client, '/geo_nodes') } + let(:nodes) do + get request.url + json_body + end + let(:primary_node) { nodes.detect {|node| node[:primary] == true} } + let(:secondary_node) { nodes.detect {|node| node[:primary] == false} } + + context 'Retrieve configuration about Geo nodes' do + scenario 'GET /geo_nodes' do + get request.url + + expect_status(200) + expect(json_body.size).to be >= 2 + expect_json('?', primary: true, current: true) + expect_json_types('*', primary: :boolean, current: :boolean, + files_max_capacity: :integer, repos_max_capacity: :integer, + clone_protocol: :string, _links: :object) + end + + scenario 'GET /geo_nodes/:id' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}") + + get request.url + + expect_status(200) + expect(json_body).to eq primary_node + end + end + + context 'Edit a Geo node' do + scenario 'PUT /geo_nodes/:id for primary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}") + + put request.url, { params: { files_max_capacity: 1000 } } + + expect_status(403) + end + + scenario 'PUT /geo_nodes/:id for secondary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}") + new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 } + + put request.url, new_attributes + + expect_status(200) + expect_json(new_attributes) + + # restore the original values + new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 } + put request.url, { enabled: secondary_node[:enabled], + files_max_capacity: secondary_node[:files_max_capacity], + repos_max_capacity: secondary_node[:repos_max_capacity], + } + + expect_status(200) + end + + scenario 'PUT /geo_nodes/:id for an invalid node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000") + + put request.url, { params: { files_max_capacity: 1000 } } + + expect_status(404) + end + end + + context 'Repair a Geo node' do + scenario 'POST /geo_nodes/:id/repair for primary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/repair") + + post request.url + + expect_status(200) + expect_json(geo_node_id: primary_node[:id], healthy: true) + end + + scenario 'POST /geo_nodes/:id/repair for secondary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/repair") + + post request.url + + expect_status(200) + expect_json(geo_node_id: secondary_node[:id], healthy: true) + end + + scenario 'POST /geo_nodes/:id/repair for an invalid node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/repair") + + post request.url + + expect_status(404) + end + end + + context 'Retrieve status about all Geo nodes' do + scenario 'GET /geo_nodes/status' do + request = Runtime::API::Request.new(@api_client, '/geo_nodes/status') + + get request.url + + expect_status(200) + expect(json_body.size).to be >= 2 + expect_json('*', healthy: true) + + # only need to check that some of the key values are there + expect_json_types('*', health: :string, + attachments_count: :integer, + db_replication_lag_seconds: :integer_or_null, + lfs_objects_count: :integer, + job_artifacts_count: :integer, + repositories_count: :integer, + wikis_count: :integer, + replication_slots_count: :integer_or_null, + version: :string) + end + end + + context 'Retrieve status about a specific Geo node' do + scenario 'GET /geo_nodes/:id/status of primary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/status") + + get request.url + + expect_status(200) + expect_json(geo_node_id: primary_node[:id], healthy: true) + end + + scenario 'GET /geo_nodes/:id/status of secondary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/status") + + get request.url + + expect_status(200) + expect_json(geo_node_id: secondary_node[:id], healthy: true) + end + + scenario 'GET /geo_nodes/:id/status of an invalid node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/status") + + get request.url + + expect_status(404) + end + end + + context 'Retrieve project sync failures ocurred on the current node' do + scenario 'GET /geo_nodes/current/failures' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/current/failures") + + get request.url + + expect_status(200) + expect(json_body).to be_an Array + end + end + end + + feature 'Geo Nodes API on secondary node', :geo do + before(:context) do + @api_client = Runtime::API::Client.new(:geo_secondary) + end + + let(:request) { Runtime::API::Request.new(@api_client, '/geo_nodes') } + let(:nodes) do + get request.url + json_body + end + let(:primary_node) { nodes.detect {|node| node[:primary] == true} } + let(:secondary_node) { nodes.detect {|node| node[:primary] == false} } + + context 'Retrieve configuration about Geo nodes' do + scenario 'GET /geo_nodes' do + get request.url + + expect_status(200) + expect(json_body.size).to be >= 2 + expect_json('?', primary: true, current: false) + expect_json_types('*', primary: :boolean, current: :boolean, + files_max_capacity: :integer, repos_max_capacity: :integer, + clone_protocol: :string, _links: :object) + end + + scenario 'GET /geo_nodes/:id' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{nodes.first[:id]}") + + get request.url + + expect_status(200) + expect(json_body).to eq nodes.first + end + end + + context 'Edit a Geo node' do + scenario 'PUT /geo_nodes/:id for primary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}") + + put request.url, { params: { files_max_capacity: 1000 } } + + expect_status(403) + end + + scenario 'PUT /geo_nodes/:id for secondary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}") + put request.url, { params: { files_max_capacity: 1000 } } + + expect_status(403) + end + + scenario 'PUT /geo_nodes/:id for an invalid node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000") + + put request.url, { params: { files_max_capacity: 1000 } } + + expect_status(403) + end + end + + context 'Repair a Geo node' do + scenario 'POST /geo_nodes/:id/repair for primary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/repair") + + post request.url + + expect_status(403) + end + + scenario 'POST /geo_nodes/:id/repair for secondary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/repair") + + post request.url + + expect_status(403) + end + + scenario 'POST /geo_nodes/:id/repair for an invalid node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/repair") + + post request.url + + expect_status(403) + end + end + + context 'Retrieve status about all Geo nodes' do + scenario 'GET /geo_nodes/status' do + request = Runtime::API::Request.new(@api_client, '/geo_nodes/status') + + get request.url + + expect_status(200) + expect(json_body.size).to be >= 2 + expect_json('*', healthy: true) + + # only need to check that some of the key values are there + expect_json_types('*', health: :string, + attachments_count: :integer, + db_replication_lag_seconds: :integer_or_null, + lfs_objects_count: :integer, + job_artifacts_count: :integer, + repositories_count: :integer, + wikis_count: :integer, + replication_slots_count: :integer_or_null, + version: :string) + end + end + + context 'Retrieve status about a specific Geo node' do + scenario 'GET /geo_nodes/:id/status of primary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/status") + + get request.url + + expect_status(200) + expect_json(geo_node_id: primary_node[:id], healthy: true) + end + + scenario 'GET /geo_nodes/:id/status of secondary node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/status") + + get request.url + + expect_status(200) + expect_json(geo_node_id: secondary_node[:id], healthy: true) + end + + scenario 'GET /geo_nodes/:id/status of an invalid node' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/status") + + get request.url + + expect_status(404) + end + end + + context 'Retrieve project sync failures ocurred on the current node' do + scenario 'GET /geo_nodes/current/failures' do + request = Runtime::API::Request.new(@api_client, "/geo_nodes/current/failures") + + get request.url + + expect_status(200) + expect(json_body).to be_an Array + end + end + end +end diff --git a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb b/qa/qa/specs/features/ee/api/geo_status_node_spec.rb deleted file mode 100644 index 929b3e358c5cab..00000000000000 --- a/qa/qa/specs/features/ee/api/geo_status_node_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'pry-byebug' -require 'faraday' - -module QA - feature 'get Geo Node status', :geo do - context 'with regular account over http' do - - scenario 'get geo node status' do - response = Runtime::API.get(:gitlab, '/geo_nodes') - expect(response.status).to eq 200 - end - end - end -end -- GitLab From c74cbf43f11cacf6c187e8da59b2836f73a03040 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Tue, 30 Jan 2018 16:57:02 +0100 Subject: [PATCH 07/16] remove unnecessary admin_user file --- qa/qa/runtime/admin_user.rb | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 qa/qa/runtime/admin_user.rb diff --git a/qa/qa/runtime/admin_user.rb b/qa/qa/runtime/admin_user.rb deleted file mode 100644 index a54d58833f3f98..00000000000000 --- a/qa/qa/runtime/admin_user.rb +++ /dev/null @@ -1,15 +0,0 @@ -module QA - module Runtime - module AdminUser - extend self - - def name - ENV['GITLAB_USERNAME'] || 'myadmin' - end - - def password - ENV['GITLAB_PASSWORD'] || 'myadmin!!' - end - end - end -end -- GitLab From 2d47ab02906c4532b60ac627b90dd056162f6a91 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Tue, 30 Jan 2018 17:38:09 +0100 Subject: [PATCH 08/16] static_analysis fixes --- qa/qa/specs/features/ee/api/geo_nodes_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb index f893b4b1ed4a75..027af7ad8fe66a 100644 --- a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb @@ -53,11 +53,9 @@ module QA expect_json(new_attributes) # restore the original values - new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 } put request.url, { enabled: secondary_node[:enabled], files_max_capacity: secondary_node[:files_max_capacity], - repos_max_capacity: secondary_node[:repos_max_capacity], - } + repos_max_capacity: secondary_node[:repos_max_capacity] } expect_status(200) end -- GitLab From 841ed2f16a79b44595308031fae1dc32d191cf2c Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Wed, 31 Jan 2018 10:18:30 +0100 Subject: [PATCH 09/16] add changelog --- changelogs/unreleased-ee/131-qa-test-geo-status-api.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased-ee/131-qa-test-geo-status-api.yml diff --git a/changelogs/unreleased-ee/131-qa-test-geo-status-api.yml b/changelogs/unreleased-ee/131-qa-test-geo-status-api.yml new file mode 100644 index 00000000000000..bc8b0636f7d47e --- /dev/null +++ b/changelogs/unreleased-ee/131-qa-test-geo-status-api.yml @@ -0,0 +1,5 @@ +--- +title: Add QA test scenarios and fix/enhance API documentation for Geo Nodes +merge_request: 3865 +author: +type: fixed -- GitLab From cd327fbd27d1d752ee8a2c3a40cc7094f5fa93b1 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Wed, 31 Jan 2018 10:35:34 +0100 Subject: [PATCH 10/16] remove unnecessary GeoInstance --- qa/qa/ee.rb | 1 - qa/qa/ee/scenario/test/geo_instance.rb | 19 ------------------- 2 files changed, 20 deletions(-) delete mode 100644 qa/qa/ee/scenario/test/geo_instance.rb diff --git a/qa/qa/ee.rb b/qa/qa/ee.rb index 1e63e6a6213695..829e58ee40fdc7 100644 --- a/qa/qa/ee.rb +++ b/qa/qa/ee.rb @@ -41,7 +41,6 @@ module Geo module Scenario module Test autoload :Geo, 'qa/ee/scenario/test/geo' - autoload :GeoInstance, 'qa/ee/scenario/test/geo_instance' end end end diff --git a/qa/qa/ee/scenario/test/geo_instance.rb b/qa/qa/ee/scenario/test/geo_instance.rb deleted file mode 100644 index c22a9cf3e5022b..00000000000000 --- a/qa/qa/ee/scenario/test/geo_instance.rb +++ /dev/null @@ -1,19 +0,0 @@ -module QA - module EE - module Scenario - module Test - class GeoInstance < Geo - attribute :geo_primary_address, '--primary-address PRIMARY' - attribute :geo_primary_name, '--primary-name PRIMARY_NAME' - attribute :geo_secondary_address, '--secondary-address SECONDARY' - attribute :geo_secondary_name, '--secondary-name SECONDARY_NAME' - - def perform(options, *files) - options[:geo_skip_setup?] = true - super(options, *files) - end - end - end - end - end -end -- GitLab From 6d7da5f006a95baad143302feb2a352c0bb1e3aa Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Tue, 13 Feb 2018 16:07:37 +0100 Subject: [PATCH 11/16] significant refactor with shared_examples --- qa/qa/specs/features/ee/api/geo_nodes_spec.rb | 325 +++++++----------- 1 file changed, 118 insertions(+), 207 deletions(-) diff --git a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb index 027af7ad8fe66a..1d485c98e4299d 100644 --- a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb @@ -1,107 +1,28 @@ module QA - feature 'Geo Nodes API on primary node', :geo do - before(:context) do - @api_client = Runtime::API::Client.new(:geo_primary) - end - - let(:request) { Runtime::API::Request.new(@api_client, '/geo_nodes') } - let(:nodes) do - get request.url - json_body - end - let(:primary_node) { nodes.detect {|node| node[:primary] == true} } - let(:secondary_node) { nodes.detect {|node| node[:primary] == false} } - - context 'Retrieve configuration about Geo nodes' do + describe 'Geo Nodes API' do + shared_examples 'retrieving configuration about Geo nodes' do scenario 'GET /geo_nodes' do - get request.url + get api_endpoint('/geo_nodes') expect_status(200) expect(json_body.size).to be >= 2 - expect_json('?', primary: true, current: true) + expect_json('?', primary: true) expect_json_types('*', primary: :boolean, current: :boolean, files_max_capacity: :integer, repos_max_capacity: :integer, clone_protocol: :string, _links: :object) end scenario 'GET /geo_nodes/:id' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}") - - get request.url + get api_endpoint("/geo_nodes/#{geo_node[:id]}") expect_status(200) - expect(json_body).to eq primary_node + expect(json_body).to eq geo_node end end - context 'Edit a Geo node' do - scenario 'PUT /geo_nodes/:id for primary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}") - - put request.url, { params: { files_max_capacity: 1000 } } - - expect_status(403) - end - - scenario 'PUT /geo_nodes/:id for secondary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}") - new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 } - - put request.url, new_attributes - - expect_status(200) - expect_json(new_attributes) - - # restore the original values - put request.url, { enabled: secondary_node[:enabled], - files_max_capacity: secondary_node[:files_max_capacity], - repos_max_capacity: secondary_node[:repos_max_capacity] } - - expect_status(200) - end - - scenario 'PUT /geo_nodes/:id for an invalid node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000") - - put request.url, { params: { files_max_capacity: 1000 } } - - expect_status(404) - end - end - - context 'Repair a Geo node' do - scenario 'POST /geo_nodes/:id/repair for primary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/repair") - - post request.url - - expect_status(200) - expect_json(geo_node_id: primary_node[:id], healthy: true) - end - - scenario 'POST /geo_nodes/:id/repair for secondary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/repair") - - post request.url - - expect_status(200) - expect_json(geo_node_id: secondary_node[:id], healthy: true) - end - - scenario 'POST /geo_nodes/:id/repair for an invalid node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/repair") - - post request.url - - expect_status(404) - end - end - - context 'Retrieve status about all Geo nodes' do + shared_examples 'retrieving status about all Geo nodes' do scenario 'GET /geo_nodes/status' do - request = Runtime::API::Request.new(@api_client, '/geo_nodes/status') - - get request.url + get api_endpoint('/geo_nodes/status') expect_status(200) expect(json_body.size).to be >= 2 @@ -116,196 +37,186 @@ module QA repositories_count: :integer, wikis_count: :integer, replication_slots_count: :integer_or_null, - version: :string) + version: :string_or_null) end end - context 'Retrieve status about a specific Geo node' do + shared_examples 'retrieving status about a specific Geo node' do scenario 'GET /geo_nodes/:id/status of primary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/status") - - get request.url + get api_endpoint("/geo_nodes/#{@primary_node[:id]}/status") expect_status(200) - expect_json(geo_node_id: primary_node[:id], healthy: true) + expect_json(geo_node_id: @primary_node[:id], healthy: true) end scenario 'GET /geo_nodes/:id/status of secondary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/status") - - get request.url + get api_endpoint("/geo_nodes/#{@secondary_node[:id]}/status") expect_status(200) - expect_json(geo_node_id: secondary_node[:id], healthy: true) + expect_json(geo_node_id: @secondary_node[:id], healthy: true) end scenario 'GET /geo_nodes/:id/status of an invalid node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/status") - - get request.url + get api_endpoint("/geo_nodes/1000/status") expect_status(404) end end - context 'Retrieve project sync failures ocurred on the current node' do + shared_examples 'retrieving project sync failures ocurred on the current node' do scenario 'GET /geo_nodes/current/failures' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/current/failures") - - get request.url + get api_endpoint("/geo_nodes/current/failures") expect_status(200) expect(json_body).to be_an Array end end - end - feature 'Geo Nodes API on secondary node', :geo do - before(:context) do - @api_client = Runtime::API::Client.new(:geo_secondary) - end + feature 'Geo Nodes API on primary node', :geo do + before(:context) do + fetch_nodes(:geo_primary) + end - let(:request) { Runtime::API::Request.new(@api_client, '/geo_nodes') } - let(:nodes) do - get request.url - json_body - end - let(:primary_node) { nodes.detect {|node| node[:primary] == true} } - let(:secondary_node) { nodes.detect {|node| node[:primary] == false} } + include_examples 'retrieving configuration about Geo nodes' do + let(:geo_node) { @primary_node } + end - context 'Retrieve configuration about Geo nodes' do - scenario 'GET /geo_nodes' do - get request.url + include_examples 'retrieving status about all Geo nodes' + include_examples 'retrieving status about a specific Geo node' + include_examples 'retrieving project sync failures ocurred on the current node' - expect_status(200) - expect(json_body.size).to be >= 2 - expect_json('?', primary: true, current: false) - expect_json_types('*', primary: :boolean, current: :boolean, - files_max_capacity: :integer, repos_max_capacity: :integer, - clone_protocol: :string, _links: :object) - end + feature 'editing a Geo node' do + scenario 'PUT /geo_nodes/:id for primary node' do + put api_endpoint("/geo_nodes/#{@primary_node[:id]}"), + { params: { files_max_capacity: 1000 } } - scenario 'GET /geo_nodes/:id' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{nodes.first[:id]}") + expect_status(403) + end - get request.url + scenario 'PUT /geo_nodes/:id for secondary node' do + endpoint = api_endpoint("/geo_nodes/#{@secondary_node[:id]}") + new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 } - expect_status(200) - expect(json_body).to eq nodes.first - end - end + put endpoint, new_attributes - context 'Edit a Geo node' do - scenario 'PUT /geo_nodes/:id for primary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}") + expect_status(200) + expect_json(new_attributes) - put request.url, { params: { files_max_capacity: 1000 } } + # restore the original values + put endpoint, { enabled: @secondary_node[:enabled], + files_max_capacity: @secondary_node[:files_max_capacity], + repos_max_capacity: @secondary_node[:repos_max_capacity] } - expect_status(403) - end + expect_status(200) + end - scenario 'PUT /geo_nodes/:id for secondary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}") - put request.url, { params: { files_max_capacity: 1000 } } + scenario 'PUT /geo_nodes/:id for an invalid node' do + put api_endpoint("/geo_nodes/1000"), + { params: { files_max_capacity: 1000 } } - expect_status(403) + expect_status(404) + end end - scenario 'PUT /geo_nodes/:id for an invalid node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000") + feature 'repairing a Geo node' do + scenario 'POST /geo_nodes/:id/repair for primary node' do + post api_endpoint("/geo_nodes/#{@primary_node[:id]}/repair") - put request.url, { params: { files_max_capacity: 1000 } } + expect_status(200) + expect_json(geo_node_id: @primary_node[:id], healthy: true) + end - expect_status(403) - end - end + scenario 'POST /geo_nodes/:id/repair for secondary node' do + post api_endpoint("/geo_nodes/#{@secondary_node[:id]}/repair") - context 'Repair a Geo node' do - scenario 'POST /geo_nodes/:id/repair for primary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/repair") + expect_status(200) + expect_json(geo_node_id: @secondary_node[:id], healthy: true) + end - post request.url + scenario 'POST /geo_nodes/:id/repair for an invalid node' do + post api_endpoint("/geo_nodes/1000/repair") - expect_status(403) + expect_status(404) + end end + end - scenario 'POST /geo_nodes/:id/repair for secondary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/repair") - - post request.url + feature 'Geo Nodes API on secondary node', :geo do + before(:context) do + fetch_nodes(:geo_secondary) + end - expect_status(403) + include_examples 'retrieving configuration about Geo nodes' do + let(:geo_node) { @nodes.first } end - scenario 'POST /geo_nodes/:id/repair for an invalid node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/repair") + include_examples 'retrieving status about all Geo nodes' + include_examples 'retrieving status about a specific Geo node' + include_examples 'retrieving project sync failures ocurred on the current node' - post request.url + scenario 'GET /geo_nodes is not current' do + get api_endpoint('/geo_nodes') - expect_status(403) + expect_status(200) + expect_json('?', current: false) end - end - - context 'Retrieve status about all Geo nodes' do - scenario 'GET /geo_nodes/status' do - request = Runtime::API::Request.new(@api_client, '/geo_nodes/status') - get request.url + feature 'editing a Geo node' do + scenario 'PUT /geo_nodes/:id for primary node' do + put api_endpoint("/geo_nodes/#{@primary_node[:id]}"), + { params: { files_max_capacity: 1000 } } - expect_status(200) - expect(json_body.size).to be >= 2 - expect_json('*', healthy: true) + expect_status(403) + end - # only need to check that some of the key values are there - expect_json_types('*', health: :string, - attachments_count: :integer, - db_replication_lag_seconds: :integer_or_null, - lfs_objects_count: :integer, - job_artifacts_count: :integer, - repositories_count: :integer, - wikis_count: :integer, - replication_slots_count: :integer_or_null, - version: :string) - end - end + scenario 'PUT /geo_nodes/:id for secondary node' do + put api_endpoint("/geo_nodes/#{@secondary_node[:id]}"), + { params: { files_max_capacity: 1000 } } - context 'Retrieve status about a specific Geo node' do - scenario 'GET /geo_nodes/:id/status of primary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{primary_node[:id]}/status") + expect_status(403) + end - get request.url + scenario 'PUT /geo_nodes/:id for an invalid node' do + put api_endpoint('/geo_nodes/1000'), + { params: { files_max_capacity: 1000 } } - expect_status(200) - expect_json(geo_node_id: primary_node[:id], healthy: true) + expect_status(403) + end end - scenario 'GET /geo_nodes/:id/status of secondary node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/#{secondary_node[:id]}/status") + feature 'repairing a Geo node' do + scenario 'POST /geo_nodes/:id/repair for primary node' do + post api_endpoint("/geo_nodes/#{@primary_node[:id]}/repair") - get request.url + expect_status(403) + end - expect_status(200) - expect_json(geo_node_id: secondary_node[:id], healthy: true) - end + scenario 'POST /geo_nodes/:id/repair for secondary node' do + post api_endpoint("/geo_nodes/#{@secondary_node[:id]}/repair") - scenario 'GET /geo_nodes/:id/status of an invalid node' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/1000/status") + expect_status(403) + end - get request.url + scenario 'POST /geo_nodes/:id/repair for an invalid node' do + post api_endpoint('/geo_nodes/1000/repair') - expect_status(404) + expect_status(403) + end end end - context 'Retrieve project sync failures ocurred on the current node' do - scenario 'GET /geo_nodes/current/failures' do - request = Runtime::API::Request.new(@api_client, "/geo_nodes/current/failures") + def api_endpoint(endpoint) + QA::Runtime::API::Request.new(@api_client, endpoint).url + end - get request.url + def fetch_nodes(node_type) + @api_client = Runtime::API::Client.new(node_type) - expect_status(200) - expect(json_body).to be_an Array - end + get api_endpoint('/geo_nodes') + + @nodes = json_body + @primary_node = @nodes.detect { |node| node[:primary] == true } + @secondary_node = @nodes.detect { |node| node[:primary] == false } end end end -- GitLab From ea389d0a8057bc4affdee298fdd6a2e2cf8f8c2f Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Mon, 26 Mar 2018 09:20:13 +0200 Subject: [PATCH 12/16] update the changelog and put in correct ee changelog folder --- changelogs/unreleased-ee/131-qa-test-geo-status-api.yml | 5 ----- ee/changelogs/unreleased/131-qa-test-geo-status-api.yml | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 changelogs/unreleased-ee/131-qa-test-geo-status-api.yml create mode 100644 ee/changelogs/unreleased/131-qa-test-geo-status-api.yml diff --git a/changelogs/unreleased-ee/131-qa-test-geo-status-api.yml b/changelogs/unreleased-ee/131-qa-test-geo-status-api.yml deleted file mode 100644 index bc8b0636f7d47e..00000000000000 --- a/changelogs/unreleased-ee/131-qa-test-geo-status-api.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Add QA test scenarios and fix/enhance API documentation for Geo Nodes -merge_request: 3865 -author: -type: fixed diff --git a/ee/changelogs/unreleased/131-qa-test-geo-status-api.yml b/ee/changelogs/unreleased/131-qa-test-geo-status-api.yml new file mode 100644 index 00000000000000..94e5c16298b835 --- /dev/null +++ b/ee/changelogs/unreleased/131-qa-test-geo-status-api.yml @@ -0,0 +1,5 @@ +--- +title: Add missing fields to the API documentation for the status of Geo Nodes +merge_request: 3865 +author: +type: fixed -- GitLab From 9c88a87005137b703c07c3090b4e4ffb7a14e00a Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Thu, 29 Mar 2018 10:43:04 +0200 Subject: [PATCH 13/16] use new naming convention for qa `perform` --- qa/qa/ee/scenario/test/geo.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qa/qa/ee/scenario/test/geo.rb b/qa/qa/ee/scenario/test/geo.rb index 1bdf9048c99044..5fb6ae5e6fda53 100644 --- a/qa/qa/ee/scenario/test/geo.rb +++ b/qa/qa/ee/scenario/test/geo.rb @@ -11,7 +11,7 @@ class Geo < QA::Scenario::Template attribute :geo_secondary_name, '--secondary-name SECONDARY_NAME' attribute :geo_skip_setup?, '--without-setup' - def perform(options, *files) + def perform(options, *rspec_options) unless options[:geo_skip_setup?] Geo::Primary.act do add_license @@ -27,7 +27,7 @@ def perform(options, *files) Specs::Runner.perform do |specs| specs.tty = true specs.tags = %w[geo] - specs.files = files.any? ? files : 'qa/specs/features' + specs.options = rspec_options.any? ? rspec_options : 'qa/specs/features' end end -- GitLab From cd3164906a59a00d5e0d4d6cea142c5a854346dc Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Mon, 2 Apr 2018 18:43:22 +0200 Subject: [PATCH 14/16] create an access token once and use for both primary and secondary --- qa/qa/runtime/api.rb | 3 ++- qa/qa/specs/features/ee/api/geo_nodes_spec.rb | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/qa/qa/runtime/api.rb b/qa/qa/runtime/api.rb index e2a096b971d97b..3f53b6b7153d28 100644 --- a/qa/qa/runtime/api.rb +++ b/qa/qa/runtime/api.rb @@ -6,8 +6,9 @@ module API class Client attr_reader :address - def initialize(address = :gitlab) + def initialize(address = :gitlab, personal_access_token = nil) @address = address + @personal_access_token = personal_access_token end def personal_access_token diff --git a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb index 1d485c98e4299d..763e6d21f7b741 100644 --- a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb @@ -1,5 +1,9 @@ module QA describe 'Geo Nodes API' do + before(:all) do + get_personal_access_token + end + shared_examples 'retrieving configuration about Geo nodes' do scenario 'GET /geo_nodes' do get api_endpoint('/geo_nodes') @@ -210,7 +214,7 @@ def api_endpoint(endpoint) end def fetch_nodes(node_type) - @api_client = Runtime::API::Client.new(node_type) + @api_client = Runtime::API::Client.new(node_type, @personal_access_token) get api_endpoint('/geo_nodes') @@ -218,5 +222,12 @@ def fetch_nodes(node_type) @primary_node = @nodes.detect { |node| node[:primary] == true } @secondary_node = @nodes.detect { |node| node[:primary] == false } end + + # go to the primary and create a personal_access_token, which will be used + # for accessing both the primary and secondary + def get_personal_access_token + api_client = Runtime::API::Client.new(:geo_primary) + @personal_access_token = api_client.personal_access_token + end end end -- GitLab From b5672b4ddc1ba3d2753570913525737b60a67e19 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Wed, 9 May 2018 18:28:47 -0500 Subject: [PATCH 15/16] remove check on :healthy attribute --- qa/qa/specs/features/ee/api/geo_nodes_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb index 763e6d21f7b741..af8812472fdbea 100644 --- a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb @@ -30,7 +30,6 @@ module QA expect_status(200) expect(json_body.size).to be >= 2 - expect_json('*', healthy: true) # only need to check that some of the key values are there expect_json_types('*', health: :string, @@ -50,14 +49,14 @@ module QA get api_endpoint("/geo_nodes/#{@primary_node[:id]}/status") expect_status(200) - expect_json(geo_node_id: @primary_node[:id], healthy: true) + expect_json(geo_node_id: @primary_node[:id]) end scenario 'GET /geo_nodes/:id/status of secondary node' do get api_endpoint("/geo_nodes/#{@secondary_node[:id]}/status") expect_status(200) - expect_json(geo_node_id: @secondary_node[:id], healthy: true) + expect_json(geo_node_id: @secondary_node[:id]) end scenario 'GET /geo_nodes/:id/status of an invalid node' do @@ -127,14 +126,14 @@ module QA post api_endpoint("/geo_nodes/#{@primary_node[:id]}/repair") expect_status(200) - expect_json(geo_node_id: @primary_node[:id], healthy: true) + expect_json(geo_node_id: @primary_node[:id]) end scenario 'POST /geo_nodes/:id/repair for secondary node' do post api_endpoint("/geo_nodes/#{@secondary_node[:id]}/repair") expect_status(200) - expect_json(geo_node_id: @secondary_node[:id], healthy: true) + expect_json(geo_node_id: @secondary_node[:id]) end scenario 'POST /geo_nodes/:id/repair for an invalid node' do -- GitLab From f78e8f4e58e36f6015dbe9233d6f5fd2e3c258c7 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Thu, 10 May 2018 13:22:55 -0500 Subject: [PATCH 16/16] can't retreive sync failures on primary yet --- qa/qa/specs/features/ee/api/geo_nodes_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb index af8812472fdbea..8531761667c62f 100644 --- a/qa/qa/specs/features/ee/api/geo_nodes_spec.rb +++ b/qa/qa/specs/features/ee/api/geo_nodes_spec.rb @@ -86,7 +86,6 @@ module QA include_examples 'retrieving status about all Geo nodes' include_examples 'retrieving status about a specific Geo node' - include_examples 'retrieving project sync failures ocurred on the current node' feature 'editing a Geo node' do scenario 'PUT /geo_nodes/:id for primary node' do -- GitLab