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
dc24b4ab
Commit
dc24b4ab
authored
Oct 23, 2019
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test retrieval of Knative 0.7 functions separately
Because some of the metadata is different from Knative 0.6
parent
a2530493
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
2 deletions
+87
-2
spec/controllers/projects/serverless/functions_controller_spec.rb
...trollers/projects/serverless/functions_controller_spec.rb
+34
-2
spec/support/helpers/kubernetes_helpers.rb
spec/support/helpers/kubernetes_helpers.rb
+53
-0
No files found.
spec/controllers/projects/serverless/functions_controller_spec.rb
View file @
dc24b4ab
...
...
@@ -139,7 +139,7 @@ describe Projects::Serverless::FunctionsController do
include_examples
'GET #show with valid data'
end
context
'on Knative 0.6
or 0.7
'
do
context
'on Knative 0.6'
do
before
do
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
...
...
@@ -152,6 +152,14 @@ describe Projects::Serverless::FunctionsController do
include_examples
'GET #show with valid data'
end
context
'on Knative 0.7'
do
before
do
prepare_knative_stubs
(
'0.7.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
include_examples
'GET #show with valid data'
end
end
end
...
...
@@ -207,7 +215,7 @@ describe Projects::Serverless::FunctionsController do
include_examples
'GET #index with data'
end
context
'on Knative 0.6
or 0.7
'
do
context
'on Knative 0.6'
do
before
do
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
...
...
@@ -220,5 +228,29 @@ describe Projects::Serverless::FunctionsController do
include_examples
'GET #index with data'
end
context
'on Knative 0.7'
do
before
do
prepare_knative_stubs
(
'0.7.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
include_examples
'GET #index with data'
end
end
def
prepare_knative_stubs
(
version
,
options
)
knative_service
=
case
version
when
'0.7.0'
knative_07_service
(
options
)
end
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
{
services:
[
knative_service
],
pods:
kube_knative_pods_body
(
cluster
.
project
.
name
,
namespace
.
namespace
)[
"items"
]
},
*
knative_services_finder
.
cache_args
)
end
end
spec/support/helpers/kubernetes_helpers.rb
View file @
dc24b4ab
...
...
@@ -421,6 +421,59 @@ module KubernetesHelpers
}
end
# noinspection RubyStringKeysInHashInspection
def
knative_07_service
(
name:
'kubetest'
,
namespace:
'default'
,
domain:
'example.com'
,
description:
'a knative service'
)
{
"apiVersion"
=>
"serving.knative.dev/v1alpha1"
,
"kind"
=>
"Service"
,
"metadata"
=>
{
"annotations"
=>
{
"serving.knative.dev/creator"
=>
"system:serviceaccount:
#{
namespace
}
:
#{
namespace
}
-service-account"
,
"serving.knative.dev/lastModifier"
=>
"system:serviceaccount:
#{
namespace
}
:
#{
namespace
}
-service-account"
},
"creationTimestamp"
=>
"2019-10-22T21:19:13Z"
,
"generation"
=>
1
,
"labels"
=>
{
"service"
=>
name
},
"name"
=>
name
,
"namespace"
=>
namespace
,
"resourceVersion"
=>
"289726"
,
"selfLink"
=>
"/apis/serving.knative.dev/v1alpha1/namespaces/
#{
namespace
}
/services/
#{
name
}
"
,
"uid"
=>
"988349fa-f511-11e9-9ea1-42010a80005e"
},
"spec"
=>
{
"template"
=>
{
"metadata"
=>
{
"annotations"
=>
{
"Description"
=>
description
},
"creationTimestamp"
=>
"2019-10-22T21:19:12Z"
,
"labels"
=>
{
"service"
=>
name
}
},
"spec"
=>
{
"containers"
=>
[
{
"env"
=>
[{
"name"
=>
"timestamp"
,
"value"
=>
"2019-10-22 21:19:12"
}],
"image"
=>
"image_name"
,
"name"
=>
"user-container"
,
"resources"
=>
{}
}
],
"timeoutSeconds"
=>
300
}
},
"traffic"
=>
[{
"latestRevision"
=>
true
,
"percent"
=>
100
}]
},
"status"
=>
{
"address"
=>
{
"url"
=>
"http://
#{
name
}
.
#{
namespace
}
.svc.cluster.local"
},
"conditions"
=>
[{
"lastTransitionTime"
=>
"2019-10-22T21:20:15Z"
,
"status"
=>
"True"
,
"type"
=>
"ConfigurationsReady"
},
{
"lastTransitionTime"
=>
"2019-10-22T21:20:15Z"
,
"status"
=>
"True"
,
"type"
=>
"Ready"
},
{
"lastTransitionTime"
=>
"2019-10-22T21:20:15Z"
,
"status"
=>
"True"
,
"type"
=>
"RoutesReady"
}],
"latestCreatedRevisionName"
=>
"
#{
name
}
-92tsj"
,
"latestReadyRevisionName"
=>
"
#{
name
}
-92tsj"
,
"observedGeneration"
=>
1
,
"traffic"
=>
[{
"latestRevision"
=>
true
,
"percent"
=>
100
,
"revisionName"
=>
"
#{
name
}
-92tsj"
}],
"url"
=>
"http://
#{
name
}
.
#{
namespace
}
.
#{
domain
}
"
},
"environment_scope"
=>
"production"
,
"cluster_id"
=>
5
,
"podcount"
=>
0
}
end
def
knative_05_service
(
name:
"kubetest"
,
namespace:
"default"
,
domain:
"example.com"
)
{
"metadata"
=>
{
...
...
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