diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-01-06 01:11:06 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-01-08 16:22:18 +0900 |
commit | 183dbdc8b8a68bdcbfb465abcbdae2d2292d9386 (patch) | |
tree | 514bd8fb1200a0c13661f2f3a0b90a0a969ab086 /spec/migrations | |
parent | 1c404c91b6e0bb0fac335083eff2f286d0da6df1 (diff) | |
download | gitlab-ce-183dbdc8b8a68bdcbfb465abcbdae2d2292d9386.tar.gz |
Revert bulk_insert and bring back AR insert(one by one)
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb index 5f135ad274e..85ed1328211 100644 --- a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb +++ b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb @@ -38,18 +38,6 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do it_behaves_like 'KubernetesService migration' end - - context 'when KubernetesService is not active' do - let(:active) { false } - - # Platforms::Kubernetes validates `token` reagdless of the activeness, - # whereas KubernetesService validates `token` if only it's activated - # However, in this migration file, there are no validations because of the migration specific model class - # therefore, Validation Error will not happen in this case and just migrate data - let(:token) { '' } - - it_behaves_like 'KubernetesService migration' - end end context 'when unique KubernetesService spawned from Service Template' do @@ -186,6 +174,34 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do end end + # Platforms::Kubernetes validates `token` reagdless of the activeness, + # whereas KubernetesService validates `token` if only it's activated + # However, in this migration file, there are no validations because of the re-defined model class + # therefore, we should safely add this raw to Platform::Kubernetes + context 'when KubernetesService has empty token' do + let(:project) { create(:project) } + + before do + ActiveRecord::Base.connection.execute <<~SQL + INSERT INTO services (project_id, active, category, type, properties) + VALUES (#{project.id}, false, 'deployment', 'KubernetesService', '{"namespace":"prod","api_url":"http://111.111.111.111","ca_pem":"a","token":""}'); + SQL + end + + it 'does not migrate the KubernetesService and disables the kubernetes_service' do + expect { migrate! }.to change { Clusters::Cluster.count }.by(1) + + project.clusters.last.tap do |cluster| + expect(cluster.environment_scope).to eq('*') + expect(cluster.platform_kubernetes.namespace).to eq('prod') + expect(cluster.platform_kubernetes.api_url).to eq('http://111.111.111.111') + expect(cluster.platform_kubernetes.ca_pem).to eq('a') + expect(cluster.platform_kubernetes.token).to be_empty + expect(project.kubernetes_service).not_to be_active + end + end + end + context 'when KubernetesService does not exist' do let!(:project) { create(:project) } |