diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-09 21:08:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-09 21:08:21 +0000 |
commit | 64786982930713d095ccd3aebd812182a1879fed (patch) | |
tree | 542e79df02f79049d8a63b31388c7d1e3e3b9166 /spec/frontend/clusters_list | |
parent | 3d0474695407d24d49bb94f29a182739ee35e1f8 (diff) | |
download | gitlab-ce-64786982930713d095ccd3aebd812182a1879fed.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/clusters_list')
-rw-r--r-- | spec/frontend/clusters_list/components/clusters_spec.js | 62 | ||||
-rw-r--r-- | spec/frontend/clusters_list/mock_data.js | 28 |
2 files changed, 85 insertions, 5 deletions
diff --git a/spec/frontend/clusters_list/components/clusters_spec.js b/spec/frontend/clusters_list/components/clusters_spec.js index 9f76078a69a..3a5c4c4c008 100644 --- a/spec/frontend/clusters_list/components/clusters_spec.js +++ b/spec/frontend/clusters_list/components/clusters_spec.js @@ -5,6 +5,7 @@ import MockAdapter from 'axios-mock-adapter'; import { apiData } from '../mock_data'; import { mount } from '@vue/test-utils'; import { GlLoadingIcon, GlTable, GlPagination } from '@gitlab/ui'; +import * as Sentry from '@sentry/browser'; describe('Clusters', () => { let mock; @@ -36,7 +37,11 @@ describe('Clusters', () => { }; }; + let captureException; + beforeEach(() => { + captureException = jest.spyOn(Sentry, 'captureException'); + mock = new MockAdapter(axios); mockPollingApi(200, apiData, paginationHeader()); @@ -46,6 +51,7 @@ describe('Clusters', () => { afterEach(() => { wrapper.destroy(); mock.restore(); + captureException.mockRestore(); }); describe('clusters table', () => { @@ -106,8 +112,8 @@ describe('Clusters', () => { ${'Unknown'} | ${0} ${'1'} | ${1} ${'2'} | ${2} - ${'Unknown'} | ${3} - ${'Unknown'} | ${4} + ${'1'} | ${3} + ${'1'} | ${4} ${'Unknown'} | ${5} `('renders node size for each cluster', ({ nodeSize, lineNumber }) => { const sizes = findTable().findAll('td:nth-child(3)'); @@ -115,6 +121,58 @@ describe('Clusters', () => { expect(size.text()).toBe(nodeSize); }); + + describe('nodes with unknown quantity', () => { + it('notifies Sentry about all missing quantity types', () => { + expect(captureException).toHaveBeenCalledTimes(8); + }); + + it('notifies Sentry about CPU missing quantity types', () => { + const missingCpuTypeError = new Error('UnknownK8sCpuQuantity:1missingCpuUnit'); + + expect(captureException).toHaveBeenCalledWith(missingCpuTypeError); + }); + + it('notifies Sentry about Memory missing quantity types', () => { + const missingMemoryTypeError = new Error('UnknownK8sMemoryQuantity:1missingMemoryUnit'); + + expect(captureException).toHaveBeenCalledWith(missingMemoryTypeError); + }); + }); + }); + + describe('cluster CPU', () => { + it.each` + clusterCpu | lineNumber + ${''} | ${0} + ${'1.93 (87% free)'} | ${1} + ${'3.87 (86% free)'} | ${2} + ${'(% free)'} | ${3} + ${'(% free)'} | ${4} + ${''} | ${5} + `('renders total cpu for each cluster', ({ clusterCpu, lineNumber }) => { + const clusterCpus = findTable().findAll('td:nth-child(4)'); + const cpuData = clusterCpus.at(lineNumber); + + expect(cpuData.text()).toBe(clusterCpu); + }); + }); + + describe('cluster Memory', () => { + it.each` + clusterMemory | lineNumber + ${''} | ${0} + ${'5.92 (78% free)'} | ${1} + ${'12.86 (79% free)'} | ${2} + ${'(% free)'} | ${3} + ${'(% free)'} | ${4} + ${''} | ${5} + `('renders total memory for each cluster', ({ clusterMemory, lineNumber }) => { + const clusterMemories = findTable().findAll('td:nth-child(5)'); + const memoryData = clusterMemories.at(lineNumber); + + expect(memoryData.text()).toBe(clusterMemory); + }); }); describe('pagination', () => { diff --git a/spec/frontend/clusters_list/mock_data.js b/spec/frontend/clusters_list/mock_data.js index 6ce0aa90f10..eb8582796f7 100644 --- a/spec/frontend/clusters_list/mock_data.js +++ b/spec/frontend/clusters_list/mock_data.js @@ -11,7 +11,12 @@ export const clusterList = [ environment_scope: 'development', cluster_type: 'project_type', status: 'unreachable', - nodes: [{ usage: { cpu: '246155922n', memory: '1255212Ki' } }], + nodes: [ + { + status: { allocatable: { cpu: '1930m', memory: '5777156Ki' } }, + usage: { cpu: '246155922n', memory: '1255212Ki' }, + }, + ], }, { name: 'My Cluster 3', @@ -19,8 +24,14 @@ export const clusterList = [ cluster_type: 'project_type', status: 'authentication_failure', nodes: [ - { usage: { cpu: '246155922n', memory: '1255212Ki' } }, - { usage: { cpu: '307051934n', memory: '1379136Ki' } }, + { + status: { allocatable: { cpu: '1930m', memory: '5777156Ki' } }, + usage: { cpu: '246155922n', memory: '1255212Ki' }, + }, + { + status: { allocatable: { cpu: '1940m', memory: '6777156Ki' } }, + usage: { cpu: '307051934n', memory: '1379136Ki' }, + }, ], }, { @@ -28,12 +39,23 @@ export const clusterList = [ environment_scope: 'production', cluster_type: 'project_type', status: 'deleting', + nodes: [ + { + status: { allocatable: { cpu: '1missingCpuUnit', memory: '1missingMemoryUnit' } }, + usage: { cpu: '1missingCpuUnit', memory: '1missingMemoryUnit' }, + }, + ], }, { name: 'My Cluster 5', environment_scope: 'development', cluster_type: 'project_type', status: 'created', + nodes: [ + { + status: { allocatable: { cpu: '1missingCpuUnit', memory: '1missingMemoryUnit' } }, + }, + ], }, { name: 'My Cluster 6', |