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
e37d18ed
Commit
e37d18ed
authored
Oct 10, 2019
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor wait_for_services to aim for more SRP
parent
2fa30478
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
16 deletions
+34
-16
qa/qa/ee/scenario/test/geo.rb
qa/qa/ee/scenario/test/geo.rb
+34
-16
No files found.
qa/qa/ee/scenario/test/geo.rb
View file @
e37d18ed
...
@@ -102,6 +102,8 @@ module QA
...
@@ -102,6 +102,8 @@ module QA
class
Secondary
class
Secondary
include
QA
::
Scenario
::
Actable
include
QA
::
Scenario
::
Actable
WAIT_FOR_SERVICES_SECS
=
120
def
initialize
def
initialize
@address
=
QA
::
Runtime
::
Scenario
.
geo_secondary_address
@address
=
QA
::
Runtime
::
Scenario
.
geo_secondary_address
@name
=
QA
::
Runtime
::
Scenario
.
geo_secondary_name
@name
=
QA
::
Runtime
::
Scenario
.
geo_secondary_name
...
@@ -135,23 +137,13 @@ module QA
...
@@ -135,23 +137,13 @@ module QA
def
wait_for_services
def
wait_for_services
puts
'Waiting until secondary node services are ready ...'
puts
'Waiting until secondary node services are ready ...'
Time
.
new
.
tap
do
|
start
|
elapsed
=
try_for
(
WAIT_FOR_SERVICES_SECS
)
do
|
elapsed
|
while
Time
.
new
-
start
<
120
break
elapsed
if
host_ready?
begin
if
host_ready?
return
puts
"
\n
Secondary ready after
#{
Time
.
now
-
start
}
seconds."
# rubocop:disable Cop/AvoidReturnFromBlocks
else
print
'.'
end
rescue
StandardError
print
'e'
end
sleep
1
end
raise
"Secondary node did not start correctly in
#{
Time
.
now
-
start
}
seconds!"
end
end
puts
"
\n
Secondary ready after
#{
elapsed
}
seconds."
rescue
TryForExceeded
raise
"Secondary node did not start correctly after
#{
WAIT_FOR_SERVICES_SECS
}
seconds!"
end
end
def
authorize
def
authorize
...
@@ -169,7 +161,33 @@ module QA
...
@@ -169,7 +161,33 @@ module QA
private
private
TryForExceeded
=
Class
.
new
(
StandardError
)
def
try_for
(
secs
)
start
=
Time
.
new
loop
do
elapsed
=
(
Time
.
new
-
start
).
round
(
2
)
break
elapsed
if
elapsed
>=
secs
yield
elapsed
sleep
1
end
raise
TryForExceeded
end
def
host_ready?
def
host_ready?
return
true
if
host_status_ok?
print
'.'
false
rescue
StandardError
print
'e'
false
end
def
host_status_ok?
body
=
Net
::
HTTP
.
get
(
URI
.
join
(
@address
,
'/-/readiness'
))
body
=
Net
::
HTTP
.
get
(
URI
.
join
(
@address
,
'/-/readiness'
))
JSON
.
parse
(
body
)[
'status'
]
==
'ok'
JSON
.
parse
(
body
)[
'status'
]
==
'ok'
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