Commit a0802dd8 authored by Shinya Maeda's avatar Shinya Maeda

Add EE spec for KubernetesService and Platform::Kubernetes compatibility

parent 582e4014
......@@ -34,7 +34,7 @@ describe Projects::EnvironmentsController do
context 'when requesting JSON response for folders' do
before do
allow_any_instance_of(Environment).to receive(:deployment_service_ready?).and_return(true)
allow_any_instance_of(Environment).to receive(:has_terminals?).and_return(true)
allow_any_instance_of(Environment).to receive(:rollout_status).and_return(kube_deployment_rollout_status)
create(:environment, project: project,
......
......@@ -4,8 +4,8 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
include KubernetesHelpers
include ReactiveCachingHelpers
let(:project) { build_stubbed(:kubernetes_project) }
let(:service) { project.kubernetes_service }
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
let(:service) { project.deployment_platform }
describe '#rollout_status' do
let(:environment) { build(:environment, project: project, name: "env", slug: "env-000000") }
......@@ -51,4 +51,18 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
end
end
end
end
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
......@@ -322,8 +322,8 @@ describe Environment do
end
end
describe '#deployment_service_ready?' do
subject { environment.deployment_service_ready? }
describe '#has_terminals?' do
subject { environment.has_terminals? }
context 'when the enviroment is available' do
context 'with a deployment service' do
......@@ -373,7 +373,7 @@ describe Environment do
context 'when the environment has terminals' do
before do
allow(environment).to receive(:deployment_service_ready?).and_return(true)
allow(environment).to receive(:has_terminals?).and_return(true)
end
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
......@@ -402,7 +402,7 @@ describe Environment do
context 'when the environment does not have terminals' do
before do
allow(environment).to receive(:deployment_service_ready?).and_return(false)
allow(environment).to receive(:has_terminals?).and_return(false)
end
it { is_expected.to be_nil }
......@@ -410,17 +410,16 @@ describe Environment do
end
describe '#rollout_status' do
let(:project) { create(:kubernetes_project) }
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
subject { environment.rollout_status }
context 'when the environment has rollout status' do
before do
allow(environment).to receive(:deployment_service_ready?).and_return(true)
allow(environment).to receive(:has_terminals?).and_return(true)
end
it 'returns the rollout status from the deployment service' do
expect(project.deployment_service)
expect(project.deployment_platform)
.to receive(:rollout_status).with(environment)
.and_return(:fake_rollout_status)
......@@ -430,13 +429,27 @@ describe Environment do
context 'when the environment does not have rollout status' do
before do
allow(environment).to receive(:deployment_service_ready?).and_return(false)
allow(environment).to receive(:has_terminals?).and_return(false)
end
it { is_expected.to eq(nil) }
end
end
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
end
describe '#has_metrics?' do
subject { environment.has_metrics? }
......
......@@ -51,7 +51,7 @@ describe EnvironmentEntity do
context 'with deployment service ready' do
before do
stub_licensed_features(deploy_board: true)
allow(environment).to receive(:deployment_service_ready?).and_return(true)
allow(environment).to receive(:has_terminals?).and_return(true)
allow(environment).to receive(:rollout_status).and_return(kube_deployment_rollout_status)
end
......@@ -63,7 +63,7 @@ describe EnvironmentEntity do
context 'when license does not has the GitLab_DeployBoard add-on' do
before do
stub_licensed_features(deploy_board: false)
allow(environment).to receive(:deployment_service_ready?).and_return(true)
allow(environment).to receive(:has_terminals?).and_return(true)
end
it 'does not expose rollout_status' do
......
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