Commit dc24b4ab authored by Alishan Ladhani's avatar Alishan Ladhani

Test retrieval of Knative 0.7 functions separately

Because some of the metadata is different from Knative 0.6
parent a2530493
......@@ -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
......@@ -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" => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment