debian-mirror-gitlab/spec/features/projects/clusters/applications_spec.rb

132 lines
5.3 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
require 'spec_helper'
2018-11-08 19:23:39 +05:30
describe 'Clusters Applications', :js do
2018-03-17 18:26:18 +05:30
include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-03-17 18:26:18 +05:30
sign_in(user)
end
describe 'Installing applications' do
before do
visit project_cluster_path(project, cluster)
end
context 'when cluster is being created' do
let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project])}
2018-11-08 19:23:39 +05:30
it 'user is unable to install applications' do
2018-03-17 18:26:18 +05:30
page.within('.js-cluster-application-row-helm') do
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install')
2018-03-17 18:26:18 +05:30
end
end
end
context 'when cluster is created' do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project])}
2018-11-08 19:23:39 +05:30
it 'user can install applications' do
2018-03-17 18:26:18 +05:30
page.within('.js-cluster-application-row-helm') do
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to be_nil
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install')
2018-03-17 18:26:18 +05:30
end
end
context 'when user installs Helm' do
before do
2018-03-27 19:54:05 +05:30
allow(ClusterInstallAppWorker).to receive(:perform_async)
2018-03-17 18:26:18 +05:30
page.within('.js-cluster-application-row-helm') do
page.find(:css, '.js-cluster-application-install-button').click
end
end
2018-11-18 11:00:15 +05:30
it 'they see status transition' do
2018-03-17 18:26:18 +05:30
page.within('.js-cluster-application-row-helm') do
# FE sends request and gets the response, then the buttons is "Install"
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install')
2018-03-17 18:26:18 +05:30
2018-11-18 11:00:15 +05:30
wait_until_helm_created!
2018-03-17 18:26:18 +05:30
Clusters::Cluster.last.application_helm.make_installing!
# FE starts polling and update the buttons to "Installing"
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
2018-03-17 18:26:18 +05:30
Clusters::Cluster.last.application_helm.make_installed!
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed')
2018-03-17 18:26:18 +05:30
end
expect(page).to have_content('Helm Tiller was successfully installed on your Kubernetes cluster')
end
end
context 'when user installs Ingress' do
context 'when user installs application: Ingress' do
before do
2018-03-27 19:54:05 +05:30
allow(ClusterInstallAppWorker).to receive(:perform_async)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
2018-03-17 18:26:18 +05:30
create(:clusters_applications_helm, :installed, cluster: cluster)
page.within('.js-cluster-application-row-ingress') do
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button:not([disabled])')
2018-03-17 18:26:18 +05:30
page.find(:css, '.js-cluster-application-install-button').click
end
end
2018-11-18 11:00:15 +05:30
it 'they see status transition' do
2018-03-17 18:26:18 +05:30
page.within('.js-cluster-application-row-ingress') do
# FE sends request and gets the response, then the buttons is "Install"
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button[disabled]')
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install')
2018-03-17 18:26:18 +05:30
Clusters::Cluster.last.application_ingress.make_installing!
# FE starts polling and update the buttons to "Installing"
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
expect(page).to have_css('.js-cluster-application-install-button[disabled]')
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
# The application becomes installed but we keep waiting for external IP address
2018-03-17 18:26:18 +05:30
Clusters::Cluster.last.application_ingress.make_installed!
2018-03-27 19:54:05 +05:30
expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed')
expect(page).to have_css('.js-cluster-application-install-button[disabled]')
expect(page).to have_selector('.js-no-ip-message')
expect(page.find('.js-ip-address').value).to eq('?')
# We receive the external IP address and display
Clusters::Cluster.last.application_ingress.update!(external_ip: '192.168.1.100')
expect(page).not_to have_selector('.js-no-ip-message')
expect(page.find('.js-ip-address').value).to eq('192.168.1.100')
2018-03-17 18:26:18 +05:30
end
expect(page).to have_content('Ingress was successfully installed on your Kubernetes cluster')
end
end
end
end
end
2018-11-18 11:00:15 +05:30
def wait_until_helm_created!
retries = 0
while Clusters::Cluster.last.application_helm.nil?
raise "Timed out waiting for helm application to be created in DB" if (retries += 1) > 3
sleep(1)
end
end
2018-03-17 18:26:18 +05:30
end