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
a0802dd8
Commit
a0802dd8
authored
Dec 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add EE spec for KubernetesService and Platform::Kubernetes compatibility
parent
582e4014
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
56 deletions
+83
-56
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+1
-1
spec/ee/spec/models/project_services/kubernetes_service_spec.rb
...e/spec/models/project_services/kubernetes_service_spec.rb
+48
-34
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+32
-19
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+2
-2
No files found.
spec/controllers/projects/environments_controller_spec.rb
View file @
a0802dd8
...
@@ -34,7 +34,7 @@ describe Projects::EnvironmentsController do
...
@@ -34,7 +34,7 @@ describe Projects::EnvironmentsController do
context
'when requesting JSON response for folders'
do
context
'when requesting JSON response for folders'
do
before
do
before
do
allow_any_instance_of
(
Environment
).
to
receive
(
:
deployment_service_ready
?
).
and_return
(
true
)
allow_any_instance_of
(
Environment
).
to
receive
(
:
has_terminals
?
).
and_return
(
true
)
allow_any_instance_of
(
Environment
).
to
receive
(
:rollout_status
).
and_return
(
kube_deployment_rollout_status
)
allow_any_instance_of
(
Environment
).
to
receive
(
:rollout_status
).
and_return
(
kube_deployment_rollout_status
)
create
(
:environment
,
project:
project
,
create
(
:environment
,
project:
project
,
...
...
spec/ee/spec/models/project_services/kubernetes_service_spec.rb
View file @
a0802dd8
...
@@ -4,51 +4,65 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
...
@@ -4,51 +4,65 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
include
KubernetesHelpers
include
KubernetesHelpers
include
ReactiveCachingHelpers
include
ReactiveCachingHelpers
let
(
:project
)
{
build_stubbed
(
:kubernetes_project
)
}
shared_examples
'same behavior between KubernetesService and Platform::Kubernetes'
do
let
(
:service
)
{
project
.
kubernetes_service
}
let
(
:service
)
{
project
.
deployment_platform
}
describe
'#rollout_status'
do
describe
'#rollout_status'
do
let
(
:environment
)
{
build
(
:environment
,
project:
project
,
name:
"env"
,
slug:
"env-000000"
)
}
let
(
:environment
)
{
build
(
:environment
,
project:
project
,
name:
"env"
,
slug:
"env-000000"
)
}
subject
(
:rollout_status
)
{
service
.
rollout_status
(
environment
)
}
subject
(
:rollout_status
)
{
service
.
rollout_status
(
environment
)
}
context
'with valid deployments'
do
context
'with valid deployments'
do
before
do
before
do
stub_reactive_cache
(
stub_reactive_cache
(
service
,
service
,
deployments:
[
kube_deployment
(
app:
environment
.
slug
),
kube_deployment
]
deployments:
[
kube_deployment
(
app:
environment
.
slug
),
kube_deployment
]
)
)
end
end
it
'creates a matching RolloutStatus'
do
it
'creates a matching RolloutStatus'
do
expect
(
rollout_status
).
to
be_kind_of
(
::
Gitlab
::
Kubernetes
::
RolloutStatus
)
expect
(
rollout_status
).
to
be_kind_of
(
::
Gitlab
::
Kubernetes
::
RolloutStatus
)
expect
(
rollout_status
.
deployments
.
map
(
&
:labels
)).
to
eq
([{
'app'
=>
'env-000000'
}])
expect
(
rollout_status
.
deployments
.
map
(
&
:labels
)).
to
eq
([{
'app'
=>
'env-000000'
}])
end
end
end
end
context
'with empty list of deployments'
do
context
'with empty list of deployments'
do
before
do
before
do
stub_reactive_cache
(
stub_reactive_cache
(
service
,
service
,
deployments:
[]
deployments:
[]
)
)
end
end
it
'creates a matching RolloutStatus'
do
it
'creates a matching RolloutStatus'
do
expect
(
rollout_status
).
to
be_kind_of
(
::
Gitlab
::
Kubernetes
::
RolloutStatus
)
expect
(
rollout_status
).
to
be_kind_of
(
::
Gitlab
::
Kubernetes
::
RolloutStatus
)
expect
(
rollout_status
).
to
be_not_found
expect
(
rollout_status
).
to
be_not_found
end
end
end
end
context
'not yet loaded deployments'
do
context
'not yet loaded deployments'
do
before
do
before
do
stub_reactive_cache
stub_reactive_cache
end
end
it
'creates a matching RolloutStatus'
do
it
'creates a matching RolloutStatus'
do
expect
(
rollout_status
).
to
be_kind_of
(
::
Gitlab
::
Kubernetes
::
RolloutStatus
)
expect
(
rollout_status
).
to
be_kind_of
(
::
Gitlab
::
Kubernetes
::
RolloutStatus
)
expect
(
rollout_status
).
to
be_loading
expect
(
rollout_status
).
to
be_loading
end
end
end
end
end
end
end
context
'when user configured kubernetes from Integration > Kubernetes'
do
let
(
:project
)
{
create
(
:kubernetes_project
)
}
it_behaves_like
'same behavior between KubernetesService and Platform::Kubernetes'
end
context
'when user configured kubernetes from CI/CD > Clusters'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
)
}
let
(
:project
)
{
cluster
.
project
}
it_behaves_like
'same behavior between KubernetesService and Platform::Kubernetes'
end
end
end
spec/models/environment_spec.rb
View file @
a0802dd8
...
@@ -322,8 +322,8 @@ describe Environment do
...
@@ -322,8 +322,8 @@ describe Environment do
end
end
end
end
describe
'#
deployment_service_ready
?'
do
describe
'#
has_terminals
?'
do
subject
{
environment
.
deployment_service_ready
?
}
subject
{
environment
.
has_terminals
?
}
context
'when the enviroment is available'
do
context
'when the enviroment is available'
do
context
'with a deployment service'
do
context
'with a deployment service'
do
...
@@ -373,7 +373,7 @@ describe Environment do
...
@@ -373,7 +373,7 @@ describe Environment do
context
'when the environment has terminals'
do
context
'when the environment has terminals'
do
before
do
before
do
allow
(
environment
).
to
receive
(
:
deployment_service_ready
?
).
and_return
(
true
)
allow
(
environment
).
to
receive
(
:
has_terminals
?
).
and_return
(
true
)
end
end
shared_examples
'same behavior between KubernetesService and Platform::Kubernetes'
do
shared_examples
'same behavior between KubernetesService and Platform::Kubernetes'
do
...
@@ -402,7 +402,7 @@ describe Environment do
...
@@ -402,7 +402,7 @@ describe Environment do
context
'when the environment does not have terminals'
do
context
'when the environment does not have terminals'
do
before
do
before
do
allow
(
environment
).
to
receive
(
:
deployment_service_ready
?
).
and_return
(
false
)
allow
(
environment
).
to
receive
(
:
has_terminals
?
).
and_return
(
false
)
end
end
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
...
@@ -410,30 +410,43 @@ describe Environment do
...
@@ -410,30 +410,43 @@ describe Environment do
end
end
describe
'#rollout_status'
do
describe
'#rollout_status'
do
let
(
:project
)
{
create
(
:kubernetes_project
)
}
shared_examples
'same behavior between KubernetesService and Platform::Kubernetes'
do
subject
{
environment
.
rollout_status
}
subject
{
environment
.
rollout_status
}
context
'when the environment has rollout status'
do
before
do
allow
(
environment
).
to
receive
(
:has_terminals?
).
and_return
(
true
)
end
context
'when the environment has rollout status'
do
it
'returns the rollout status from the deployment service'
do
before
do
expect
(
project
.
deployment_platform
)
allow
(
environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
.
to
receive
(
:rollout_status
).
with
(
environment
)
.
and_return
(
:fake_rollout_status
)
is_expected
.
to
eq
(
:fake_rollout_status
)
end
end
end
it
'returns the rollout status from the deployment service
'
do
context
'when the environment does not have rollout status
'
do
expect
(
project
.
deployment_service
)
before
do
.
to
receive
(
:rollout_status
).
with
(
environment
)
allow
(
environment
).
to
receive
(
:has_terminals?
).
and_return
(
false
)
.
and_return
(
:fake_rollout_status
)
end
i
s_expected
.
to
eq
(
:fake_rollout_status
)
i
t
{
is_expected
.
to
eq
(
nil
)
}
end
end
end
end
context
'when the environment does not have rollout status'
do
context
'when user configured kubernetes from Integration > Kubernetes'
do
before
do
let
(
:project
)
{
create
(
:kubernetes_project
)
}
allow
(
environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
false
)
end
it_behaves_like
'same behavior between KubernetesService and Platform::Kubernetes'
end
context
'when user configured kubernetes from CI/CD > Clusters'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
)
}
let
(
:project
)
{
cluster
.
project
}
it
{
is_expected
.
to
eq
(
nil
)
}
it
_behaves_like
'same behavior between KubernetesService and Platform::Kubernetes'
end
end
end
end
...
...
spec/serializers/environment_entity_spec.rb
View file @
a0802dd8
...
@@ -51,7 +51,7 @@ describe EnvironmentEntity do
...
@@ -51,7 +51,7 @@ describe EnvironmentEntity do
context
'with deployment service ready'
do
context
'with deployment service ready'
do
before
do
before
do
stub_licensed_features
(
deploy_board:
true
)
stub_licensed_features
(
deploy_board:
true
)
allow
(
environment
).
to
receive
(
:
deployment_service_ready
?
).
and_return
(
true
)
allow
(
environment
).
to
receive
(
:
has_terminals
?
).
and_return
(
true
)
allow
(
environment
).
to
receive
(
:rollout_status
).
and_return
(
kube_deployment_rollout_status
)
allow
(
environment
).
to
receive
(
:rollout_status
).
and_return
(
kube_deployment_rollout_status
)
end
end
...
@@ -63,7 +63,7 @@ describe EnvironmentEntity do
...
@@ -63,7 +63,7 @@ describe EnvironmentEntity do
context
'when license does not has the GitLab_DeployBoard add-on'
do
context
'when license does not has the GitLab_DeployBoard add-on'
do
before
do
before
do
stub_licensed_features
(
deploy_board:
false
)
stub_licensed_features
(
deploy_board:
false
)
allow
(
environment
).
to
receive
(
:
deployment_service_ready
?
).
and_return
(
true
)
allow
(
environment
).
to
receive
(
:
has_terminals
?
).
and_return
(
true
)
end
end
it
'does not expose rollout_status'
do
it
'does not expose rollout_status'
do
...
...
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