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
path: root/spec
diff options
context:
space:
mode:
authorwalkafwalka <2865898-walkafwalka@users.noreply.gitlab.com>2019-03-08 00:51:43 +0300
committerwalkafwalka <2865898-walkafwalka@users.noreply.gitlab.com>2019-03-08 02:25:48 +0300
commit460797dec3dc143943390e86a09d6e6b45a465d8 (patch)
treea5495703f3bfd1152929c84853322cd9a6812f15 /spec
parent31cf53df4d766ef58d6d5be60d5fa2e380406fc8 (diff)
Add support for ingress hostnames
Diffstat (limited to 'spec')
-rw-r--r--spec/features/projects/clusters/applications_spec.rb12
-rw-r--r--spec/fixtures/api/schemas/cluster_status.json1
-rw-r--r--spec/javascripts/clusters/components/applications_spec.js42
-rw-r--r--spec/javascripts/clusters/services/mock_data.js2
-rw-r--r--spec/javascripts/clusters/stores/clusters_store_spec.js2
-rw-r--r--spec/models/clusters/applications/ingress_spec.rb8
-rw-r--r--spec/models/clusters/applications/jupyter_spec.rb7
-rw-r--r--spec/models/clusters/applications/knative_spec.rb8
-rw-r--r--spec/models/clusters/cluster_spec.rb1
-rw-r--r--spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb10
-rw-r--r--spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb8
11 files changed, 86 insertions, 15 deletions
diff --git a/spec/features/projects/clusters/applications_spec.rb b/spec/features/projects/clusters/applications_spec.rb
index 713e25cdcb2..4981bf794d9 100644
--- a/spec/features/projects/clusters/applications_spec.rb
+++ b/spec/features/projects/clusters/applications_spec.rb
@@ -82,7 +82,7 @@ describe 'Clusters Applications', :js do
it 'should show info block and not be installable' do
page.within('.js-cluster-application-row-knative') do
- expect(page).to have_css('.bs-callout-info')
+ expect(page).to have_css('.rbac-notice')
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
end
end
@@ -93,7 +93,7 @@ describe 'Clusters Applications', :js do
it 'should not show callout block and be installable' do
page.within('.js-cluster-application-row-knative') do
- expect(page).not_to have_css('.bs-callout-info')
+ expect(page).not_to have_css('.rbac-notice')
expect(page).to have_css('.js-cluster-application-install-button:not([disabled])')
end
end
@@ -226,14 +226,14 @@ describe 'Clusters Applications', :js do
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('?')
+ expect(page).to have_selector('.js-no-endpoint-message')
+ expect(page.find('.js-endpoint').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')
+ expect(page).not_to have_selector('.js-no-endpoint-message')
+ expect(page.find('.js-endpoint').value).to eq('192.168.1.100')
end
expect(page).to have_content('Ingress was successfully installed on your Kubernetes cluster')
diff --git a/spec/fixtures/api/schemas/cluster_status.json b/spec/fixtures/api/schemas/cluster_status.json
index 5ebc09a96dc..9da07a0b253 100644
--- a/spec/fixtures/api/schemas/cluster_status.json
+++ b/spec/fixtures/api/schemas/cluster_status.json
@@ -33,6 +33,7 @@
"version": { "type": "string" },
"status_reason": { "type": ["string", "null"] },
"external_ip": { "type": ["string", "null"] },
+ "external_hostname": { "type": ["string", "null"] },
"hostname": { "type": ["string", "null"] },
"email": { "type": ["string", "null"] },
"update_available": { "type": ["boolean", "null"] }
diff --git a/spec/javascripts/clusters/components/applications_spec.js b/spec/javascripts/clusters/components/applications_spec.js
index 8daf0282184..e2466bf326c 100644
--- a/spec/javascripts/clusters/components/applications_spec.js
+++ b/spec/javascripts/clusters/components/applications_spec.js
@@ -106,7 +106,7 @@ describe('Applications', () => {
},
});
- expect(vm.$el.querySelector('.js-ip-address').value).toEqual('0.0.0.0');
+ expect(vm.$el.querySelector('.js-endpoint').value).toEqual('0.0.0.0');
expect(
vm.$el.querySelector('.js-clipboard-btn').getAttribute('data-clipboard-text'),
@@ -114,6 +114,32 @@ describe('Applications', () => {
});
});
+ describe('with hostname', () => {
+ it('renders hostname with a clipboard button', () => {
+ vm = mountComponent(Applications, {
+ applications: {
+ ingress: {
+ title: 'Ingress',
+ status: 'installed',
+ externalHostname: 'localhost.localdomain',
+ },
+ helm: { title: 'Helm Tiller' },
+ cert_manager: { title: 'Cert-Manager' },
+ runner: { title: 'GitLab Runner' },
+ prometheus: { title: 'Prometheus' },
+ jupyter: { title: 'JupyterHub', hostname: '' },
+ knative: { title: 'Knative', hostname: '' },
+ },
+ });
+
+ expect(vm.$el.querySelector('.js-endpoint').value).toEqual('localhost.localdomain');
+
+ expect(
+ vm.$el.querySelector('.js-clipboard-btn').getAttribute('data-clipboard-text'),
+ ).toEqual('localhost.localdomain');
+ });
+ });
+
describe('without ip address', () => {
it('renders an input text with a question mark and an alert text', () => {
vm = mountComponent(Applications, {
@@ -126,9 +152,9 @@ describe('Applications', () => {
},
});
- expect(vm.$el.querySelector('.js-ip-address').value).toEqual('?');
+ expect(vm.$el.querySelector('.js-endpoint').value).toEqual('?');
- expect(vm.$el.querySelector('.js-no-ip-message')).not.toBe(null);
+ expect(vm.$el.querySelector('.js-no-endpoint-message')).not.toBe(null);
});
});
});
@@ -140,7 +166,7 @@ describe('Applications', () => {
});
expect(vm.$el.textContent).not.toContain('Ingress IP Address');
- expect(vm.$el.querySelector('.js-ip-address')).toBe(null);
+ expect(vm.$el.querySelector('.js-endpoint')).toBe(null);
});
});
@@ -268,11 +294,11 @@ describe('Applications', () => {
it('renders ip address with a clipboard button', () => {
vm = mountComponent(Applications, props);
- expect(vm.$el.querySelector('.js-knative-ip-address').value).toEqual('1.1.1.1');
+ expect(vm.$el.querySelector('.js-knative-endpoint').value).toEqual('1.1.1.1');
expect(
vm.$el
- .querySelector('.js-knative-ip-clipboard-btn')
+ .querySelector('.js-knative-endpoint-clipboard-btn')
.getAttribute('data-clipboard-text'),
).toEqual('1.1.1.1');
});
@@ -316,9 +342,9 @@ describe('Applications', () => {
},
});
- expect(vm.$el.querySelector('.js-knative-ip-address').value).toEqual('?');
+ expect(vm.$el.querySelector('.js-knative-endpoint').value).toEqual('?');
- expect(vm.$el.querySelector('.js-no-knative-ip-message')).not.toBe(null);
+ expect(vm.$el.querySelector('.js-no-knative-endpoint-message')).not.toBe(null);
});
});
});
diff --git a/spec/javascripts/clusters/services/mock_data.js b/spec/javascripts/clusters/services/mock_data.js
index 3ace19c6401..b4d1bb710e0 100644
--- a/spec/javascripts/clusters/services/mock_data.js
+++ b/spec/javascripts/clusters/services/mock_data.js
@@ -17,6 +17,7 @@ const CLUSTERS_MOCK_DATA = {
status: APPLICATION_STATUS.ERROR,
status_reason: 'Cannot connect',
external_ip: null,
+ external_hostname: null,
},
{
name: 'runner',
@@ -62,6 +63,7 @@ const CLUSTERS_MOCK_DATA = {
status: APPLICATION_STATUS.INSTALLED,
status_reason: 'Cannot connect',
external_ip: '1.1.1.1',
+ external_hostname: null,
},
{
name: 'runner',
diff --git a/spec/javascripts/clusters/stores/clusters_store_spec.js b/spec/javascripts/clusters/stores/clusters_store_spec.js
index 09bcdf91d91..161722ec571 100644
--- a/spec/javascripts/clusters/stores/clusters_store_spec.js
+++ b/spec/javascripts/clusters/stores/clusters_store_spec.js
@@ -78,6 +78,7 @@ describe('Clusters Store', () => {
requestStatus: null,
requestReason: null,
externalIp: null,
+ externalHostname: null,
},
runner: {
title: 'GitLab Runner',
@@ -113,6 +114,7 @@ describe('Clusters Store', () => {
hostname: null,
isEditingHostName: false,
externalIp: null,
+ externalHostname: null,
},
cert_manager: {
title: 'Cert-Manager',
diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb
index d5fd42509a3..a40fa988287 100644
--- a/spec/models/clusters/applications/ingress_spec.rb
+++ b/spec/models/clusters/applications/ingress_spec.rb
@@ -56,6 +56,14 @@ describe Clusters::Applications::Ingress do
expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_in)
end
end
+
+ context 'when there is already an external_hostname' do
+ let(:application) { create(:clusters_applications_ingress, :installed, external_hostname: 'localhost.localdomain') }
+
+ it 'does not schedule a ClusterWaitForIngressIpAddressWorker' do
+ expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_in)
+ end
+ end
end
describe '#install_command' do
diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb
index 6e58f3ad699..2967c4076c6 100644
--- a/spec/models/clusters/applications/jupyter_spec.rb
+++ b/spec/models/clusters/applications/jupyter_spec.rb
@@ -26,6 +26,13 @@ describe Clusters::Applications::Jupyter do
it { expect(jupyter).to be_installable }
end
+
+ context 'when ingress is installed and external_hostname is assigned' do
+ let(:ingress) { create(:clusters_applications_ingress, :installed, external_hostname: 'localhost.localdomain') }
+ let(:jupyter) { create(:clusters_applications_jupyter, cluster: ingress.cluster) }
+
+ it { expect(jupyter).to be_installable }
+ end
end
describe '#install_command' do
diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb
index 4884a5927fb..bf425a2617c 100644
--- a/spec/models/clusters/applications/knative_spec.rb
+++ b/spec/models/clusters/applications/knative_spec.rb
@@ -64,6 +64,14 @@ describe Clusters::Applications::Knative do
expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_in)
end
end
+
+ context 'when there is already an external_hostname' do
+ let(:application) { create(:clusters_applications_knative, :installed, external_hostname: 'localhost.localdomain') }
+
+ it 'does not schedule a ClusterWaitForIngressIpAddressWorker' do
+ expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_in)
+ end
+ end
end
shared_examples 'a command' do
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb
index 3feed4e9718..acbcdc7d170 100644
--- a/spec/models/clusters/cluster_spec.rb
+++ b/spec/models/clusters/cluster_spec.rb
@@ -31,6 +31,7 @@ describe Clusters::Cluster do
it { is_expected.to delegate_method(:available?).to(:application_prometheus).with_prefix }
it { is_expected.to delegate_method(:available?).to(:application_knative).with_prefix }
it { is_expected.to delegate_method(:external_ip).to(:application_ingress).with_prefix }
+ it { is_expected.to delegate_method(:external_hostname).to(:application_ingress).with_prefix }
it { is_expected.to respond_to :project }
diff --git a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
index f3036fbcb0e..80fc48d1b07 100644
--- a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
+++ b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
@@ -6,9 +6,17 @@ describe Clusters::Applications::CheckIngressIpAddressService do
let(:application) { create(:clusters_applications_ingress, :installed) }
let(:service) { described_class.new(application) }
let(:kubeclient) { double(::Kubeclient::Client, get_service: kube_service) }
- let(:ingress) { [{ ip: '111.222.111.222' }] }
let(:lease_key) { "check_ingress_ip_address_service:#{application.id}" }
+ let(:ingress) do
+ [
+ {
+ ip: '111.222.111.222',
+ hostname: 'localhost.localdomain'
+ }
+ ]
+ end
+
let(:kube_service) do
::Kubeclient::Resource.new(
{
diff --git a/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb b/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb
index 14638a574a5..02de47a96dd 100644
--- a/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb
@@ -12,6 +12,14 @@ shared_examples 'check ingress ip executions' do |app_name|
end
end
+ context 'when the ingress external hostname is available' do
+ it 'updates the external_hostname for the app' do
+ subject
+
+ expect(application.external_hostname).to eq('localhost.localdomain')
+ end
+ end
+
context 'when the ingress ip address is not available' do
let(:ingress) { nil }