summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-11-07 18:34:59 +0900
committerShinya Maeda <shinya@gitlab.com>2017-11-07 18:34:59 +0900
commitd89d514e89916a08b2692ada242afc732d10fdc0 (patch)
tree2e69d464f6b3d03f8177ee0c3bd0bb85a1af1e46
parent6228b65ff1503e2a3496544c15961139e1fb6cd4 (diff)
parent3bf2abaa1cc26b8658d870e85d4fc9e60e621944 (diff)
downloadgitlab-ce-d89d514e89916a08b2692ada242afc732d10fdc0.tar.gz
Merge branch '38464-k8s-apps' of https://gitlab.com/gitlab-org/gitlab-ce into 38464-k8s-apps
-rw-r--r--app/models/clusters/concerns/application_status.rb14
-rw-r--r--spec/factories/clusters/applications/helm.rb8
-rw-r--r--spec/models/clusters/applications/helm_spec.rb10
-rw-r--r--spec/serializers/cluster_application_entity_spec.rb4
-rw-r--r--spec/services/clusters/applications/check_installation_progress_service_spec.rb4
-rw-r--r--spec/services/clusters/applications/install_service_spec.rb4
-rw-r--r--spec/services/clusters/applications/schedule_installation_service_spec.rb2
7 files changed, 21 insertions, 25 deletions
diff --git a/app/models/clusters/concerns/application_status.rb b/app/models/clusters/concerns/application_status.rb
index 40140cb71cb..e73abfa9055 100644
--- a/app/models/clusters/concerns/application_status.rb
+++ b/app/models/clusters/concerns/application_status.rb
@@ -12,20 +12,20 @@ module Clusters
state :installing, value: 2
state :installed, value: 3
+ event :make_scheduled do
+ transition %i(installable errored) => :scheduled
+ end
+
event :make_installing do
- transition any - [:installing] => :installing
+ transition %i(scheduled) => :installing
end
event :make_installed do
- transition any - [:installed] => :installed
+ transition %i(installing) => :installed
end
event :make_errored do
- transition any - [:errored] => :errored
- end
-
- event :make_scheduled do
- transition %i(installable errored) => :scheduled
+ transition any => :errored
end
before_transition any => [:scheduled] do |app_status, _|
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
index fd956097115..b63e26125d1 100644
--- a/spec/factories/clusters/applications/helm.rb
+++ b/spec/factories/clusters/applications/helm.rb
@@ -1,10 +1,6 @@
FactoryGirl.define do
- factory :applications_helm, class: Clusters::Applications::Helm do
- trait :cluster do
- before(:create) do |app, _|
- app.cluster = create(:cluster)
- end
- end
+ factory :cluster_applications_helm, class: Clusters::Applications::Helm do
+ cluster factory: :cluster
trait :installable do
cluster
diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb
index 54fce7d886a..44fb60f0ed0 100644
--- a/spec/models/clusters/applications/helm_spec.rb
+++ b/spec/models/clusters/applications/helm_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Clusters::Applications::Helm, type: :model do
describe 'status state machine' do
describe '#make_installing' do
- subject { create(:applications_helm, :scheduled) }
+ subject { create(:cluster_applications_helm, :scheduled) }
it 'is installing' do
subject.make_installing!
@@ -38,7 +38,7 @@ RSpec.describe Clusters::Applications::Helm, type: :model do
end
describe '#make_installed' do
- subject { create(:applications_helm, :installing) }
+ subject { create(:cluster_applications_helm, :installing) }
it 'is installed' do
subject.make_installed
@@ -48,7 +48,7 @@ RSpec.describe Clusters::Applications::Helm, type: :model do
end
describe '#make_errored' do
- subject { create(:applications_helm, :installing) }
+ subject { create(:cluster_applications_helm, :installing) }
let(:reason) { 'some errors' }
it 'is errored' do
@@ -60,7 +60,7 @@ RSpec.describe Clusters::Applications::Helm, type: :model do
end
describe '#make_scheduled' do
- subject { create(:applications_helm, :installable) }
+ subject { create(:cluster_applications_helm, :installable) }
it 'is scheduled' do
subject.make_scheduled
@@ -69,7 +69,7 @@ RSpec.describe Clusters::Applications::Helm, type: :model do
end
describe 'when was errored' do
- subject { create(:applications_helm, :errored) }
+ subject { create(:cluster_applications_helm, :errored) }
it 'clears #status_reason' do
expect(subject.status_reason).not_to be_nil
diff --git a/spec/serializers/cluster_application_entity_spec.rb b/spec/serializers/cluster_application_entity_spec.rb
index 61cebcefa28..8a3a081adf8 100644
--- a/spec/serializers/cluster_application_entity_spec.rb
+++ b/spec/serializers/cluster_application_entity_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe ClusterApplicationEntity do
describe '#as_json' do
- let(:application) { build(:applications_helm) }
+ let(:application) { build(:cluster_applications_helm) }
subject { described_class.new(application).as_json }
it 'has name' do
@@ -18,7 +18,7 @@ describe ClusterApplicationEntity do
end
context 'when application is errored' do
- let(:application) { build(:applications_helm, :errored) }
+ let(:application) { build(:cluster_applications_helm, :errored) }
it 'has corresponded data' do
expect(subject[:status]).to eq(:errored)
diff --git a/spec/services/clusters/applications/check_installation_progress_service_spec.rb b/spec/services/clusters/applications/check_installation_progress_service_spec.rb
index faa5b469069..75fc05d36e9 100644
--- a/spec/services/clusters/applications/check_installation_progress_service_spec.rb
+++ b/spec/services/clusters/applications/check_installation_progress_service_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Clusters::Applications::CheckInstallationProgressService do
RESCHEDULE_PHASES = Gitlab::Kubernetes::Pod::PHASES - [Gitlab::Kubernetes::Pod::SUCCEEDED, Gitlab::Kubernetes::Pod::FAILED].freeze
- let(:application) { create(:applications_helm, :installing) }
+ let(:application) { create(:cluster_applications_helm, :installing) }
let(:service) { described_class.new(application) }
let(:phase) { Gitlab::Kubernetes::Pod::UNKNOWN }
let(:errors) { nil }
@@ -33,7 +33,7 @@ describe Clusters::Applications::CheckInstallationProgressService do
end
context 'when timeouted' do
- let(:application) { create(:applications_helm, :timeouted) }
+ let(:application) { create(:cluster_applications_helm, :timeouted) }
it_behaves_like 'a terminated installation'
diff --git a/spec/services/clusters/applications/install_service_spec.rb b/spec/services/clusters/applications/install_service_spec.rb
index a646dac1cae..ae8dc7b2bd9 100644
--- a/spec/services/clusters/applications/install_service_spec.rb
+++ b/spec/services/clusters/applications/install_service_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Clusters::Applications::InstallService do
describe '#execute' do
- let(:application) { create(:applications_helm, :scheduled) }
+ let(:application) { create(:cluster_applications_helm, :scheduled) }
let(:service) { described_class.new(application) }
context 'when there are no errors' do
@@ -39,7 +39,7 @@ describe Clusters::Applications::InstallService do
end
context 'when application cannot be persisted' do
- let(:application) { build(:applications_helm, :scheduled) }
+ let(:application) { build(:cluster_applications_helm, :scheduled) }
it 'make the application errored' do
expect(application).to receive(:make_installing!).once.and_raise(ActiveRecord::RecordInvalid)
diff --git a/spec/services/clusters/applications/schedule_installation_service_spec.rb b/spec/services/clusters/applications/schedule_installation_service_spec.rb
index 6ba587a41db..cf95361c935 100644
--- a/spec/services/clusters/applications/schedule_installation_service_spec.rb
+++ b/spec/services/clusters/applications/schedule_installation_service_spec.rb
@@ -32,7 +32,7 @@ describe Clusters::Applications::ScheduleInstallationService do
end
context 'when installation is already in progress' do
- let(:application) { create(:applications_helm, :installing) }
+ let(:application) { create(:cluster_applications_helm, :installing) }
let(:cluster) { application.cluster }
it_behaves_like 'a failing service'