Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiger <twatson@gitlab.com>2019-06-14 03:45:31 +0300
committerTiger <twatson@gitlab.com>2019-06-21 01:30:26 +0300
commitbae848418b1784be938bb670da4ffceed06f42dd (patch)
treeba3a2234dabe881760cf851375e9cae9bd9046a5 /spec/migrations/migrate_managed_clusters_with_no_token_to_unmanaged_spec.rb
parent2c48cb24983314ab78963d2dfb2a74b0f9104fc8 (diff)
Migrate clusters with no token to unmanaged
There are clusters that have Kubernetes namespaces stored which are missing a service account token. These namespaces are unable to be used for deployments, so marking the clusters as unmanaged will allow the platform credentials to be used instead.
Diffstat (limited to 'spec/migrations/migrate_managed_clusters_with_no_token_to_unmanaged_spec.rb')
-rw-r--r--spec/migrations/migrate_managed_clusters_with_no_token_to_unmanaged_spec.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/migrations/migrate_managed_clusters_with_no_token_to_unmanaged_spec.rb b/spec/migrations/migrate_managed_clusters_with_no_token_to_unmanaged_spec.rb
new file mode 100644
index 00000000000..b73bd16cb60
--- /dev/null
+++ b/spec/migrations/migrate_managed_clusters_with_no_token_to_unmanaged_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20190613231640_migrate_managed_clusters_with_no_token_to_unmanaged.rb')
+
+describe MigrateManagedClustersWithNoTokenToUnmanaged, :migration do
+ let(:cluster_type) { 'project_type' }
+ let(:created_at) { Date.new(2018, 11, 1).midnight }
+
+ let!(:cluster) do
+ table(:clusters).create!(
+ name: 'cluster',
+ cluster_type: described_class::Cluster.cluster_types[cluster_type],
+ managed: true,
+ created_at: created_at
+ )
+ end
+
+ let!(:kubernetes_namespace) do
+ table(:clusters_kubernetes_namespaces).create!(
+ cluster_id: cluster.id,
+ namespace: 'namespace'
+ )
+ end
+
+ it 'marks the cluster as unmanaged' do
+ migrate!
+ expect(cluster.reload).not_to be_managed
+ end
+
+ context 'cluster is not project type' do
+ let(:cluster_type) { 'group_type' }
+
+ it 'does not update the cluster' do
+ migrate!
+ expect(cluster.reload).to be_managed
+ end
+ end
+
+ context 'kubernetes namespace has a service account token' do
+ before do
+ kubernetes_namespace.update!(encrypted_service_account_token: "TOKEN")
+ end
+
+ it 'does not update the cluster' do
+ migrate!
+ expect(cluster.reload).to be_managed
+ end
+ end
+
+ context 'cluster was created after the cutoff' do
+ let(:created_at) { Date.new(2019, 1, 1).midnight }
+
+ it 'does not update the cluster' do
+ migrate!
+ expect(cluster.reload).to be_managed
+ end
+ end
+end