Skip to content

Commit

Permalink
Add e2e test to check default grafana storage size for statefulset ty…
Browse files Browse the repository at this point in the history
…pe (rancher#10933)

* add e2e test to check default grafana storage size for statefulset type

* make default grafana size reusable for both pvc and statefulset types

---------

Co-authored-by: Mo Mesgin <mmesgin@Mos-M2-MacBook-Pro.local>
  • Loading branch information
momesgin and Mo Mesgin authored May 2, 2024
1 parent 8a94b71 commit 6ca6174
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
13 changes: 13 additions & 0 deletions cypress/e2e/po/pages/explorer/charts/tabs/grafana-tab.po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ComponentPo from '@/cypress/e2e/po/components/component.po';
import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po';
import RadioGroupInputPo from '@/cypress/e2e/po/components/radio-group-input.po';

export class GrafanaTab extends ComponentPo {
constructor(selector = '.dashboard-root') {
Expand All @@ -21,4 +22,16 @@ export class GrafanaTab extends ComponentPo {
memoryLimit(): LabeledInputPo {
return new LabeledInputPo('[data-testid="input-grafana-limits-memory"]');
}

storageOptions(): RadioGroupInputPo {
return new RadioGroupInputPo('[data-testid="radio-group-input-grafana-storage"');
}

storagePvcSizeInput(): LabeledInputPo {
return new LabeledInputPo('[data-testid="grafana-storage-pvc-size"');
}

storageStatefulsetSizeInput(): LabeledInputPo {
return new LabeledInputPo('[data-testid="grafana-storage-statefulset-size"');
}
}
15 changes: 15 additions & 0 deletions cypress/e2e/tests/pages/charts/monitoring-istio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ChartsPage } from '@/cypress/e2e/po/pages/explorer/charts/charts.po';
import { InstallChartPage } from '@/cypress/e2e/po/pages/explorer/charts/install-charts.po';
import { PrometheusTab } from '@/cypress/e2e/po/pages/explorer/charts/tabs/prometheus-tab.po';
import { GrafanaTab } from '@/cypress/e2e/po/pages/explorer/charts/tabs/grafana-tab.po';
import { DEFAULT_GRAFANA_STORAGE_SIZE } from '@shell/config/types.js';

describe('Charts', { tags: ['@charts', '@adminUser'] }, () => {
const chartsPage = new ChartsPage();
Expand Down Expand Up @@ -172,6 +173,20 @@ describe('Charts', { tags: ['@charts', '@adminUser'] }, () => {
grafana.memoryLimit().checkVisible();
grafana.memoryLimit().set('123Mi');

// Check default Grafana storage value for pvc and statefulset types
// pvc
grafana.storageOptions().set(2);
grafana.storagePvcSizeInput().checkExists();
grafana.storagePvcSizeInput().checkVisible();
grafana.storagePvcSizeInput().self().invoke('val').should('equal', DEFAULT_GRAFANA_STORAGE_SIZE);
// statefulset
grafana.storageOptions().set(3);
grafana.storageStatefulsetSizeInput().checkExists();
grafana.storageStatefulsetSizeInput().checkVisible();
grafana.storageStatefulsetSizeInput().self().invoke('val').should('equal', DEFAULT_GRAFANA_STORAGE_SIZE);
// back to disabled
grafana.storageOptions().set(0);

// Click on YAML. In YAML mode, the prometheus selector is present but empty
// It should not be sent to the API
installChart.editYaml();
Expand Down
8 changes: 6 additions & 2 deletions shell/chart/monitoring/grafana/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import LabeledSelect from '@shell/components/form/LabeledSelect';
import KeyValue from '@shell/components/form/KeyValue';
import ArrayList from '@shell/components/form/ArrayList';
import StorageClassSelector from '@shell/chart/monitoring/StorageClassSelector';
import { DEFAULT_GRAFANA_STORAGE_SIZE } from '@shell/config/types';
export default {
components: {
Expand Down Expand Up @@ -139,7 +140,7 @@ export default {
newValsOut = {
accessModes: null,
storageClassName: null,
size: '10Gi',
size: DEFAULT_GRAFANA_STORAGE_SIZE,
subPath: null,
type: 'pvc',
annotations: null,
Expand All @@ -151,7 +152,7 @@ export default {
newValsOut = {
accessModes: null,
storageClassName: null,
size: '10Gi',
size: DEFAULT_GRAFANA_STORAGE_SIZE,
subPath: null,
type: 'statefulset',
enabled: true,
Expand Down Expand Up @@ -236,6 +237,7 @@ export default {
:labels="persistentStorageTypeLabels"
:mode="mode"
:options="persistentStorageTypes"
data-testid="radio-group-input-grafana-storage"
/>
</div>
</div>
Expand All @@ -259,6 +261,7 @@ export default {
v-model="value.grafana.persistence.size"
:label="t('monitoring.grafana.storage.size')"
:mode="mode"
data-testid="grafana-storage-pvc-size"
/>
</div>
<div class="col span-6">
Expand Down Expand Up @@ -325,6 +328,7 @@ export default {
v-model="value.grafana.persistence.size"
:label="t('monitoring.grafana.storage.size')"
:mode="mode"
data-testid="grafana-storage-statefulset-size"
/>
</div>
<div class="col span-6">
Expand Down
2 changes: 2 additions & 0 deletions shell/config/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,5 @@ export const AUTH_TYPE = {
};

export const LOCAL_CLUSTER = 'local';

export const DEFAULT_GRAFANA_STORAGE_SIZE = '10Gi';

0 comments on commit 6ca6174

Please sign in to comment.