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
d80c3719
Commit
d80c3719
authored
May 10, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport KubernetesHelper deployment related changes
parent
3fba8c37
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
3 deletions
+66
-3
spec/support/helpers/kubernetes_helpers.rb
spec/support/helpers/kubernetes_helpers.rb
+66
-3
No files found.
spec/support/helpers/kubernetes_helpers.rb
View file @
d80c3719
...
@@ -9,8 +9,13 @@ module KubernetesHelpers
...
@@ -9,8 +9,13 @@ module KubernetesHelpers
kube_response
(
kube_pods_body
)
kube_response
(
kube_pods_body
)
end
end
def
kube_deployments_response
kube_response
(
kube_deployments_body
)
end
def
stub_kubeclient_discover
(
api_url
)
def
stub_kubeclient_discover
(
api_url
)
WebMock
.
stub_request
(
:get
,
api_url
+
'/api/v1'
).
to_return
(
kube_response
(
kube_v1_discovery_body
))
WebMock
.
stub_request
(
:get
,
api_url
+
'/api/v1'
).
to_return
(
kube_response
(
kube_v1_discovery_body
))
WebMock
.
stub_request
(
:get
,
api_url
+
'/apis/extensions/v1beta1'
).
to_return
(
kube_response
(
kube_v1beta1_discovery_body
))
end
end
def
stub_kubeclient_pods
(
response
=
nil
)
def
stub_kubeclient_pods
(
response
=
nil
)
...
@@ -20,6 +25,13 @@ module KubernetesHelpers
...
@@ -20,6 +25,13 @@ module KubernetesHelpers
WebMock
.
stub_request
(
:get
,
pods_url
).
to_return
(
response
||
kube_pods_response
)
WebMock
.
stub_request
(
:get
,
pods_url
).
to_return
(
response
||
kube_pods_response
)
end
end
def
stub_kubeclient_deployments
(
response
=
nil
)
stub_kubeclient_discover
(
service
.
api_url
)
deployments_url
=
service
.
api_url
+
"/apis/extensions/v1beta1/namespaces/
#{
service
.
actual_namespace
}
/deployments"
WebMock
.
stub_request
(
:get
,
deployments_url
).
to_return
(
response
||
kube_deployments_response
)
end
def
stub_kubeclient_get_secrets
(
api_url
,
**
options
)
def
stub_kubeclient_get_secrets
(
api_url
,
**
options
)
WebMock
.
stub_request
(
:get
,
api_url
+
'/api/v1/secrets'
)
WebMock
.
stub_request
(
:get
,
api_url
+
'/api/v1/secrets'
)
.
to_return
(
kube_response
(
kube_v1_secrets_body
(
options
)))
.
to_return
(
kube_response
(
kube_v1_secrets_body
(
options
)))
...
@@ -53,6 +65,18 @@ module KubernetesHelpers
...
@@ -53,6 +65,18 @@ module KubernetesHelpers
"kind"
=>
"APIResourceList"
,
"kind"
=>
"APIResourceList"
,
"resources"
=>
[
"resources"
=>
[
{
"name"
=>
"pods"
,
"namespaced"
=>
true
,
"kind"
=>
"Pod"
},
{
"name"
=>
"pods"
,
"namespaced"
=>
true
,
"kind"
=>
"Pod"
},
{
"name"
=>
"deployments"
,
"namespaced"
=>
true
,
"kind"
=>
"Deployment"
},
{
"name"
=>
"secrets"
,
"namespaced"
=>
true
,
"kind"
=>
"Secret"
}
]
}
end
def
kube_v1beta1_discovery_body
{
"kind"
=>
"APIResourceList"
,
"resources"
=>
[
{
"name"
=>
"pods"
,
"namespaced"
=>
true
,
"kind"
=>
"Pod"
},
{
"name"
=>
"deployments"
,
"namespaced"
=>
true
,
"kind"
=>
"Deployment"
},
{
"name"
=>
"secrets"
,
"namespaced"
=>
true
,
"kind"
=>
"Secret"
}
{
"name"
=>
"secrets"
,
"namespaced"
=>
true
,
"kind"
=>
"Secret"
}
]
]
}
}
...
@@ -65,14 +89,25 @@ module KubernetesHelpers
...
@@ -65,14 +89,25 @@ module KubernetesHelpers
}
}
end
end
def
kube_deployments_body
{
"kind"
=>
"DeploymentList"
,
"items"
=>
[
kube_deployment
]
}
end
# This is a partial response, it will have many more elements in reality but
# This is a partial response, it will have many more elements in reality but
# these are the ones we care about at the moment
# these are the ones we care about at the moment
def
kube_pod
(
name:
"kube-pod"
,
app:
"valid-pod-label"
)
def
kube_pod
(
name:
"kube-pod"
,
app:
"valid-pod-label"
,
status:
"Running"
,
track:
nil
)
{
{
"metadata"
=>
{
"metadata"
=>
{
"name"
=>
name
,
"name"
=>
name
,
"generate_name"
=>
"generated-name-with-suffix"
,
"creationTimestamp"
=>
"2016-11-25T19:55:19Z"
,
"creationTimestamp"
=>
"2016-11-25T19:55:19Z"
,
"labels"
=>
{
"app"
=>
app
}
"labels"
=>
{
"app"
=>
app
,
"track"
=>
track
}
},
},
"spec"
=>
{
"spec"
=>
{
"containers"
=>
[
"containers"
=>
[
...
@@ -80,7 +115,27 @@ module KubernetesHelpers
...
@@ -80,7 +115,27 @@ module KubernetesHelpers
{
"name"
=>
"container-1"
}
{
"name"
=>
"container-1"
}
]
]
},
},
"status"
=>
{
"phase"
=>
"Running"
}
"status"
=>
{
"phase"
=>
status
}
}
end
def
kube_deployment
(
name:
"kube-deployment"
,
app:
"valid-deployment-label"
,
track:
nil
)
{
"metadata"
=>
{
"name"
=>
name
,
"generation"
=>
4
,
"labels"
=>
{
"app"
=>
app
,
"track"
=>
track
}.
compact
},
"spec"
=>
{
"replicas"
=>
3
},
"status"
=>
{
"observedGeneration"
=>
4
,
"replicas"
=>
3
,
"updatedReplicas"
=>
3
,
"availableReplicas"
=>
3
}
}
}
end
end
...
@@ -101,4 +156,12 @@ module KubernetesHelpers
...
@@ -101,4 +156,12 @@ module KubernetesHelpers
terminal
terminal
end
end
end
end
def
kube_deployment_rollout_status
::
Gitlab
::
Kubernetes
::
RolloutStatus
.
from_deployments
(
kube_deployment
)
end
def
empty_deployment_rollout_status
::
Gitlab
::
Kubernetes
::
RolloutStatus
.
from_deployments
()
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