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
3613fed3
Commit
3613fed3
authored
Mar 20, 2018
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deployment_platform assignation when multiple clusters & environments
Closes #5347
parent
cac6a815
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
38 deletions
+59
-38
ee/app/models/concerns/ee/deployment_platform.rb
ee/app/models/concerns/ee/deployment_platform.rb
+1
-1
ee/changelogs/unreleased/5347-fix-multiple-clusters-incorrect-details-injected.yml
...5347-fix-multiple-clusters-incorrect-details-injected.yml
+5
-0
ee/spec/models/concerns/ee/deployment_platform_spec.rb
ee/spec/models/concerns/ee/deployment_platform_spec.rb
+53
-37
No files found.
ee/app/models/concerns/ee/deployment_platform.rb
View file @
3613fed3
...
...
@@ -6,7 +6,7 @@ module EE
def
deployment_platform
(
environment:
nil
)
return
super
unless
environment
&&
feature_available?
(
:multiple_clusters
)
@deployment_platform
||
=
# rubocop:disable Gitlab/ModuleWithInstanceVariables
@deployment_platform
=
# rubocop:disable Gitlab/ModuleWithInstanceVariables
clusters
.
enabled
.
on_environment
(
environment
.
name
)
.
last
&
.
platform_kubernetes
...
...
ee/changelogs/unreleased/5347-fix-multiple-clusters-incorrect-details-injected.yml
0 → 100644
View file @
3613fed3
---
title
:
Fixes incorrect assignation of cluster details
merge_request
:
5047
author
:
type
:
fixed
ee/spec/models/concerns/ee/deployment_platform_spec.rb
View file @
3613fed3
...
...
@@ -4,56 +4,56 @@ describe EE::DeploymentPlatform do
describe
'#deployment_platform'
do
let
(
:project
)
{
create
(
:project
)
}
context
'when environment is specified'
do
let
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'review/name'
)
}
let!
(
:default_cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
],
environment_scope:
'*'
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
environment_scope:
'review/*'
,
projects:
[
project
])
}
subject
{
project
.
deployment_platform
(
environment:
environment
)
}
shared_examples
'matching environment scope'
do
context
'when multiple clusters is available'
do
before
do
stub_licensed_features
(
multiple_clusters:
true
)
end
shared_examples
'matching environment scope'
do
context
'when multiple clusters license is available'
do
before
do
stub_licensed_features
(
multiple_clusters:
true
)
end
it
'returns environment specific cluster'
do
is_expected
.
to
eq
(
cluster
.
platform_kubernetes
)
end
it
'returns environment specific cluster'
do
is_expected
.
to
eq
(
cluster
.
platform_kubernetes
)
end
end
context
'when multiple clusters
is unavailable'
do
before
do
stub_licensed_features
(
multiple_clusters:
false
)
end
context
'when multiple clusters licence
is unavailable'
do
before
do
stub_licensed_features
(
multiple_clusters:
false
)
end
it
'returns a kubernetes platform'
do
is_expected
.
to
be_kind_of
(
Clusters
::
Platforms
::
Kubernetes
)
end
it
'returns a kubernetes platform'
do
is_expected
.
to
be_kind_of
(
Clusters
::
Platforms
::
Kubernetes
)
end
end
end
shared_examples
'not matching environment scope'
do
context
'when multiple clusters
is available'
do
before
do
stub_licensed_features
(
multiple_clusters:
true
)
end
shared_examples
'not matching environment scope'
do
context
'when multiple clusters license
is available'
do
before
do
stub_licensed_features
(
multiple_clusters:
true
)
end
it
'returns default cluster'
do
is_expected
.
to
eq
(
default_cluster
.
platform_kubernetes
)
end
it
'returns default cluster'
do
is_expected
.
to
eq
(
default_cluster
.
platform_kubernetes
)
end
end
context
'when multiple clusters
is unavailable'
do
before
do
stub_licensed_features
(
multiple_clusters:
false
)
end
context
'when multiple clusters license
is unavailable'
do
before
do
stub_licensed_features
(
multiple_clusters:
false
)
end
it
'returns a kubernetes platform'
do
is_expected
.
to
be_kind_of
(
Clusters
::
Platforms
::
Kubernetes
)
end
it
'returns a kubernetes platform'
do
is_expected
.
to
be_kind_of
(
Clusters
::
Platforms
::
Kubernetes
)
end
end
end
context
'when environment is specified'
do
let!
(
:default_cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
],
environment_scope:
'*'
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
environment_scope:
'review/*'
,
projects:
[
project
])
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'review/name'
)
}
subject
{
project
.
deployment_platform
(
environment:
environment
)
}
context
'when environment scope is exactly matched'
do
before
do
...
...
@@ -133,5 +133,21 @@ describe EE::DeploymentPlatform do
end
end
end
context
'with multiple clusters and multiple environments'
do
let!
(
:cluster_1
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
],
environment_scope:
'staging/*'
)
}
let!
(
:cluster_2
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
],
environment_scope:
'test/*'
)
}
let
(
:environment_1
)
{
create
(
:environment
,
project:
project
,
name:
'staging/name'
)
}
let
(
:environment_2
)
{
create
(
:environment
,
project:
project
,
name:
'test/name'
)
}
before
do
stub_licensed_features
(
multiple_clusters:
true
)
end
it
'should return the appropriate cluster'
do
expect
(
project
.
deployment_platform
(
environment:
environment_1
)).
to
eq
(
cluster_1
.
platform_kubernetes
)
expect
(
project
.
deployment_platform
(
environment:
environment_2
)).
to
eq
(
cluster_2
.
platform_kubernetes
)
end
end
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