2019-07-31 22:56:46 +05:30
|
|
|
import { APPLICATION_INSTALLED_STATUSES, APPLICATION_STATUS, RUNNER } from '~/clusters/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import ClustersStore from '~/clusters/stores/clusters_store';
|
2018-03-17 18:26:18 +05:30
|
|
|
import { CLUSTERS_MOCK_DATA } from '../services/mock_data';
|
|
|
|
|
|
|
|
describe('Clusters Store', () => {
|
|
|
|
let store;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
store = new ClustersStore();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updateStatus', () => {
|
|
|
|
it('should store new status', () => {
|
|
|
|
expect(store.state.status).toEqual(null);
|
|
|
|
|
|
|
|
const newStatus = 'errored';
|
|
|
|
store.updateStatus(newStatus);
|
|
|
|
|
|
|
|
expect(store.state.status).toEqual(newStatus);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updateStatusReason', () => {
|
|
|
|
it('should store new reason', () => {
|
|
|
|
expect(store.state.statusReason).toEqual(null);
|
|
|
|
|
|
|
|
const newReason = 'Something went wrong!';
|
|
|
|
store.updateStatusReason(newReason);
|
|
|
|
|
|
|
|
expect(store.state.statusReason).toEqual(newReason);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updateAppProperty', () => {
|
|
|
|
it('should store new request reason', () => {
|
|
|
|
expect(store.state.applications.helm.requestReason).toEqual(null);
|
|
|
|
|
|
|
|
const newReason = 'We broke it.';
|
|
|
|
store.updateAppProperty('helm', 'requestReason', newReason);
|
|
|
|
|
|
|
|
expect(store.state.applications.helm.requestReason).toEqual(newReason);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updateStateFromServer', () => {
|
|
|
|
it('should store new polling data from server', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
const mockResponseData =
|
|
|
|
CLUSTERS_MOCK_DATA.GET['/gitlab-org/gitlab-shell/clusters/1/status.json'].data;
|
2018-03-17 18:26:18 +05:30
|
|
|
store.updateStateFromServer(mockResponseData);
|
|
|
|
|
|
|
|
expect(store.state).toEqual({
|
|
|
|
helpPath: null,
|
2021-02-22 17:27:13 +05:30
|
|
|
helmHelpPath: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
ingressHelpPath: null,
|
2019-12-04 20:38:33 +05:30
|
|
|
environmentsHelpPath: null,
|
|
|
|
clustersHelpPath: null,
|
|
|
|
deployBoardsHelpPath: null,
|
2019-12-21 20:55:43 +05:30
|
|
|
cloudRunHelpPath: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
status: mockResponseData.status,
|
|
|
|
statusReason: mockResponseData.status_reason,
|
2019-12-21 20:55:43 +05:30
|
|
|
providerType: null,
|
|
|
|
preInstalledKnative: false,
|
2019-02-15 15:39:39 +05:30
|
|
|
rbac: false,
|
2018-03-17 18:26:18 +05:30
|
|
|
applications: {
|
|
|
|
helm: {
|
2021-02-22 17:27:13 +05:30
|
|
|
title: 'Legacy Helm Tiller server',
|
2018-03-17 18:26:18 +05:30
|
|
|
status: mockResponseData.applications[0].status,
|
|
|
|
statusReason: mockResponseData.applications[0].status_reason,
|
|
|
|
requestReason: null,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
installFailed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
ingress: {
|
|
|
|
title: 'Ingress',
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
2018-03-17 18:26:18 +05:30
|
|
|
statusReason: mockResponseData.applications[1].status_reason,
|
|
|
|
requestReason: null,
|
2018-03-27 19:54:05 +05:30
|
|
|
externalIp: null,
|
2019-07-07 11:18:12 +05:30
|
|
|
externalHostname: null,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
installFailed: true,
|
|
|
|
uninstallable: false,
|
2020-04-08 14:13:33 +05:30
|
|
|
updateFailed: false,
|
2019-07-31 22:56:46 +05:30
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
runner: {
|
|
|
|
title: 'GitLab Runner',
|
|
|
|
status: mockResponseData.applications[2].status,
|
|
|
|
statusReason: mockResponseData.applications[2].status_reason,
|
|
|
|
requestReason: null,
|
2019-03-02 22:35:43 +05:30
|
|
|
version: mockResponseData.applications[2].version,
|
2019-09-04 21:01:54 +05:30
|
|
|
updateAvailable: mockResponseData.applications[2].update_available,
|
2019-12-04 20:38:33 +05:30
|
|
|
chartRepo: 'https://gitlab.com/gitlab-org/charts/gitlab-runner',
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
installFailed: false,
|
|
|
|
updateFailed: false,
|
|
|
|
updateSuccessful: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
prometheus: {
|
|
|
|
title: 'Prometheus',
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
2018-03-17 18:26:18 +05:30
|
|
|
statusReason: mockResponseData.applications[3].status_reason,
|
|
|
|
requestReason: null,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
installFailed: true,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
jupyter: {
|
|
|
|
title: 'JupyterHub',
|
|
|
|
status: mockResponseData.applications[4].status,
|
|
|
|
statusReason: mockResponseData.applications[4].status_reason,
|
|
|
|
requestReason: null,
|
|
|
|
hostname: '',
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
installFailed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
knative: {
|
|
|
|
title: 'Knative',
|
|
|
|
status: mockResponseData.applications[5].status,
|
|
|
|
statusReason: mockResponseData.applications[5].status_reason,
|
|
|
|
requestReason: null,
|
|
|
|
hostname: null,
|
2020-04-22 19:07:51 +05:30
|
|
|
isEditingDomain: false,
|
2019-02-15 15:39:39 +05:30
|
|
|
externalIp: null,
|
2019-07-07 11:18:12 +05:30
|
|
|
externalHostname: null,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
installFailed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-09-04 21:01:54 +05:30
|
|
|
updateSuccessful: false,
|
|
|
|
updateFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
|
|
|
cert_manager: {
|
|
|
|
title: 'Cert-Manager',
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
|
|
|
installFailed: true,
|
2019-02-15 15:39:39 +05:30
|
|
|
statusReason: mockResponseData.applications[6].status_reason,
|
|
|
|
requestReason: null,
|
|
|
|
email: mockResponseData.applications[6].email,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
2019-12-26 22:10:19 +05:30
|
|
|
validationError: null,
|
|
|
|
},
|
|
|
|
elastic_stack: {
|
|
|
|
title: 'Elastic Stack',
|
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
|
|
|
installFailed: true,
|
|
|
|
statusReason: mockResponseData.applications[7].status_reason,
|
|
|
|
requestReason: null,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-12-26 22:10:19 +05:30
|
|
|
installed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
|
|
|
validationError: null,
|
|
|
|
},
|
|
|
|
crossplane: {
|
|
|
|
title: 'Crossplane',
|
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
|
|
|
installFailed: true,
|
|
|
|
statusReason: mockResponseData.applications[8].status_reason,
|
|
|
|
requestReason: null,
|
2020-10-24 23:57:45 +05:30
|
|
|
installable: true,
|
2019-12-26 22:10:19 +05:30
|
|
|
installed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
|
|
|
validationError: null,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
cilium: {
|
|
|
|
title: 'GitLab Container Network Policies',
|
|
|
|
status: null,
|
|
|
|
statusReason: null,
|
|
|
|
requestReason: null,
|
|
|
|
installable: false,
|
|
|
|
installed: false,
|
|
|
|
installFailed: false,
|
|
|
|
uninstallable: false,
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
uninstallFailed: false,
|
|
|
|
validationError: null,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2019-12-04 20:38:33 +05:30
|
|
|
environments: [],
|
|
|
|
fetchingEnvironments: false,
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
describe.each(APPLICATION_INSTALLED_STATUSES)(
|
|
|
|
'given the current app status is %s',
|
|
|
|
(status) => {
|
|
|
|
it('marks application as installed', () => {
|
|
|
|
const mockResponseData =
|
|
|
|
CLUSTERS_MOCK_DATA.GET['/gitlab-org/gitlab-shell/clusters/2/status.json'].data;
|
|
|
|
const runnerAppIndex = 2;
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
mockResponseData.applications[runnerAppIndex].status = status;
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
store.updateStateFromServer(mockResponseData);
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(store.state.applications[RUNNER].installed).toBe(true);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it('sets default hostname for jupyter when ingress has a ip address', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
const mockResponseData =
|
|
|
|
CLUSTERS_MOCK_DATA.GET['/gitlab-org/gitlab-shell/clusters/2/status.json'].data;
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
store.updateStateFromServer(mockResponseData);
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(store.state.applications.jupyter.hostname).toEqual(
|
|
|
|
`jupyter.${store.state.applications.ingress.externalIp}.nip.io`,
|
|
|
|
);
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|