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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
80b0834a
Commit
80b0834a
authored
Nov 06, 2017
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Clusters::Appplications::CheckInstallationProgressService tests
parent
c6c9b37b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
2 deletions
+82
-2
app/services/clusters/applications/check_installation_progress_service.rb
...sters/applications/check_installation_progress_service.rb
+2
-2
spec/factories/clusters/applications/helm.rb
spec/factories/clusters/applications/helm.rb
+5
-0
spec/services/clusters/applications/check_installation_progress_service_spec.rb
.../applications/check_installation_progress_service_spec.rb
+75
-0
No files found.
app/services/clusters/applications/check_installation_progress_service.rb
View file @
80b0834a
...
@@ -27,13 +27,13 @@ module Clusters
...
@@ -27,13 +27,13 @@ module Clusters
end
end
def
on_failed
def
on_failed
app
.
make_errored!
(
log
||
'Installation silently failed'
)
app
.
make_errored!
(
installation_errors
||
'Installation silently failed'
)
finalize_installation
finalize_installation
end
end
def
check_timeout
def
check_timeout
if
Time
.
now
.
utc
-
app
.
updated_at
.
to_time
.
utc
>
ClusterWaitForAppInstallationWorker
::
TIMEOUT
if
Time
.
now
.
utc
-
app
.
updated_at
.
to_time
.
utc
>
ClusterWaitForAppInstallationWorker
::
TIMEOUT
app
.
make_errored!
(
'
App i
nstallation timeouted'
)
app
.
make_errored!
(
'
I
nstallation timeouted'
)
else
else
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
...
...
spec/factories/clusters/applications/helm.rb
View file @
80b0834a
...
@@ -31,5 +31,10 @@ FactoryGirl.define do
...
@@ -31,5 +31,10 @@ FactoryGirl.define do
status
(
-
1
)
status
(
-
1
)
status_reason
'something went wrong'
status_reason
'something went wrong'
end
end
trait
:timeouted
do
installing
updated_at
ClusterWaitForAppInstallationWorker
::
TIMEOUT
.
ago
end
end
end
end
end
spec/services/clusters/applications/check_installation_progress_service_spec.rb
0 → 100644
View file @
80b0834a
require
'spec_helper'
describe
Clusters
::
Applications
::
CheckInstallationProgressService
do
RESCHEDULE_PHASES
=
Gitlab
::
Kubernetes
::
Pod
::
PHASES
-
[
Gitlab
::
Kubernetes
::
Pod
::
SUCCEEDED
,
Gitlab
::
Kubernetes
::
Pod
::
FAILED
].
freeze
def
mock_helm_api
(
phase
,
errors:
nil
)
expect
(
service
).
to
receive
(
:installation_phase
).
once
.
and_return
(
phase
)
expect
(
service
).
to
receive
(
:installation_errors
).
once
.
and_return
(
errors
)
if
errors
.
present?
end
shared_examples
'not yet completed phase'
do
|
phase
|
context
"when the installation POD phase is
#{
phase
}
"
do
before
do
mock_helm_api
(
phase
)
end
context
'when not timeouted'
do
it
'reschedule a new check'
do
expect
(
ClusterWaitForAppInstallationWorker
).
to
receive
(
:perform_in
).
once
service
.
execute
expect
(
application
).
to
be_installing
expect
(
application
.
status_reason
).
to
be_nil
end
end
context
'when timeouted'
do
let
(
:application
)
{
create
(
:applications_helm
,
:timeouted
)
}
it
'make the application errored'
do
expect
(
ClusterWaitForAppInstallationWorker
).
not_to
receive
(
:perform_in
)
service
.
execute
expect
(
application
).
to
be_errored
expect
(
application
.
status_reason
).
to
match
(
/\btimeouted\b/
)
end
end
end
end
describe
'#execute'
do
let
(
:application
)
{
create
(
:applications_helm
,
:installing
)
}
let
(
:service
)
{
described_class
.
new
(
application
)
}
context
'when installation POD succeeded'
do
it
'make the application installed'
do
mock_helm_api
(
Gitlab
::
Kubernetes
::
Pod
::
SUCCEEDED
)
expect
(
service
).
to
receive
(
:finalize_installation
).
once
service
.
execute
expect
(
application
).
to
be_installed
expect
(
application
.
status_reason
).
to
be_nil
end
end
context
'when installation POD failed'
do
let
(
:error_message
)
{
'test installation failed'
}
it
'make the application errored'
do
mock_helm_api
(
Gitlab
::
Kubernetes
::
Pod
::
FAILED
,
errors:
error_message
)
expect
(
service
).
to
receive
(
:finalize_installation
).
once
service
.
execute
expect
(
application
).
to
be_errored
expect
(
application
.
status_reason
).
to
eq
(
error_message
)
end
end
RESCHEDULE_PHASES
.
each
{
|
phase
|
it_behaves_like
'not yet completed phase'
,
phase
}
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