diff options
author | Nick Thomas <nick@gitlab.com> | 2019-05-22 13:53:30 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-05-22 13:53:30 +0300 |
commit | 9f54fdcc89c71022906cf72074c749c72b2abd58 (patch) | |
tree | 3a18b8baecc9ac41769f1d36bd723c2ecf46597d /spec/support | |
parent | 3846f89d4f9164e16313c11a78bdf9fa3ee2294e (diff) | |
parent | 101c4480b32044682e453753c6bb18c2a296b044 (diff) |
Merge branch '61935-remove-code-left-over-from-when-clusters-were-always-project-specific' into 'master'
remove `Clusters::Platforms::Kubernetes#actual_namespace`
Closes #61935
See merge request gitlab-org/gitlab-ce!28391
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/kubernetes_helpers.rb | 24 | ||||
-rw-r--r-- | spec/support/prometheus/additional_metrics_shared_examples.rb | 2 |
2 files changed, 16 insertions, 10 deletions
diff --git a/spec/support/helpers/kubernetes_helpers.rb b/spec/support/helpers/kubernetes_helpers.rb index ac52acb6570..78b7ae9c00c 100644 --- a/spec/support/helpers/kubernetes_helpers.rb +++ b/spec/support/helpers/kubernetes_helpers.rb @@ -24,30 +24,34 @@ module KubernetesHelpers WebMock.stub_request(:get, api_url + '/apis/serving.knative.dev/v1alpha1').to_return(kube_response(kube_v1alpha1_serving_knative_discovery_body)) end - def stub_kubeclient_service_pods(response = nil) + def stub_kubeclient_service_pods(status: nil) stub_kubeclient_discover(service.api_url) pods_url = service.api_url + "/api/v1/pods" + response = { status: status } if status WebMock.stub_request(:get, pods_url).to_return(response || kube_pods_response) end - def stub_kubeclient_pods(response = nil) + def stub_kubeclient_pods(namespace, status: nil) stub_kubeclient_discover(service.api_url) - pods_url = service.api_url + "/api/v1/namespaces/#{service.actual_namespace}/pods" + pods_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods" + response = { status: status } if status WebMock.stub_request(:get, pods_url).to_return(response || kube_pods_response) end - def stub_kubeclient_logs(pod_name, response = nil) + def stub_kubeclient_logs(pod_name, namespace, status: nil) stub_kubeclient_discover(service.api_url) - logs_url = service.api_url + "/api/v1/namespaces/#{service.actual_namespace}/pods/#{pod_name}/log?tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}" + logs_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod_name}/log?tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}" + response = { status: status } if status WebMock.stub_request(:get, logs_url).to_return(response || kube_logs_response) end - def stub_kubeclient_deployments(response = nil) + def stub_kubeclient_deployments(namespace, status: nil) stub_kubeclient_discover(service.api_url) - deployments_url = service.api_url + "/apis/extensions/v1beta1/namespaces/#{service.actual_namespace}/deployments" + deployments_url = service.api_url + "/apis/extensions/v1beta1/namespaces/#{namespace}/deployments" + response = { status: status } if status WebMock.stub_request(:get, deployments_url).to_return(response || kube_deployments_response) end @@ -250,10 +254,11 @@ module KubernetesHelpers # This is a partial response, it will have many more elements in reality but # these are the ones we care about at the moment - def kube_pod(name: "kube-pod", environment_slug: "production", project_slug: "project-path-slug", status: "Running", track: nil) + def kube_pod(name: "kube-pod", environment_slug: "production", namespace: "project-namespace", project_slug: "project-path-slug", status: "Running", track: nil) { "metadata" => { "name" => name, + "namespace" => namespace, "generate_name" => "generated-name-with-suffix", "creationTimestamp" => "2016-11-25T19:55:19Z", "annotations" => { @@ -369,12 +374,13 @@ module KubernetesHelpers def kube_terminals(service, pod) pod_name = pod['metadata']['name'] + pod_namespace = pod['metadata']['namespace'] containers = pod['spec']['containers'] containers.map do |container| terminal = { selectors: { pod: pod_name, container: container['name'] }, - url: container_exec_url(service.api_url, service.actual_namespace, pod_name, container['name']), + url: container_exec_url(service.api_url, pod_namespace, pod_name, container['name']), subprotocols: ['channel.k8s.io'], headers: { 'Authorization' => ["Bearer #{service.token}"] }, created_at: DateTime.parse(pod['metadata']['creationTimestamp']), diff --git a/spec/support/prometheus/additional_metrics_shared_examples.rb b/spec/support/prometheus/additional_metrics_shared_examples.rb index 0fd67531c3b..8044b061ca5 100644 --- a/spec/support/prometheus/additional_metrics_shared_examples.rb +++ b/spec/support/prometheus/additional_metrics_shared_examples.rb @@ -46,7 +46,7 @@ RSpec.shared_examples 'additional metrics query' do describe 'project has Kubernetes service' do shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do let(:environment) { create(:environment, slug: 'environment-slug', project: project) } - let(:kube_namespace) { project.deployment_platform.actual_namespace } + let(:kube_namespace) { project.deployment_platform.kubernetes_namespace_for(project) } it_behaves_like 'query context containing environment slug and filter' |