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
a99ad59e
Commit
a99ad59e
authored
Nov 06, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 10.3 comments (Tracked by a tech debts issue). Refactor spec factory name. Use ArgumentError
parent
377916ed
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
37 additions
and
207 deletions
+37
-207
app/models/clusters/providers/gcp.rb
app/models/clusters/providers/gcp.rb
+1
-1
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+0
-81
spec/factories/clusters/cluster.rb
spec/factories/clusters/cluster.rb
+4
-4
spec/factories/clusters/platforms/kubernetes.rb
spec/factories/clusters/platforms/kubernetes.rb
+1
-1
spec/factories/clusters/providers/gcp.rb
spec/factories/clusters/providers/gcp.rb
+1
-1
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+10
-10
spec/models/clusters/providers/gcp_spec.rb
spec/models/clusters/providers/gcp_spec.rb
+12
-12
spec/serializers/cluster_entity_spec.rb
spec/serializers/cluster_entity_spec.rb
+2
-2
spec/serializers/cluster_serializer_spec.rb
spec/serializers/cluster_serializer_spec.rb
+1
-1
spec/services/clusters/create_service_spec.rb
spec/services/clusters/create_service_spec.rb
+0
-53
spec/services/clusters/gcp/fetch_operation_service_spec.rb
spec/services/clusters/gcp/fetch_operation_service_spec.rb
+1
-1
spec/services/clusters/gcp/provision_service_spec.rb
spec/services/clusters/gcp/provision_service_spec.rb
+1
-1
spec/services/clusters/gcp/verify_provision_status_service_spec.rb
...ices/clusters/gcp/verify_provision_status_service_spec.rb
+1
-1
spec/support/google_api/cloud_platform_helpers.rb
spec/support/google_api/cloud_platform_helpers.rb
+0
-36
spec/workers/cluster_provision_worker_spec.rb
spec/workers/cluster_provision_worker_spec.rb
+1
-1
spec/workers/wait_for_cluster_creation_worker_spec.rb
spec/workers/wait_for_cluster_creation_worker_spec.rb
+1
-1
No files found.
app/models/clusters/providers/gcp.rb
View file @
a99ad59e
...
@@ -55,7 +55,7 @@ module Clusters
...
@@ -55,7 +55,7 @@ module Clusters
before_transition
any
=>
[
:creating
]
do
|
provider
,
transition
|
before_transition
any
=>
[
:creating
]
do
|
provider
,
transition
|
operation_id
=
transition
.
args
.
first
operation_id
=
transition
.
args
.
first
raise
'operation_id is required'
unless
operation_id
raise
ArgumentError
.
new
(
'operation_id is required'
)
unless
operation_id
.
present?
provider
.
operation_id
=
operation_id
provider
.
operation_id
=
operation_id
end
end
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
a99ad59e
...
@@ -200,51 +200,6 @@ describe Projects::ClustersController do
...
@@ -200,51 +200,6 @@ describe Projects::ClustersController do
expect
(
response
).
to
redirect_to
(
project_cluster_path
(
project
,
project
.
cluster
))
expect
(
response
).
to
redirect_to
(
project_cluster_path
(
project
,
project
.
cluster
))
end
end
end
end
# TODO: Activate in 10.3
# context 'when adds a cluster manually' do
# let(:params) do
# {
# cluster: {
# name: 'new-cluster',
# platform_type: :kubernetes,
# provider_type: :user,
# platform_kubernetes_attributes: {
# namespace: 'custom-namespace',
# api_url: 'https://111.111.111.111',
# token: 'token'
# }
# }
# }
# end
# it 'creates a new cluster' do
# expect(ClusterProvisionWorker).to receive(:perform_async)
# expect { go }.to change { Clusters::Cluster.count }
# expect(response).to redirect_to(project_cluster_path(project, project.cluster))
# end
# end
# TODO: We should fix this in 10.2
# Maybe
# - validates :provider_gcp, presence: true, if: :gcp?
# - validates :provider_type, presence: true
# are required in Clusters::Cluster
# context 'when not all required parameters are set' do
# let(:params) do
# {
# cluster: {
# name: 'new-cluster'
# }
# }
# end
# it 'shows an error message' do
# expect { go }.not_to change { Clusters::Cluster.count }
# expect(assigns(:cluster).errors).not_to be_empty
# expect(response).to render_template(:new)
# end
# end
end
end
context
'when access token is expired'
do
context
'when access token is expired'
do
...
@@ -397,42 +352,6 @@ describe Projects::ClustersController do
...
@@ -397,42 +352,6 @@ describe Projects::ClustersController do
end
end
end
end
end
end
# TODO: Activate in 10.3
# context 'when update namespace' do
# let(:namespace) { 'namespace-123' }
# let(:params) do
# {
# cluster: {
# platform_kubernetes_attributes: {
# namespace: namespace
# }
# }
# }
# end
# it "updates and redirects back to show page" do
# go
# cluster.reload
# expect(response).to redirect_to(project_cluster_path(project, project.cluster))
# expect(flash[:notice]).to eq('Cluster was successfully updated.')
# expect(cluster.platform.namespace).to eq(namespace)
# end
# context 'when namespace is invalid' do
# let(:namespace) { 'my Namespace 321321321 #' }
# it "rejects changes" do
# go
# expect(response).to have_gitlab_http_status(:ok)
# expect(response).to render_template(:show)
# expect(cluster.platform.namespace).not_to eq(namespace)
# end
# end
# end
end
end
describe
'security'
do
describe
'security'
do
...
...
spec/factories/clusters/cluster.rb
View file @
a99ad59e
...
@@ -14,7 +14,7 @@ FactoryGirl.define do
...
@@ -14,7 +14,7 @@ FactoryGirl.define do
platform_type
:kubernetes
platform_type
:kubernetes
platform_kubernetes
do
platform_kubernetes
do
create
(
:platform_kubernetes
,
:configured
)
create
(
:
cluster_
platform_kubernetes
,
:configured
)
end
end
end
end
...
@@ -23,8 +23,8 @@ FactoryGirl.define do
...
@@ -23,8 +23,8 @@ FactoryGirl.define do
platform_type
:kubernetes
platform_type
:kubernetes
before
(
:create
)
do
|
cluster
,
evaluator
|
before
(
:create
)
do
|
cluster
,
evaluator
|
cluster
.
platform_kubernetes
=
build
(
:platform_kubernetes
,
:configured
)
cluster
.
platform_kubernetes
=
build
(
:
cluster_
platform_kubernetes
,
:configured
)
cluster
.
provider_gcp
=
build
(
:provider_gcp
,
:created
)
cluster
.
provider_gcp
=
build
(
:
cluster_
provider_gcp
,
:created
)
end
end
end
end
...
@@ -32,7 +32,7 @@ FactoryGirl.define do
...
@@ -32,7 +32,7 @@ FactoryGirl.define do
provider_type
:gcp
provider_type
:gcp
provider_gcp
do
provider_gcp
do
create
(
:provider_gcp
,
:creating
)
create
(
:
cluster_
provider_gcp
,
:creating
)
end
end
end
end
end
end
...
...
spec/factories/clusters/platforms/kubernetes.rb
View file @
a99ad59e
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:platform_kubernetes
,
class:
Clusters
::
Platforms
::
Kubernetes
do
factory
:
cluster_
platform_kubernetes
,
class:
Clusters
::
Platforms
::
Kubernetes
do
cluster
cluster
namespace
nil
namespace
nil
api_url
'https://kubernetes.example.com'
api_url
'https://kubernetes.example.com'
...
...
spec/factories/clusters/providers/gcp.rb
View file @
a99ad59e
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:provider_gcp
,
class:
Clusters
::
Providers
::
Gcp
do
factory
:
cluster_
provider_gcp
,
class:
Clusters
::
Providers
::
Gcp
do
cluster
cluster
gcp_project_id
'test-gcp-project'
gcp_project_id
'test-gcp-project'
...
...
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
a99ad59e
...
@@ -9,7 +9,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -9,7 +9,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
describe
'before_validation'
do
describe
'before_validation'
do
context
'when namespace includes upper case'
do
context
'when namespace includes upper case'
do
let
(
:kubernetes
)
{
create
(
:platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:kubernetes
)
{
create
(
:
cluster_
platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:namespace
)
{
'ABC'
}
let
(
:namespace
)
{
'ABC'
}
it
'converts to lower case'
do
it
'converts to lower case'
do
...
@@ -22,7 +22,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -22,7 +22,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
subject
{
kubernetes
.
valid?
}
subject
{
kubernetes
.
valid?
}
context
'when validates namespace'
do
context
'when validates namespace'
do
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:kubernetes
)
{
build
(
:
cluster_
platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
context
'when namespace is blank'
do
context
'when namespace is blank'
do
let
(
:namespace
)
{
''
}
let
(
:namespace
)
{
''
}
...
@@ -50,7 +50,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -50,7 +50,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
context
'when validates api_url'
do
context
'when validates api_url'
do
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
)
}
let
(
:kubernetes
)
{
build
(
:
cluster_
platform_kubernetes
,
:configured
)
}
before
do
before
do
kubernetes
.
api_url
=
api_url
kubernetes
.
api_url
=
api_url
...
@@ -76,7 +76,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -76,7 +76,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
context
'when validates token'
do
context
'when validates token'
do
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
)
}
let
(
:kubernetes
)
{
build
(
:
cluster_
platform_kubernetes
,
:configured
)
}
before
do
before
do
kubernetes
.
token
=
token
kubernetes
.
token
=
token
...
@@ -95,8 +95,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -95,8 +95,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
let
(
:enabled
)
{
true
}
let
(
:enabled
)
{
true
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:cluster
)
{
build
(
:cluster
,
provider_type: :gcp
,
platform_type: :kubernetes
,
platform_kubernetes:
platform
,
provider_gcp:
provider
,
enabled:
enabled
,
projects:
[
project
])
}
let
(
:cluster
)
{
build
(
:cluster
,
provider_type: :gcp
,
platform_type: :kubernetes
,
platform_kubernetes:
platform
,
provider_gcp:
provider
,
enabled:
enabled
,
projects:
[
project
])
}
let
(
:platform
)
{
build
(
:platform_kubernetes
,
:configured
)
}
let
(
:platform
)
{
build
(
:
cluster_
platform_kubernetes
,
:configured
)
}
let
(
:provider
)
{
build
(
:provider_gcp
)
}
let
(
:provider
)
{
build
(
:
cluster_
provider_gcp
)
}
let
(
:kubernetes_service
)
{
project
.
kubernetes_service
}
let
(
:kubernetes_service
)
{
project
.
kubernetes_service
}
it
'updates KubernetesService'
do
it
'updates KubernetesService'
do
...
@@ -126,8 +126,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -126,8 +126,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context
'when kubernetes_service has been configured without cluster integration'
do
context
'when kubernetes_service has been configured without cluster integration'
do
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:project
)
{
create
(
:project
)
}
let
(
:cluster
)
{
build
(
:cluster
,
provider_type: :gcp
,
platform_type: :kubernetes
,
platform_kubernetes:
platform
,
provider_gcp:
provider
,
projects:
[
project
])
}
let
(
:cluster
)
{
build
(
:cluster
,
provider_type: :gcp
,
platform_type: :kubernetes
,
platform_kubernetes:
platform
,
provider_gcp:
provider
,
projects:
[
project
])
}
let
(
:platform
)
{
build
(
:platform_kubernetes
,
:configured
,
api_url:
'https://111.111.111.111'
)
}
let
(
:platform
)
{
build
(
:
cluster_
platform_kubernetes
,
:configured
,
api_url:
'https://111.111.111.111'
)
}
let
(
:provider
)
{
build
(
:provider_gcp
)
}
let
(
:provider
)
{
build
(
:
cluster_
provider_gcp
)
}
before
do
before
do
create
(
:kubernetes_service
,
project:
project
)
create
(
:kubernetes_service
,
project:
project
)
...
@@ -144,7 +144,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -144,7 +144,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
platform_kubernetes:
kubernetes
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
platform_kubernetes:
kubernetes
)
}
let
(
:project
)
{
cluster
.
project
}
let
(
:project
)
{
cluster
.
project
}
let
(
:kubernetes
)
{
create
(
:platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:kubernetes
)
{
create
(
:
cluster_
platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
context
'when namespace is present'
do
context
'when namespace is present'
do
let
(
:namespace
)
{
'namespace-123'
}
let
(
:namespace
)
{
'namespace-123'
}
...
@@ -170,7 +170,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -170,7 +170,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
describe
'#default_namespace'
do
describe
'#default_namespace'
do
subject
{
kubernetes
.
default_namespace
}
subject
{
kubernetes
.
default_namespace
}
let
(
:kubernetes
)
{
create
(
:platform_kubernetes
,
:configured
)
}
let
(
:kubernetes
)
{
create
(
:
cluster_
platform_kubernetes
,
:configured
)
}
context
'when cluster belongs to a project'
do
context
'when cluster belongs to a project'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
platform_kubernetes:
kubernetes
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:project
,
platform_kubernetes:
kubernetes
)
}
...
...
spec/models/clusters/providers/gcp_spec.rb
View file @
a99ad59e
...
@@ -5,7 +5,7 @@ describe Clusters::Providers::Gcp do
...
@@ -5,7 +5,7 @@ describe Clusters::Providers::Gcp do
it
{
is_expected
.
to
validate_presence_of
(
:zone
)
}
it
{
is_expected
.
to
validate_presence_of
(
:zone
)
}
describe
'default_value_for'
do
describe
'default_value_for'
do
let
(
:gcp
)
{
build
(
:provider_gcp
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
)
}
it
"has default value"
do
it
"has default value"
do
expect
(
gcp
.
zone
).
to
eq
(
'us-central1-a'
)
expect
(
gcp
.
zone
).
to
eq
(
'us-central1-a'
)
...
@@ -18,7 +18,7 @@ describe Clusters::Providers::Gcp do
...
@@ -18,7 +18,7 @@ describe Clusters::Providers::Gcp do
subject
{
gcp
.
valid?
}
subject
{
gcp
.
valid?
}
context
'when validates gcp_project_id'
do
context
'when validates gcp_project_id'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
gcp_project_id:
gcp_project_id
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
gcp_project_id:
gcp_project_id
)
}
context
'when gcp_project_id is shorter than 1'
do
context
'when gcp_project_id is shorter than 1'
do
let
(
:gcp_project_id
)
{
''
}
let
(
:gcp_project_id
)
{
''
}
...
@@ -46,7 +46,7 @@ describe Clusters::Providers::Gcp do
...
@@ -46,7 +46,7 @@ describe Clusters::Providers::Gcp do
end
end
context
'when validates num_nodes'
do
context
'when validates num_nodes'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
num_nodes:
num_nodes
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
num_nodes:
num_nodes
)
}
context
'when num_nodes is string'
do
context
'when num_nodes is string'
do
let
(
:num_nodes
)
{
'A3'
}
let
(
:num_nodes
)
{
'A3'
}
...
@@ -76,7 +76,7 @@ describe Clusters::Providers::Gcp do
...
@@ -76,7 +76,7 @@ describe Clusters::Providers::Gcp do
describe
'#state_machine'
do
describe
'#state_machine'
do
context
'when any => [:created]'
do
context
'when any => [:created]'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
:creating
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
:creating
)
}
before
do
before
do
gcp
.
make_created
gcp
.
make_created
...
@@ -90,7 +90,7 @@ describe Clusters::Providers::Gcp do
...
@@ -90,7 +90,7 @@ describe Clusters::Providers::Gcp do
end
end
context
'when any => [:creating]'
do
context
'when any => [:creating]'
do
let
(
:gcp
)
{
build
(
:provider_gcp
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
)
}
context
'when operation_id is present'
do
context
'when operation_id is present'
do
let
(
:operation_id
)
{
'operation-xxx'
}
let
(
:operation_id
)
{
'operation-xxx'
}
...
@@ -116,7 +116,7 @@ describe Clusters::Providers::Gcp do
...
@@ -116,7 +116,7 @@ describe Clusters::Providers::Gcp do
end
end
context
'when any => [:errored]'
do
context
'when any => [:errored]'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
:creating
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
:creating
)
}
let
(
:status_reason
)
{
'err msg'
}
let
(
:status_reason
)
{
'err msg'
}
it
'nullify access_token and operation_id'
do
it
'nullify access_token and operation_id'
do
...
@@ -129,7 +129,7 @@ describe Clusters::Providers::Gcp do
...
@@ -129,7 +129,7 @@ describe Clusters::Providers::Gcp do
end
end
context
'when status_reason is nil'
do
context
'when status_reason is nil'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
:errored
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
:errored
)
}
it
'does not set status_reason'
do
it
'does not set status_reason'
do
gcp
.
make_errored
(
nil
)
gcp
.
make_errored
(
nil
)
...
@@ -144,13 +144,13 @@ describe Clusters::Providers::Gcp do
...
@@ -144,13 +144,13 @@ describe Clusters::Providers::Gcp do
subject
{
gcp
.
on_creation?
}
subject
{
gcp
.
on_creation?
}
context
'when status is creating'
do
context
'when status is creating'
do
let
(
:gcp
)
{
create
(
:provider_gcp
,
:creating
)
}
let
(
:gcp
)
{
create
(
:
cluster_
provider_gcp
,
:creating
)
}
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
end
end
context
'when status is created'
do
context
'when status is created'
do
let
(
:gcp
)
{
create
(
:provider_gcp
,
:created
)
}
let
(
:gcp
)
{
create
(
:
cluster_
provider_gcp
,
:created
)
}
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
end
end
...
@@ -160,7 +160,7 @@ describe Clusters::Providers::Gcp do
...
@@ -160,7 +160,7 @@ describe Clusters::Providers::Gcp do
subject
{
gcp
.
api_client
}
subject
{
gcp
.
api_client
}
context
'when status is creating'
do
context
'when status is creating'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
:creating
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
:creating
)
}
it
'returns Cloud Platform API clinet'
do
it
'returns Cloud Platform API clinet'
do
expect
(
subject
).
to
be_an_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
expect
(
subject
).
to
be_an_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
...
@@ -169,13 +169,13 @@ describe Clusters::Providers::Gcp do
...
@@ -169,13 +169,13 @@ describe Clusters::Providers::Gcp do
end
end
context
'when status is created'
do
context
'when status is created'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
:created
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
:created
)
}
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
end
end
context
'when status is errored'
do
context
'when status is errored'
do
let
(
:gcp
)
{
build
(
:provider_gcp
,
:errored
)
}
let
(
:gcp
)
{
build
(
:
cluster_
provider_gcp
,
:errored
)
}
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
end
end
...
...
spec/serializers/cluster_entity_spec.rb
View file @
a99ad59e
...
@@ -8,7 +8,7 @@ describe ClusterEntity do
...
@@ -8,7 +8,7 @@ describe ClusterEntity do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
context
'when status is creating'
do
context
'when status is creating'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:creating
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:creating
)
}
it
'has corresponded data'
do
it
'has corresponded data'
do
expect
(
subject
[
:status
]).
to
eq
(
:creating
)
expect
(
subject
[
:status
]).
to
eq
(
:creating
)
...
@@ -17,7 +17,7 @@ describe ClusterEntity do
...
@@ -17,7 +17,7 @@ describe ClusterEntity do
end
end
context
'when status is errored'
do
context
'when status is errored'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:errored
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:errored
)
}
it
'has corresponded data'
do
it
'has corresponded data'
do
expect
(
subject
[
:status
]).
to
eq
(
:errored
)
expect
(
subject
[
:status
]).
to
eq
(
:errored
)
...
...
spec/serializers/cluster_serializer_spec.rb
View file @
a99ad59e
...
@@ -6,7 +6,7 @@ describe ClusterSerializer do
...
@@ -6,7 +6,7 @@ describe ClusterSerializer do
context
'when provider type is gcp'
do
context
'when provider type is gcp'
do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:provider
)
{
create
(
:provider_gcp
,
:errored
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:errored
)
}
it
'serializes only status'
do
it
'serializes only status'
do
expect
(
subject
.
keys
).
to
contain_exactly
(
:status
,
:status_reason
)
expect
(
subject
.
keys
).
to
contain_exactly
(
:status
,
:status_reason
)
...
...
spec/services/clusters/create_service_spec.rb
View file @
a99ad59e
...
@@ -61,57 +61,4 @@ describe Clusters::CreateService do
...
@@ -61,57 +61,4 @@ describe Clusters::CreateService do
end
end
end
end
end
end
# TODO: This will be active in 10.3
# context 'when provider is user' do
# context 'when correct params' do
# let(:params) do
# {
# name: 'test-cluster',
# platform_type: :kubernetes,
# provider_type: :user,
# platform_kubernetes_attributes: {
# namespace: 'custom-namespace',
# api_url: 'https://111.111.111.111',
# token: 'token'
# }
# }
# end
# it 'creates a cluster object and performs a worker' do
# expect(ClusterProvisionWorker).to receive(:perform_async)
# expect { result }
# .to change { Clusters::Cluster.count }.by(1)
# .and change { Clusters::Platforms::Kubernetes.count }.by(1)
# expect(result.name).to eq('test-cluster')
# expect(result.user).to eq(user)
# expect(result.project).to eq(project)
# expect(result.provider).to be_nil
# expect(result.platform.namespace).to eq('custom-namespace')
# end
# end
# context 'when invalid params' do
# let(:params) do
# {
# name: 'test-cluster',
# platform_type: :kubernetes,
# provider_type: :user,
# platform_kubernetes_attributes: {
# namespace: 'custom-namespace',
# api_url: '!!!!!',
# token: 'token'
# }
# }
# end
# it 'returns an error' do
# # expect(ClusterProvisionWorker).not_to receive(:perform_async)
# expect { result }.to change { Clusters::Cluster.count }.by(0)
# expect(result.errors[:"platform_kubernetes.api_url"]).to be_present
# end
# end
# end
end
end
spec/services/clusters/gcp/fetch_operation_service_spec.rb
View file @
a99ad59e
...
@@ -4,7 +4,7 @@ describe Clusters::Gcp::FetchOperationService do
...
@@ -4,7 +4,7 @@ describe Clusters::Gcp::FetchOperationService do
include
GoogleApi
::
CloudPlatformHelpers
include
GoogleApi
::
CloudPlatformHelpers
describe
'#execute'
do
describe
'#execute'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:creating
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:creating
)
}
let
(
:gcp_project_id
)
{
provider
.
gcp_project_id
}
let
(
:gcp_project_id
)
{
provider
.
gcp_project_id
}
let
(
:zone
)
{
provider
.
zone
}
let
(
:zone
)
{
provider
.
zone
}
let
(
:operation_id
)
{
provider
.
operation_id
}
let
(
:operation_id
)
{
provider
.
operation_id
}
...
...
spec/services/clusters/gcp/provision_service_spec.rb
View file @
a99ad59e
...
@@ -4,7 +4,7 @@ describe Clusters::Gcp::ProvisionService do
...
@@ -4,7 +4,7 @@ describe Clusters::Gcp::ProvisionService do
include
GoogleApi
::
CloudPlatformHelpers
include
GoogleApi
::
CloudPlatformHelpers
describe
'#execute'
do
describe
'#execute'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:scheduled
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:scheduled
)
}
let
(
:gcp_project_id
)
{
provider
.
gcp_project_id
}
let
(
:gcp_project_id
)
{
provider
.
gcp_project_id
}
let
(
:zone
)
{
provider
.
zone
}
let
(
:zone
)
{
provider
.
zone
}
...
...
spec/services/clusters/gcp/verify_provision_status_service_spec.rb
View file @
a99ad59e
...
@@ -4,7 +4,7 @@ describe Clusters::Gcp::VerifyProvisionStatusService do
...
@@ -4,7 +4,7 @@ describe Clusters::Gcp::VerifyProvisionStatusService do
include
GoogleApi
::
CloudPlatformHelpers
include
GoogleApi
::
CloudPlatformHelpers
describe
'#execute'
do
describe
'#execute'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:creating
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:creating
)
}
let
(
:gcp_project_id
)
{
provider
.
gcp_project_id
}
let
(
:gcp_project_id
)
{
provider
.
gcp_project_id
}
let
(
:zone
)
{
provider
.
zone
}
let
(
:zone
)
{
provider
.
zone
}
let
(
:operation_id
)
{
provider
.
operation_id
}
let
(
:operation_id
)
{
provider
.
operation_id
}
...
...
spec/support/google_api/cloud_platform_helpers.rb
View file @
a99ad59e
...
@@ -71,15 +71,9 @@ module GoogleApi
...
@@ -71,15 +71,9 @@ module GoogleApi
"name"
:
options
[
:name
]
||
'string'
,
"name"
:
options
[
:name
]
||
'string'
,
"description"
:
options
[
:description
]
||
'string'
,
"description"
:
options
[
:description
]
||
'string'
,
"initialNodeCount"
:
options
[
:initialNodeCount
]
||
'number'
,
"initialNodeCount"
:
options
[
:initialNodeCount
]
||
'number'
,
# "nodeConfig": {,
# object(NodeConfig),
# },,
"masterAuth"
:
{
"masterAuth"
:
{
"username"
:
options
[
:username
]
||
'string'
,
"username"
:
options
[
:username
]
||
'string'
,
"password"
:
options
[
:password
]
||
'string'
,
"password"
:
options
[
:password
]
||
'string'
,
# "clientCertificateConfig": {
# object(ClientCertificateConfig)
# },
"clusterCaCertificate"
:
options
[
:clusterCaCertificate
]
||
load_sample_cert
,
"clusterCaCertificate"
:
options
[
:clusterCaCertificate
]
||
load_sample_cert
,
"clientCertificate"
:
options
[
:clientCertificate
]
||
'string'
,
"clientCertificate"
:
options
[
:clientCertificate
]
||
'string'
,
"clientKey"
:
options
[
:clientKey
]
||
'string'
"clientKey"
:
options
[
:clientKey
]
||
'string'
...
@@ -88,36 +82,9 @@ module GoogleApi
...
@@ -88,36 +82,9 @@ module GoogleApi
"monitoringService"
:
options
[
:monitoringService
]
||
'string'
,
"monitoringService"
:
options
[
:monitoringService
]
||
'string'
,
"network"
:
options
[
:network
]
||
'string'
,
"network"
:
options
[
:network
]
||
'string'
,
"clusterIpv4Cidr"
:
options
[
:clusterIpv4Cidr
]
||
'string'
,
"clusterIpv4Cidr"
:
options
[
:clusterIpv4Cidr
]
||
'string'
,
# "addonsConfig": {,
# object(AddonsConfig),
# },,
"subnetwork"
:
options
[
:subnetwork
]
||
'string'
,
"subnetwork"
:
options
[
:subnetwork
]
||
'string'
,
# "nodePools": [,
# {,
# object(NodePool),
# },
# ],,
# "locations": [,
# string,
# ],,
"enableKubernetesAlpha"
:
options
[
:enableKubernetesAlpha
]
||
'boolean'
,
"enableKubernetesAlpha"
:
options
[
:enableKubernetesAlpha
]
||
'boolean'
,
# "resourceLabels": {,
# string: string,,
# ...,
# },,
"labelFingerprint"
:
options
[
:labelFingerprint
]
||
'string'
,
"labelFingerprint"
:
options
[
:labelFingerprint
]
||
'string'
,
# "legacyAbac": {,
# object(LegacyAbac),
# },
# "networkPolicy": {,
# object(NetworkPolicy),
# },
# "ipAllocationPolicy": {,
# object(IPAllocationPolicy),
# },
# "masterAuthorizedNetworksConfig": {,
# object(MasterAuthorizedNetworksConfig),
# },
"selfLink"
:
options
[
:selfLink
]
||
'string'
,
"selfLink"
:
options
[
:selfLink
]
||
'string'
,
"zone"
:
options
[
:zone
]
||
'string'
,
"zone"
:
options
[
:zone
]
||
'string'
,
"endpoint"
:
options
[
:endpoint
]
||
'string'
,
"endpoint"
:
options
[
:endpoint
]
||
'string'
,
...
@@ -129,9 +96,6 @@ module GoogleApi
...
@@ -129,9 +96,6 @@ module GoogleApi
"statusMessage"
:
options
[
:statusMessage
]
||
'string'
,
"statusMessage"
:
options
[
:statusMessage
]
||
'string'
,
"nodeIpv4CidrSize"
:
options
[
:nodeIpv4CidrSize
]
||
'number'
,
"nodeIpv4CidrSize"
:
options
[
:nodeIpv4CidrSize
]
||
'number'
,
"servicesIpv4Cidr"
:
options
[
:servicesIpv4Cidr
]
||
'string'
,
"servicesIpv4Cidr"
:
options
[
:servicesIpv4Cidr
]
||
'string'
,
# "instanceGroupUrls": [,
# string,
# ],,
"currentNodeCount"
:
options
[
:currentNodeCount
]
||
'number'
,
"currentNodeCount"
:
options
[
:currentNodeCount
]
||
'number'
,
"expireTime"
:
options
[
:expireTime
]
||
'string'
"expireTime"
:
options
[
:expireTime
]
||
'string'
}
}
...
...
spec/workers/cluster_provision_worker_spec.rb
View file @
a99ad59e
...
@@ -4,7 +4,7 @@ describe ClusterProvisionWorker do
...
@@ -4,7 +4,7 @@ describe ClusterProvisionWorker do
describe
'#perform'
do
describe
'#perform'
do
context
'when provider type is gcp'
do
context
'when provider type is gcp'
do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:provider
)
{
create
(
:provider_gcp
,
:scheduled
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:scheduled
)
}
it
'provision a cluster'
do
it
'provision a cluster'
do
expect_any_instance_of
(
Clusters
::
Gcp
::
ProvisionService
).
to
receive
(
:execute
)
expect_any_instance_of
(
Clusters
::
Gcp
::
ProvisionService
).
to
receive
(
:execute
)
...
...
spec/workers/wait_for_cluster_creation_worker_spec.rb
View file @
a99ad59e
...
@@ -4,7 +4,7 @@ describe WaitForClusterCreationWorker do
...
@@ -4,7 +4,7 @@ describe WaitForClusterCreationWorker do
describe
'#perform'
do
describe
'#perform'
do
context
'when provider type is gcp'
do
context
'when provider type is gcp'
do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:provider
)
{
create
(
:provider_gcp
,
:creating
)
}
let
(
:provider
)
{
create
(
:
cluster_
provider_gcp
,
:creating
)
}
it
'provision a cluster'
do
it
'provision a cluster'
do
expect_any_instance_of
(
Clusters
::
Gcp
::
VerifyProvisionStatusService
).
to
receive
(
:execute
)
expect_any_instance_of
(
Clusters
::
Gcp
::
VerifyProvisionStatusService
).
to
receive
(
:execute
)
...
...
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