Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1f679685
Commit
1f679685
authored
Jan 31, 2020
by
Rajendra Kadam
Committed by
Michael Kozono
Jan 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace Net::HTTP with Gitlab::HTTP in rake gitlab:geo:check
parent
d6c8dbbb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
4 deletions
+78
-4
changelogs/unreleased/geo-http-check.yml
changelogs/unreleased/geo-http-check.yml
+5
-0
ee/lib/system_check/geo/http_connection_check.rb
ee/lib/system_check/geo/http_connection_check.rb
+2
-4
ee/spec/lib/system_check/geo/http_connection_check_spec.rb
ee/spec/lib/system_check/geo/http_connection_check_spec.rb
+71
-0
No files found.
changelogs/unreleased/geo-http-check.yml
0 → 100644
View file @
1f679685
---
title
:
Replace Net::HTTP with Gitlab::HTTP in rake gitlab:geo:check
merge_request
:
23741
author
:
Rajendra Kadam
type
:
added
ee/lib/system_check/geo/http_connection_check.rb
View file @
1f679685
...
...
@@ -33,11 +33,9 @@ module SystemCheck
private
def
check_gitlab_geo_node
(
node
)
response
=
Net
::
HTTP
.
start
(
node
.
internal_uri
.
host
,
node
.
internal_uri
.
port
,
use_ssl:
(
node
.
internal_uri
.
scheme
==
'https'
))
do
|
http
|
http
.
request
(
Net
::
HTTP
::
Get
.
new
(
node
.
internal_uri
))
end
response
=
Gitlab
::
HTTP
.
get
(
node
.
internal_uri
,
allow_local_requests:
true
)
if
response
.
code_type
==
Net
::
HTTP
Found
if
response
.
code_type
==
Net
::
HTTP
OK
$stdout
.
puts
'yes'
.
color
(
:green
)
else
$stdout
.
puts
'no'
.
color
(
:red
)
...
...
ee/spec/lib/system_check/geo/http_connection_check_spec.rb
View file @
1f679685
...
...
@@ -2,6 +2,11 @@
require
'spec_helper'
describe
SystemCheck
::
Geo
::
HttpConnectionCheck
do
include
EE
::
GeoHelpers
let_it_be
(
:primary_node
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:http_method
)
{
:get
}
describe
'skip?'
do
it
'skips when Geo is disabled'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
false
}
...
...
@@ -18,4 +23,70 @@ describe SystemCheck::Geo::HttpConnectionCheck do
expect
(
subject
.
skip_reason
).
to
eq
(
'not a secondary node'
)
end
end
describe
'multi_check'
do
before
do
stub_current_geo_node
(
primary_node
)
end
context
'connection success'
do
it
'puts yes if check works'
do
stub_request
(
http_method
,
primary_node
.
internal_uri
).
to_return
(
status:
200
,
body:
""
,
headers:
{})
expect
do
subject
.
multi_check
end
.
to
output
(
"
\n
* Can connect to the primary node ... yes
\n
"
).
to_stdout
end
end
context
'connection errored'
do
it
'puts no if check errored'
do
stub_request
(
http_method
,
primary_node
.
internal_uri
).
to_return
(
status:
400
,
body:
""
,
headers:
{})
expect
do
subject
.
multi_check
end
.
to
output
(
"
\n
* Can connect to the primary node ... no
\n
"
).
to_stdout
end
end
context
'connection exceptions'
do
it
'calls try_fixing_it for econnrefused'
do
stub_request
(
http_method
,
primary_node
.
internal_uri
).
to_raise
(
Errno
::
ECONNREFUSED
)
expect
do
subject
.
multi_check
end
.
to
output
(
econnrefused_help_messages
).
to_stdout
end
it
'calls try_fixing_it for econnrefused'
do
stub_request
(
http_method
,
primary_node
.
internal_uri
).
to_raise
(
SocketError
.
new
)
expect
do
subject
.
multi_check
end
.
to
output
(
socketerror_help_messages
).
to_stdout
end
it
'calls try_fixing_it for openssl errors'
do
stub_request
(
http_method
,
primary_node
.
internal_uri
).
to_raise
(
OpenSSL
::
SSL
::
SSLError
.
new
)
expect
do
subject
.
multi_check
end
.
to
output
(
openssl_error_help_messages
).
to_stdout
end
end
end
private
def
econnrefused_help_messages
/Can connect to the primary node ... no.*Connection refused/m
end
def
socketerror_help_messages
/Can connect to the primary node ... no.*SocketError/m
end
def
openssl_error_help_messages
/Can connect to the primary node ... no.*OpenSSL::SSL::SSLError/m
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment