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
8d9d0f94
Commit
8d9d0f94
authored
Oct 04, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create_cluster_service_spec. cluster_provision_worker_spec. cluster_queue_spec.
parent
a644f4b8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
2 deletions
+93
-2
spec/services/ci/create_cluster_service_spec.rb
spec/services/ci/create_cluster_service_spec.rb
+30
-2
spec/workers/cluster_provision_worker_spec.rb
spec/workers/cluster_provision_worker_spec.rb
+23
-0
spec/workers/concerns/cluster_queue_spec.rb
spec/workers/concerns/cluster_queue_spec.rb
+15
-0
spec/workers/wait_for_cluster_creation_worker_spec.rb
spec/workers/wait_for_cluster_creation_worker_spec.rb
+25
-0
No files found.
spec/services/ci/create_cluster_service_spec.rb
View file @
8d9d0f94
...
...
@@ -3,16 +3,44 @@ require 'spec_helper'
describe
Ci
::
CreateClusterService
do
describe
'#execute'
do
let
(
:access_token
)
{
'xxx'
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:result
)
{
described_class
.
new
(
project
,
user
,
params
).
execute
(
access_token
)
}
context
'when correct params'
do
it
'creates a cluster object'
do
let
(
:params
)
do
{
gcp_project_id:
'gcp-project'
,
gcp_cluster_name:
'test-cluster'
,
gcp_cluster_zone:
'us-central1-a'
,
gcp_cluster_size:
1
,
}
end
it
'creates a cluster object'
do
expect
(
ClusterProvisionWorker
).
to
receive
(
:perform_async
)
expect
{
result
}.
to
change
{
Gcp
::
Cluster
.
count
}.
by
(
1
)
expect
(
result
.
gcp_project_id
).
to
eq
(
'gcp-project'
)
expect
(
result
.
gcp_cluster_name
).
to
eq
(
'test-cluster'
)
expect
(
result
.
gcp_cluster_zone
).
to
eq
(
'us-central1-a'
)
expect
(
result
.
gcp_cluster_size
).
to
eq
(
1
)
expect
(
result
.
gcp_token
).
to
eq
(
access_token
)
end
end
context
'when invalid params'
do
it
'returns an error'
do
let
(
:params
)
do
{
gcp_project_id:
'gcp-project'
,
gcp_cluster_name:
'test-cluster'
,
gcp_cluster_zone:
'us-central1-a'
,
gcp_cluster_size:
'ABC'
,
}
end
it
'returns an error'
do
expect
(
ClusterProvisionWorker
).
not_to
receive
(
:perform_async
)
expect
{
result
}.
to
change
{
Gcp
::
Cluster
.
count
}.
by
(
0
)
end
end
end
...
...
spec/workers/cluster_provision_worker_spec.rb
0 → 100644
View file @
8d9d0f94
require
'spec_helper'
describe
ClusterProvisionWorker
do
describe
'#perform'
do
context
'when cluster exists'
do
let
(
:cluster
)
{
create
(
:gcp_cluster
)
}
it
'provision a cluster'
do
expect_any_instance_of
(
Ci
::
ProvisionClusterService
).
to
receive
(
:execute
)
described_class
.
new
.
perform
(
cluster
.
id
)
end
end
context
'when cluster does not exist'
do
it
'does not provision a cluster'
do
expect_any_instance_of
(
Ci
::
ProvisionClusterService
).
not_to
receive
(
:execute
)
described_class
.
new
.
perform
(
123
)
end
end
end
end
spec/workers/concerns/cluster_queue_spec.rb
0 → 100644
View file @
8d9d0f94
require
'spec_helper'
describe
ClusterQueue
do
let
(
:worker
)
do
Class
.
new
do
include
Sidekiq
::
Worker
include
ClusterQueue
end
end
it
'sets a default pipelines queue automatically'
do
expect
(
worker
.
sidekiq_options
[
'queue'
])
.
to
eq
:gcp_cluster
end
end
spec/workers/wait_for_cluster_creation_worker_spec.rb
0 → 100644
View file @
8d9d0f94
require
'spec_helper'
describe
WaitForClusterCreationWorker
do
describe
'#perform'
do
context
'when cluster exists'
do
let
(
:cluster
)
{
create
(
:gcp_cluster
)
}
it
'fetches gcp operation status'
do
expect_any_instance_of
(
Ci
::
FetchGcpOperationService
).
to
receive
(
:execute
)
described_class
.
new
.
perform
(
cluster
.
id
)
end
# TODO: context 'when operation.status is runnning'
end
context
'when cluster does not exist'
do
it
'does not provision a cluster'
do
expect_any_instance_of
(
Ci
::
FetchGcpOperationService
).
to
receive
(
:execute
).
with
(
nil
)
described_class
.
new
.
perform
(
123
)
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