diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-04-30 13:31:47 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-04-30 13:31:47 +0000 |
commit | 56c8b35b8460dac53e6d29c3c811da4e57eca66c (patch) | |
tree | 566efb71c8385a474c8ca08e4401a2782067557e /spec/lib | |
parent | ac2c2be97f1a0647630646ebf1e25f9bb0fb5ac9 (diff) | |
parent | b389ef66d46219abbd671bcdbdfdd2fb142798b8 (diff) | |
download | gitlab-ce-56c8b35b8460dac53e6d29c3c811da4e57eca66c.tar.gz |
Merge branch 'pl-fix-k8s-ns-query-variables' into 'master'
Use correct k8s namespace in Prometheus queries
See merge request gitlab-org/gitlab-ce!27812
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/prometheus/query_variables_spec.rb | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/spec/lib/gitlab/prometheus/query_variables_spec.rb b/spec/lib/gitlab/prometheus/query_variables_spec.rb index 78c74266c61..048f4af6020 100644 --- a/spec/lib/gitlab/prometheus/query_variables_spec.rb +++ b/spec/lib/gitlab/prometheus/query_variables_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::Prometheus::QueryVariables do describe '.call' do + let(:project) { environment.project } let(:environment) { create(:environment) } let(:slug) { environment.slug } @@ -21,13 +22,32 @@ describe Gitlab::Prometheus::QueryVariables do end context 'with deployment platform' do - let(:kube_namespace) { environment.deployment_platform.actual_namespace } + context 'with project cluster' do + let(:kube_namespace) { environment.deployment_platform.actual_namespace } - before do - create(:cluster, :provided_by_user, projects: [environment.project]) + before do + create(:cluster, :project, :provided_by_user, projects: [project]) + end + + it { is_expected.to include(kube_namespace: kube_namespace) } end - it { is_expected.to include(kube_namespace: kube_namespace) } + context 'with group cluster' do + let(:cluster) { create(:cluster, :group, :provided_by_user, groups: [group]) } + let(:group) { create(:group) } + let(:project2) { create(:project) } + let(:kube_namespace) { k8s_ns.namespace } + + let!(:k8s_ns) { create(:cluster_kubernetes_namespace, cluster: cluster, project: project) } + let!(:k8s_ns2) { create(:cluster_kubernetes_namespace, cluster: cluster, project: project2) } + + before do + group.projects << project + group.projects << project2 + end + + it { is_expected.to include(kube_namespace: kube_namespace) } + end end end end |