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
Léo-Paul Géneau
gitlab-ce
Commits
7eeada80
Commit
7eeada80
authored
Dec 18, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add env_scope tests
parent
8e6ffe35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
...grate_kubernetes_service_to_new_clusters_architectures.rb
+1
-0
spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
..._kubernetes_service_to_new_clusters_architectures_spec.rb
+32
-0
No files found.
db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
View file @
7eeada80
...
...
@@ -88,6 +88,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
provider_type:
Cluster
.
provider_types
[
:user
],
platform_type:
Cluster
.
platform_types
[
:kubernetes
],
projects:
[
kubernetes_service
.
project
],
environment_scope:
'*'
,
# KubernetesService is considered as a default cluster
platform_kubernetes_attributes:
{
api_url:
kubernetes_service
.
api_url
,
ca_cert:
kubernetes_service
.
ca_pem
,
...
...
spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
View file @
7eeada80
...
...
@@ -113,6 +113,38 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
context
'when production cluster has already been existsed'
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
environment_scope:
'production/*'
,
projects:
[
project
])
}
let!
(
:kubernetes_service
)
{
create
(
:kubernetes_service
,
api_url:
'https://debug.kube.com'
,
active:
true
,
project:
project
)
}
it
'migrates the KubernetesService to Platform::Kubernetes'
do
expect
{
migrate!
}.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
1
)
kubernetes_service
.
reload
project
.
clusters
.
last
.
tap
do
|
cluster
|
expect
(
cluster
.
platform_kubernetes
.
api_url
).
to
eq
(
kubernetes_service
.
api_url
)
expect
(
cluster
.
platform_kubernetes
.
ca_pem
).
to
eq
(
kubernetes_service
.
ca_pem
)
expect
(
cluster
.
platform_kubernetes
.
token
).
to
eq
(
kubernetes_service
.
token
)
expect
(
kubernetes_service
).
not_to
be_active
expect
(
kubernetes_service
.
properties
[
'migrated'
]).
to
be_truthy
end
end
end
context
'when default cluster has already been existsed'
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
environment_scope:
'*'
,
projects:
[
project
])
}
let!
(
:kubernetes_service
)
{
create
(
:kubernetes_service
,
api_url:
'https://debug.kube.com'
,
active:
true
,
project:
project
)
}
it
'does not migrate the KubernetesService'
do
# Because environment_scope is duplicated
expect
{
migrate!
}.
not_to
change
{
Clusters
::
Cluster
.
count
}
expect
(
kubernetes_service
).
to
be_active
expect
(
kubernetes_service
.
properties
[
'migrated'
]).
to
be_falsy
end
end
context
'when KubernetesService does not exist'
do
let!
(
:project
)
{
create
(
:project
)
}
...
...
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