Commit a2df8321 authored by Stan Hu's avatar Stan Hu

Merge branch 'resolve-issue-7434' into 'master'

Resolve "ee:geo QA specs are failing as of !7210"

Closes gitlab-org/quality/nightly#7 and #7434

See merge request gitlab-org/gitlab-ee!7315
parents 5e0beca6 c9b9fb0a
---
title: 'Resolve "ee:geo QA specs are failing as of !7210"'
merge_request: 7315
author:
type: other
...@@ -54,11 +54,22 @@ describe API::GeoNodes, :geo, :prometheus, api: true do ...@@ -54,11 +54,22 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
end end
describe 'GET /geo_nodes/status' do describe 'GET /geo_nodes/status' do
it 'retrieves the Geo nodes status if admin is logged in' do it 'retrieves all Geo nodes statuses if admin is logged in' do
create(:geo_node_status, :healthy, geo_node: primary)
get api("/geo_nodes/status", admin) get api("/geo_nodes/status", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/geo_node_statuses', dir: 'ee') expect(response).to match_response_schema('public_api/v4/geo_node_statuses', dir: 'ee')
expect(json_response.size).to eq(2)
end
it 'returns only one record if only one record exists' do
get api("/geo_nodes/status", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/geo_node_statuses', dir: 'ee')
expect(json_response.size).to eq(1)
end end
it 'denies access if not admin' do it 'denies access if not admin' do
...@@ -113,7 +124,7 @@ describe API::GeoNodes, :geo, :prometheus, api: true do ...@@ -113,7 +124,7 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
expect(response).to match_response_schema('public_api/v4/geo_node_status', dir: 'ee') expect(response).to match_response_schema('public_api/v4/geo_node_status', dir: 'ee')
end end
it 'shows 404 response if current node status does not exist in database or redis yet' do it 'the secondary shows 404 response if current node status does not exist in database or redis yet' do
stub_current_geo_node(secondary) stub_current_geo_node(secondary)
secondary_status.destroy! secondary_status.destroy!
...@@ -125,6 +136,17 @@ describe API::GeoNodes, :geo, :prometheus, api: true do ...@@ -125,6 +136,17 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
it 'the primary shows 404 response if secondary node status does not exist in database yet' do
stub_current_geo_node(primary)
secondary_status.destroy!
expect(GeoNode).to receive(:find).and_return(secondary)
get api("/geo_nodes/#{secondary.id}/status", admin)
expect(response).to have_gitlab_http_status(404)
end
it_behaves_like '404 response' do it_behaves_like '404 response' do
let(:request) { get api("/geo_nodes/#{unexisting_node_id}/status", admin) } let(:request) { get api("/geo_nodes/#{unexisting_node_id}/status", admin) }
end end
......
...@@ -27,58 +27,6 @@ module QA ...@@ -27,58 +27,6 @@ module QA
end end
end end
shared_examples 'retrieving status about all Geo nodes' do
it 'GET /geo_nodes/status' do
get api_endpoint('/geo_nodes/status')
expect_status(200)
expect(json_body.size).to be >= 2
# 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,
projects_count: :integer,
repositories_count: :integer,
wikis_count: :integer,
replication_slots_count: :integer_or_null,
version: :string_or_null)
end
end
shared_examples 'retrieving status about a specific Geo node' do
it 'GET /geo_nodes/:id/status of primary node' do
get api_endpoint("/geo_nodes/#{@primary_node[:id]}/status")
expect_status(200)
expect_json(geo_node_id: @primary_node[:id])
end
it '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])
end
it 'GET /geo_nodes/:id/status of an invalid node' do
get api_endpoint("/geo_nodes/1000/status")
expect_status(404)
end
end
shared_examples 'retrieving project sync failures ocurred on the current node' do
it 'GET /geo_nodes/current/failures' do
get api_endpoint("/geo_nodes/current/failures")
expect_status(200)
expect(json_body).to be_an Array
end
end
describe 'Geo Nodes API on primary node', :geo do describe 'Geo Nodes API on primary node', :geo do
before(:context) do before(:context) do
fetch_nodes(:geo_primary) fetch_nodes(:geo_primary)
...@@ -88,17 +36,7 @@ module QA ...@@ -88,17 +36,7 @@ module QA
let(:geo_node) { @primary_node } let(:geo_node) { @primary_node }
end end
include_examples 'retrieving status about all Geo nodes'
include_examples 'retrieving status about a specific Geo node'
describe 'editing a Geo node' do describe 'editing a Geo node' do
it 'PUT /geo_nodes/:id for primary node' do
put api_endpoint("/geo_nodes/#{@primary_node[:id]}"),
{ params: { files_max_capacity: 1000 } }
expect_status(403)
end
it 'PUT /geo_nodes/:id for secondary node' do it 'PUT /geo_nodes/:id for secondary node' do
endpoint = api_endpoint("/geo_nodes/#{@secondary_node[:id]}") endpoint = api_endpoint("/geo_nodes/#{@secondary_node[:id]}")
new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 } new_attributes = { enabled: false, files_max_capacity: 1000, repos_max_capacity: 2000 }
...@@ -115,35 +53,6 @@ module QA ...@@ -115,35 +53,6 @@ module QA
expect_status(200) expect_status(200)
end end
it 'PUT /geo_nodes/:id for an invalid node' do
put api_endpoint("/geo_nodes/1000"),
{ params: { files_max_capacity: 1000 } }
expect_status(404)
end
end
describe 'repairing a Geo node' do
it 'POST /geo_nodes/:id/repair for primary node' do
post api_endpoint("/geo_nodes/#{@primary_node[:id]}/repair")
expect_status(200)
expect_json(geo_node_id: @primary_node[:id])
end
it '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])
end
it 'POST /geo_nodes/:id/repair for an invalid node' do
post api_endpoint("/geo_nodes/1000/repair")
expect_status(404)
end
end end
end end
...@@ -155,60 +64,6 @@ module QA ...@@ -155,60 +64,6 @@ module QA
include_examples 'retrieving configuration about Geo nodes' do include_examples 'retrieving configuration about Geo nodes' do
let(:geo_node) { @nodes.first } let(:geo_node) { @nodes.first }
end end
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'
it 'GET /geo_nodes is not current' do
get api_endpoint('/geo_nodes')
expect_status(200)
expect_json('?', current: false)
end
describe 'editing a Geo node' do
it 'PUT /geo_nodes/:id for primary node' do
put api_endpoint("/geo_nodes/#{@primary_node[:id]}"),
{ params: { files_max_capacity: 1000 } }
expect_status(403)
end
it 'PUT /geo_nodes/:id for secondary node' do
put api_endpoint("/geo_nodes/#{@secondary_node[:id]}"),
{ params: { files_max_capacity: 1000 } }
expect_status(403)
end
it 'PUT /geo_nodes/:id for an invalid node' do
put api_endpoint('/geo_nodes/1000'),
{ params: { files_max_capacity: 1000 } }
expect_status(403)
end
end
describe 'repairing a Geo node' do
it 'POST /geo_nodes/:id/repair for primary node' do
post api_endpoint("/geo_nodes/#{@primary_node[:id]}/repair")
expect_status(403)
end
it 'POST /geo_nodes/:id/repair for secondary node' do
post api_endpoint("/geo_nodes/#{@secondary_node[:id]}/repair")
expect_status(403)
end
it 'POST /geo_nodes/:id/repair for an invalid node' do
post api_endpoint('/geo_nodes/1000/repair')
expect_status(403)
end
end
end end
def api_endpoint(endpoint) def api_endpoint(endpoint)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment