Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 00:06:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 00:06:41 +0300
commit08f4ce10c04d705148a7e14556443b9e3aee6821 (patch)
treeba58b29874803db12ebec690fb4416b6208ee750 /spec/support/helpers/kubernetes_helpers.rb
parentb4cdff15ca53312ccbbafe4effac85b1ee4420ae (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers/kubernetes_helpers.rb')
-rw-r--r--spec/support/helpers/kubernetes_helpers.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/support/helpers/kubernetes_helpers.rb b/spec/support/helpers/kubernetes_helpers.rb
index 538a5b8ef3c..36391543768 100644
--- a/spec/support/helpers/kubernetes_helpers.rb
+++ b/spec/support/helpers/kubernetes_helpers.rb
@@ -11,6 +11,10 @@ module KubernetesHelpers
kube_response(kube_pods_body)
end
+ def kube_pod_response
+ kube_response(kube_pod)
+ end
+
def kube_logs_response
kube_response(kube_logs_body)
end
@@ -63,11 +67,30 @@ module KubernetesHelpers
WebMock.stub_request(:get, pods_url).to_return(response || kube_pods_response)
end
- def stub_kubeclient_logs(pod_name, namespace, status: nil)
+ def stub_kubeclient_pod_details(pod, namespace, status: nil)
stub_kubeclient_discover(service.api_url)
- logs_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod_name}/log?tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}"
+
+ pod_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod}"
response = { status: status } if status
+ WebMock.stub_request(:get, pod_url).to_return(response || kube_pod_response)
+ end
+
+ def stub_kubeclient_logs(pod_name, namespace, container: nil, status: nil, message: nil)
+ stub_kubeclient_discover(service.api_url)
+
+ if container
+ container_query_param = "container=#{container}&"
+ end
+
+ logs_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod_name}" \
+ "/log?#{container_query_param}tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}"
+
+ if status
+ response = { status: status }
+ response[:body] = { message: message }.to_json if message
+ end
+
WebMock.stub_request(:get, logs_url).to_return(response || kube_logs_response)
end