Commit 85520a43 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'cluster_application_version_updated' into 'master'

Update version column on updated and installed

See merge request gitlab-org/gitlab-ee!9367
parents 8bb12814 c95f735a
......@@ -7,8 +7,8 @@ module Clusters
included do
state_machine :status do
after_transition any => [:installing] do |application|
application.update(version: application.class.const_get(:VERSION))
before_transition any => [:installed, :updated] do |application|
application.version = application.class.const_get(:VERSION)
end
end
end
......
---
title: Update cluster application version on updated and installed status
merge_request: 24810
author:
type: other
......@@ -16,7 +16,7 @@ module EE
state_machine :status do
after_transition any => :updating do |application|
application.update(last_update_started_at: Time.now, version: application.class.const_get(:VERSION))
application.update(last_update_started_at: Time.now)
end
end
end
......
......@@ -14,16 +14,6 @@ describe Clusters::Applications::Prometheus do
expect { subject.make_updating }.to change { subject.reload.last_update_started_at }.to be_within(1.second).of(Time.now)
end
end
context 'application install previously errored with older version' do
subject { create(:clusters_applications_prometheus, :installed, cluster: cluster, version: '6.7.2') }
it 'updates the application version' do
subject.make_updating
expect(subject.reload.version).to eq('6.7.3')
end
end
end
context '#updated_since?' do
......
......@@ -4,20 +4,8 @@ describe Clusters::Applications::CertManager do
let(:cert_manager) { create(:clusters_applications_cert_managers) }
include_examples 'cluster application core specs', :clusters_applications_cert_managers
describe '#make_installing!' do
before do
application.make_installing!
end
context 'application install previously errored with older version' do
let(:application) { create(:clusters_applications_cert_managers, :scheduled, version: 'v0.4.0') }
it 'updates the application version' do
expect(application.reload.version).to eq('v0.5.2')
end
end
end
include_examples 'cluster application status specs', :clusters_applications_cert_managers
include_examples 'cluster application initial status specs'
describe '#install_command' do
let(:cluster_issuer_file) { { "cluster_issuer.yaml": "---\napiVersion: certmanager.k8s.io/v1alpha1\nkind: ClusterIssuer\nmetadata:\n name: letsencrypt-prod\nspec:\n acme:\n server: https://acme-v02.api.letsencrypt.org/directory\n email: admin@example.com\n privateKeySecretRef:\n name: letsencrypt-prod\n http01: {}\n" } }
......
......@@ -8,6 +8,7 @@ describe Clusters::Applications::Ingress do
include_examples 'cluster application core specs', :clusters_applications_ingress
include_examples 'cluster application status specs', :clusters_applications_ingress
include_examples 'cluster application helm specs', :clusters_applications_ingress
include_examples 'cluster application initial status specs'
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
......@@ -26,20 +27,6 @@ describe Clusters::Applications::Ingress do
it { is_expected.to contain_exactly(cluster) }
end
describe '#make_installing!' do
before do
application.make_installing!
end
context 'application install previously errored with older version' do
let(:application) { create(:clusters_applications_ingress, :scheduled, version: '0.22.0') }
it 'updates the application version' do
expect(application.reload.version).to eq('1.1.2')
end
end
end
describe '#make_installed!' do
before do
application.make_installed!
......
......@@ -2,6 +2,7 @@ require 'rails_helper'
describe Clusters::Applications::Jupyter do
include_examples 'cluster application core specs', :clusters_applications_jupyter
include_examples 'cluster application status specs', :clusters_applications_jupyter
include_examples 'cluster application helm specs', :clusters_applications_jupyter
it { is_expected.to belong_to(:oauth_application) }
......@@ -26,20 +27,6 @@ describe Clusters::Applications::Jupyter do
end
end
describe '#make_installing!' do
before do
application.make_installing!
end
context 'application install previously errored with older version' do
let(:application) { create(:clusters_applications_jupyter, :scheduled, version: 'v0.5') }
it 'updates the application version' do
expect(application.reload.version).to eq('v0.6')
end
end
end
describe '#install_command' do
let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: ingress.cluster) }
......
......@@ -9,6 +9,7 @@ describe Clusters::Applications::Knative do
include_examples 'cluster application core specs', :clusters_applications_knative
include_examples 'cluster application status specs', :clusters_applications_knative
include_examples 'cluster application helm specs', :clusters_applications_knative
include_examples 'cluster application initial status specs'
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
......@@ -34,20 +35,6 @@ describe Clusters::Applications::Knative do
it { is_expected.to contain_exactly(cluster) }
end
describe '#make_installing!' do
before do
application.make_installing!
end
context 'application install previously errored with older version' do
let(:application) { create(:clusters_applications_knative, :scheduled, version: '0.2.2') }
it 'updates the application version' do
expect(application.reload.version).to eq('0.2.2')
end
end
end
describe '#make_installed' do
subject { described_class.installed }
......
......@@ -6,6 +6,7 @@ describe Clusters::Applications::Prometheus do
include_examples 'cluster application core specs', :clusters_applications_prometheus
include_examples 'cluster application status specs', :clusters_applications_prometheus
include_examples 'cluster application helm specs', :clusters_applications_prometheus
include_examples 'cluster application initial status specs'
describe '.installed' do
subject { described_class.installed }
......@@ -19,20 +20,6 @@ describe Clusters::Applications::Prometheus do
it { is_expected.to contain_exactly(cluster) }
end
describe '#make_installing!' do
before do
application.make_installing!
end
context 'application install previously errored with older version' do
let(:application) { create(:clusters_applications_prometheus, :scheduled, version: '6.7.2') }
it 'updates the application version' do
expect(application.reload.version).to eq('6.7.3')
end
end
end
describe 'transition to installed' do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) }
......
......@@ -6,23 +6,10 @@ describe Clusters::Applications::Runner do
include_examples 'cluster application core specs', :clusters_applications_runner
include_examples 'cluster application status specs', :clusters_applications_runner
include_examples 'cluster application helm specs', :clusters_applications_runner
include_examples 'cluster application initial status specs'
it { is_expected.to belong_to(:runner) }
describe '#make_installing!' do
before do
application.make_installing!
end
context 'application install previously errored with older version' do
let(:application) { create(:clusters_applications_runner, :scheduled, version: '0.1.30') }
it 'updates the application version' do
expect(application.reload.version).to eq('0.1.45')
end
end
end
describe '.installed' do
subject { described_class.installed }
......
# frozen_string_literal: true
shared_examples 'cluster application initial status specs' do
describe '#status' do
let(:cluster) { create(:cluster, :provided_by_gcp) }
subject { described_class.new(cluster: cluster) }
context 'when application helm is scheduled' do
before do
create(:clusters_applications_helm, :scheduled, cluster: cluster)
end
it 'defaults to :not_installable' do
expect(subject.status_name).to be(:not_installable)
end
end
context 'when application is scheduled' do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
end
it 'sets a default status' do
expect(subject.status_name).to be(:installable)
end
end
end
end
......@@ -7,26 +7,6 @@ shared_examples 'cluster application status specs' do |application_name|
it 'sets a default status' do
expect(subject.status_name).to be(:not_installable)
end
context 'when application helm is scheduled' do
before do
create(:clusters_applications_helm, :scheduled, cluster: cluster)
end
it 'defaults to :not_installable' do
expect(subject.status_name).to be(:not_installable)
end
end
context 'when application is scheduled' do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
end
it 'sets a default status' do
expect(subject.status_name).to be(:installable)
end
end
end
describe 'status state machine' do
......@@ -58,6 +38,16 @@ shared_examples 'cluster application status specs' do |application_name|
expect(subject.cluster.application_helm.version).to eq(Gitlab::Kubernetes::Helm::HELM_VERSION)
end
it 'sets the correct version of the application' do
subject.update!(version: '0.0.0')
subject.make_installed!
subject.reload
expect(subject.version).to eq(subject.class.const_get(:VERSION))
end
end
describe '#make_updated' do
......@@ -78,6 +68,16 @@ shared_examples 'cluster application status specs' do |application_name|
expect(subject.cluster.application_helm.version).to eq(Gitlab::Kubernetes::Helm::HELM_VERSION)
end
it 'updates the version for the application' do
subject.update!(version: '0.0.0')
subject.make_updated!
subject.reload
expect(subject.version).to eq(subject.class.const_get(:VERSION))
end
end
describe '#make_errored' 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