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
8e6ffe35
Commit
8e6ffe35
authored
Dec 15, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test
parent
4dc14576
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
187 deletions
+52
-187
spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
..._kubernetes_service_to_new_clusters_architectures_spec.rb
+52
-187
No files found.
spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
View file @
8e6ffe35
...
@@ -54,205 +54,70 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
...
@@ -54,205 +54,70 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
context
'when unique KubernetesService spawned from Service Template'
do
context
'when unique KubernetesService spawned from Service Template'
do
it
'migrates the KubernetesService to Platform::Kubernetes'
do
let
(
:sample_num
)
{
2
}
let
(
:projects
)
{
create_list
(
:project
,
sample_num
)
}
let!
(
:kubernetes_service_template
)
do
create
(
:kubernetes_service
,
project:
nil
,
template:
true
,
api_url:
"https://sample.kubernetes.com"
,
token:
"token-sample"
,
ca_pem:
"ca_pem-sample"
)
end
end
end
context
'when synced KubernetesService exists'
do
it
'does not migrate the KubernetesService'
do
# Because the corresponding Platform::Kubernetes already exists
let!
(
:kubernetes_services
)
do
projects
.
map
do
|
project
|
create
(
:kubernetes_service
,
project:
project
,
api_url:
kubernetes_service_template
.
api_url
,
token:
kubernetes_service_template
.
token
,
ca_pem:
kubernetes_service_template
.
ca_pem
)
end
end
end
end
context
'when KubernetesService does not exist
'
do
it
'migrates the KubernetesService to Platform::Kubernetes without template
'
do
it
'does not migrate the KubernetesService'
do
expect
{
migrate!
}.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
sample_num
)
projects
.
each
do
|
project
|
project
.
clusters
.
last
.
tap
do
|
cluster
|
expect
(
cluster
.
platform_kubernetes
.
api_url
).
to
eq
(
project
.
kubernetes_service
.
api_url
)
expect
(
cluster
.
platform_kubernetes
.
ca_pem
).
to
eq
(
project
.
kubernetes_service
.
ca_pem
)
expect
(
cluster
.
platform_kubernetes
.
token
).
to
eq
(
project
.
kubernetes_service
.
token
)
expect
(
project
.
kubernetes_service
).
not_to
be_active
expect
(
project
.
kubernetes_service
.
properties
[
'migrated'
]).
to
be_truthy
end
end
end
end
end
end
# context 'when user configured kubernetes from CI/CD > Clusters' do
context
'when synced KubernetesService exists'
do
# let(:project) { create(:project) }
let
(
:project
)
{
create
(
:project
)
}
# let(:user) { create(:user) }
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let!
(
:platform_kubernetes
)
{
cluster
.
platform_kubernetes
}
# # Platforms::Kubernetes (New archtecture)
# let!(:cluster) do
# create(:cluster,
# projects: [project],
# user: user,
# provider_type: :gcp,
# platform_type: :kubernetes,
# provider_gcp: provider_gcp,
# platform_kubernetes: platform_kubernetes)
# end
# let(:provider_gcp) { create(:cluster_provider_gcp, :created) }
# let(:platform_kubernetes) { create(:cluster_platform_kubernetes, :configured) }
# # KubernetesService (Automatically synchronized when Platforms::Kubernetes created)
# let!(:kubernetes_service) { create(:kubernetes_service, project: project) }
# context 'when user is using the cluster' do
# it 'migrates' do
# expect{ migrate! }.not_to change { Clusters::Cluster.count }
# expect(cluster).to be_active
# expect(kubernetes_service).not_to be_active
# end
# end
# context 'when user disabled cluster' do
# before do
# disable_cluster!
# end
# context 'when user configured kubernetes from Integration > Kubernetes' do
# before do
# kubernetes_service.update(
# active: true,
# api_url: 'http://new.kube.com',
# ca_pem: nil,
# token: 'z' * 40).reload
# end
# context 'when user is using the kubernetes service' do
# it 'migrates' do
# expect{ migrate! }.to change { Clusters::Cluster.count }.by(1)
# Clusters::Cluster.last.tap do |c|
# expect(c).to be_active
# expect(c.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
# expect(c.platform_kubernetes.ca_pem).to eq(kubernetes_service.ca_pem)
# expect(c.platform_kubernetes.token).to eq(kubernetes_service.token)
# end
# expect(kubernetes_service).not_to be_active
# end
# end
# context 'when user stopped using the kubernetes service' do
# before do
# kubernetes_service.update(active: false)
# end
# it 'migrates' do
# expect{ migrate! }.to change { Clusters::Cluster.count }.by(1)
# Clusters::Cluster.last.tap do |c|
# expect(c).not_to be_active
# expect(c.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
# expect(c.platform_kubernetes.ca_pem).to eq(kubernetes_service.ca_pem)
# expect(c.platform_kubernetes.token).to eq(kubernetes_service.token)
# end
# expect(kubernetes_service).not_to be_active
# end
# end
# end
# end
# context 'when user deleted cluster' do
# before do
# destory_cluster!
# end
# context 'when user configured kubernetes from Integration > Kubernetes' do
# let!(:new_kubernetes_service) do
# project.create_kubernetes_service(
# active: true,
# api_url: 'http://123.123.123.123',
# ca_pem: nil,
# token: 'a' * 40)
# end
# context 'when user is using the kubernetes service' do
# it 'migrates' do
# expect{ migrate! }.to change { Clusters::Cluster.count }.by(1)
# Clusters::Cluster.last.tap do |c|
# expect(c).to be_active
# expect(c.platform_kubernetes.api_url).to eq(new_kubernetes_service.api_url)
# expect(c.platform_kubernetes.ca_pem).to eq(new_kubernetes_service.ca_pem)
# expect(c.platform_kubernetes.token).to eq(new_kubernetes_service.token)
# end
# expect(new_kubernetes_service).not_to be_active
# end
# end
# context 'when user stopped using the kubernetes service' do
# before do
# new_kubernetes_service.update(active: false)
# end
# it 'migrates' do
# expect{ migrate! }.to change { Clusters::Cluster.count }.by(1)
# Clusters::Cluster.last.tap do |c|
# expect(c).not_to be_active
# expect(c.platform_kubernetes.api_url).to eq(new_kubernetes_service.api_url)
# expect(c.platform_kubernetes.ca_pem).to eq(new_kubernetes_service.ca_pem)
# expect(c.platform_kubernetes.token).to eq(new_kubernetes_service.token)
# end
# expect(new_kubernetes_service).not_to be_active
# end
# end
# end
# end
# end
# context 'when user configured kubernetes from Integration > Kubernetes' do
# let(:project) { create(:project) }
# let!(:kubernetes_service) { create(:kubernetes_service, project: project) }
# context 'when user is using the kubernetes service' do
# it 'migrates' do
# expect{ migrate! }.to change { Clusters::Cluster.count }.by(1)
# Clusters::Cluster.last.tap do |c|
# expect(c).to be_active
# expect(c.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
# expect(c.platform_kubernetes.ca_pem).to eq(kubernetes_service.ca_pem)
# expect(c.platform_kubernetes.token).to eq(kubernetes_service.token)
# end
# expect(kubernetes_service).not_to be_active
# end
# end
# context 'when user stopped using the kubernetes service' do
# before do
# kubernetes_service.update(active: false)
# end
# it 'migrates' do
# expect{ migrate! }.to change { Clusters::Cluster.count }.by(1)
# Clusters::Cluster.last.tap do |c|
let!
(
:kubernetes_service
)
do
# expect(c).not_to be_active
create
(
:kubernetes_service
,
# expect(c.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
project:
project
,
# expect(c.platform_kubernetes.ca_pem).to eq(kubernetes_service.ca_pem)
active:
cluster
.
enabled
,
# expect(c.platform_kubernetes.token).to eq(kubernetes_service.token)
api_url:
platform_kubernetes
.
api_url
,
# end
token:
platform_kubernetes
.
token
,
ca_pem:
platform_kubernetes
.
ca_cert
)
end
# expect(kubernetes_service).not_to be_active
it
'does not migrate the KubernetesService'
do
# Because the corresponding Platform::Kubernetes already exists
# end
expect
{
migrate!
}.
not_to
change
{
Clusters
::
Cluster
.
count
}
# end
# end
# context 'when nothing is configured' do
expect
(
kubernetes_service
).
to
be_active
# it 'migrates' do
expect
(
kubernetes_service
.
properties
[
'migrated'
]).
to
be_falsy
# expect{ migrate! }.not_to change { Clusters::Cluster.count }
end
# end
end
# end
# def disable_cluster!
context
'when KubernetesService does not exist'
do
# cluster.update!(enabled: false)
let!
(
:project
)
{
create
(
:project
)
}
# kubernetes_service.update!(active: false)
# end
# def destory_cluster!
it
'does not migrate the KubernetesService'
do
# cluster.destroy!
expect
{
migrate!
}.
not_to
change
{
Clusters
::
Cluster
.
count
}
# kubernetes_service.destroy!
end
#
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