Skip to content

Commit

Permalink
Merge pull request #1700 from red-hat-storage/master
Browse files Browse the repository at this point in the history
Manual Sync (master & release-4.18)
  • Loading branch information
openshift-merge-bot[bot] authored Nov 21, 2024
2 parents f5fdde6 + 29cb726 commit ec0a05e
Show file tree
Hide file tree
Showing 111 changed files with 874 additions and 835 deletions.
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = {
'react/jsx-curly-newline': 'off',
'react/jsx-indent': 'off',
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
'react/jsx-pascal-case': 'error',
'react/no-unused-prop-types': 'off',
'consistent-return': 'off',
'default-case': 'off',
Expand Down Expand Up @@ -102,6 +103,44 @@ module.exports = {
'jsx-a11y/no-static-element-interactions': 'off',
'max-classes-per-file': 'off',
'max-len': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'enumMember',
format: ['PascalCase', 'UPPER_CASE'],
},
{
selector: 'import',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'objectLiteralMethod',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'parameter',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'property',
format: null,
},
{
selector: 'variable',
// React Components, regular variables, constants.
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'default',
format: ['camelCase'],
},
],
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'error',
'no-empty-pattern': 'off',
Expand Down
8 changes: 5 additions & 3 deletions cypress/constants/storage-pool-const.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export enum POOL_STATE {
export enum PoolState {
READY = 'Ready',
RECONCILE_FAILED = 'ReconcileFailed',
FAILURE = 'Failure',
}

export enum POOL_PROGRESS {
export enum PoolProgress {
CREATED = 'created',
FAILED = 'failed',
PROGRESS = 'progress',
Expand All @@ -15,13 +15,15 @@ export enum POOL_PROGRESS {
BOUNDED = 'bounded',
}

export enum POOL_TYPE {
export enum PoolType {
BLOCK = 'Block',
FILESYSTEM = 'Filesystem',
}

export const COMPRESSION_ON = 'aggressive';
export const ROOK_MODEL = 'cephblockpools.ceph.rook.io';
export const CEPH_BUILTIN_MGR_POOL = 'builtin-mgr';
export const CEPH_BUILTIN_NFS_POOL = 'ocs-storagecluster-cephnfs-builtin-pool';
export const CEPH_DEFAULT_BLOCK_POOL_NAME = 'ocs-storagecluster-cephblockpool';
export const CEPH_DEFAULT_FS_POOL_PREFIX = 'ocs-storagecluster-cephfilesystem';
export const CEPH_DEFAULT_FS_POOL_NAME = `${CEPH_DEFAULT_FS_POOL_PREFIX}-data0`;
2 changes: 1 addition & 1 deletion cypress/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const STORAGECLUSTER_PHASE = `"$(oc get storageclusters -n openshift-storage -o=
)}')"`;
export const OCS_SC_STATE = `until [ ${STORAGECLUSTER_PHASE} = "Ready" ]; do sleep 1; done;`;

export enum CLUSTER_STATUS {
export enum ClusterStatus {
READY = 'Ready',
PROGRESSING = 'Progressing',
HEALTH_ERROR = 'HEALTH_ERR',
Expand Down
4 changes: 4 additions & 0 deletions cypress/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Cypress.Commands.add('install', () => {
cy.contains('Create StorageSystem', { timeout: 15 * SECOND }).should(
'be.visible'
);

// Uncomment next line only if the cluster has enough resources.
// cy.get('label[for="enable-nfs"]').click();

cy.get('button').contains('Next').click();
// @TODO: Do we still want to uncheck the already unchecked 'Taint nodes' checkbox?
// If yes, we should scroll down (needed after adding the performance profile selection)
Expand Down
6 changes: 3 additions & 3 deletions cypress/tests/add-capacity.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from 'lodash-es';
import {
CLUSTER_STATUS,
ClusterStatus,
STORAGE_SYSTEM_NAME,
STORAGE_CLUSTER_NAME,
CLUSTER_NAMESPACE,
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('OCS Operator Expansion of Storage Class Test', () => {

cy.log('Check if ceph cluster is healthy before expansion');
expect(cephCluster.status.ceph.health).not.to.equal(
CLUSTER_STATUS.HEALTH_ERROR
ClusterStatus.HEALTH_ERROR
);
});
cy.exec(
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('OCS Operator Expansion of Storage Class Test', () => {

cy.log('Check if ceph cluster is healthy after expansion');
expect(cephCluster.status.ceph.health).to.not.equal(
CLUSTER_STATUS.HEALTH_ERROR
ClusterStatus.HEALTH_ERROR
);
});
cy.exec(`oc get po -n ${CLUSTER_NAMESPACE} -o json`).then((res) => {
Expand Down
42 changes: 24 additions & 18 deletions cypress/tests/storage-pool-in-storageclass-form.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
CEPH_BUILTIN_MGR_POOL,
CEPH_BUILTIN_NFS_POOL,
CEPH_DEFAULT_FS_POOL_PREFIX,
POOL_TYPE,
PoolType,
} from '../constants/storage-pool-const';
import {
deleteBlockPoolFromCLI,
Expand All @@ -9,45 +11,49 @@ import {
createStoragePoolInSCForm,
fillPoolModalForm,
checkStoragePoolIsSelectableInSCForm,
showAvailablePoolsInSCForm,
} from '../views/storage-pool';

describe('Test storage pool creation when creating a new StorageClass', () => {
it(`Creates a new ${POOL_TYPE.BLOCK} pool`, () => {
const poolName = 'sc-block-name';

beforeEach(() => {
cy.clickNavLink(['Storage', 'StorageClasses']);
cy.byTestID('item-create').click();
});

it(`does not show hidden pools`, () => {
showAvailablePoolsInSCForm(PoolType.BLOCK);
cy.byTestID(CEPH_BUILTIN_MGR_POOL).should('not.exist');
cy.byTestID(CEPH_BUILTIN_NFS_POOL).should('not.exist');
});

it(`Creates a new ${PoolType.BLOCK} pool`, () => {
const poolName = 'sc-block-name';

cy.log(`Create a new ${POOL_TYPE.BLOCK} pool`);
createStoragePoolInSCForm(POOL_TYPE.BLOCK, poolName);
cy.log(`Create a new ${PoolType.BLOCK} pool`);
createStoragePoolInSCForm(PoolType.BLOCK, poolName);
checkStoragePoolIsSelectableInSCForm(poolName);
verifyBlockPoolJSON(poolName);

cy.log(
`Try to create a new ${POOL_TYPE.BLOCK} pool using an existing name`
);
fillPoolModalForm(POOL_TYPE.BLOCK, poolName);
cy.log(`Try to create a new ${PoolType.BLOCK} pool using an existing name`);
fillPoolModalForm(PoolType.BLOCK, poolName);
cy.byLegacyTestID('confirm-action').should('be.disabled');
cy.byLegacyTestID('modal-cancel-action').click();

deleteBlockPoolFromCLI(poolName);
});

it(`Creates a new ${POOL_TYPE.FILESYSTEM} pool`, () => {
it(`Creates a new ${PoolType.FILESYSTEM} pool`, () => {
const poolName = 'sc-fs-name';
const poolFullName = `${CEPH_DEFAULT_FS_POOL_PREFIX}-${poolName}`;

cy.clickNavLink(['Storage', 'StorageClasses']);
cy.byTestID('item-create').click();

cy.log(`Create a new ${POOL_TYPE.FILESYSTEM} pool`);
createStoragePoolInSCForm(POOL_TYPE.FILESYSTEM, poolName);
cy.log(`Create a new ${PoolType.FILESYSTEM} pool`);
createStoragePoolInSCForm(PoolType.FILESYSTEM, poolName);
checkStoragePoolIsSelectableInSCForm(poolFullName);

cy.log(
`Try to create a new ${POOL_TYPE.FILESYSTEM} pool using an existing name`
`Try to create a new ${PoolType.FILESYSTEM} pool using an existing name`
);
fillPoolModalForm(POOL_TYPE.FILESYSTEM, poolName);
fillPoolModalForm(PoolType.FILESYSTEM, poolName);
cy.byLegacyTestID('confirm-action').should('be.disabled');
cy.byLegacyTestID('modal-cancel-action').click();

Expand Down
24 changes: 12 additions & 12 deletions cypress/tests/storage-pool.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
POOL_PROGRESS,
PoolProgress,
CEPH_DEFAULT_BLOCK_POOL_NAME,
POOL_TYPE,
PoolType,
CEPH_DEFAULT_FS_POOL_NAME,
CEPH_DEFAULT_FS_POOL_PREFIX,
} from '../constants/storage-pool-const';
Expand Down Expand Up @@ -30,9 +30,9 @@ describe('Block pool on ODF UI', () => {
});

it('Check for a new pool creation', () => {
createStoragePool(POOL_TYPE.BLOCK, poolName);
createStoragePool(PoolType.BLOCK, poolName);
app.waitForLoad();
cy.log(`Verify ${POOL_TYPE.BLOCK} pool creation`);
cy.log(`Verify ${PoolType.BLOCK} pool creation`);
cy.byTestID('status-text').should('contain', 'Ready', {
timeout: 2 * 60000,
});
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('Block pool on ODF UI', () => {
it('Test updating/deleting a default block pool is not allowed', () => {
cy.log('Kebab action should be disabled');
openStoragePoolKebab(CEPH_DEFAULT_BLOCK_POOL_NAME, true);
cy.log(poolMessage(poolName, POOL_PROGRESS.NOTALLOWED));
cy.log(poolMessage(poolName, PoolProgress.NOTALLOWED));
});

it('deletion of a non-default pool deletion pool is successful', () => {
Expand All @@ -80,10 +80,10 @@ describe('Block pool on ODF UI', () => {

cy.contains('Delete Storage Pool');
cy.byTestID('pool-bound-message').contains(
poolMessage(poolName, POOL_PROGRESS.BOUNDED)
poolMessage(poolName, PoolProgress.BOUNDED)
);
cy.byTestID('pool-storage-classes').contains(scName);
triggerPoolFormFooterAction(POOL_PROGRESS.BOUNDED);
triggerPoolFormFooterAction(PoolProgress.BOUNDED);

cy.log('Delete pvc and storage class, then try pool deletion');
cy.exec(`oc delete pvc ${pvcName} -n default`, {
Expand All @@ -106,7 +106,7 @@ describe('Tests form validations on block pool', () => {
});

fieldValidationOnWizardFormsTests(nameFieldTestId, 'Create', () =>
fillStoragePoolForm(POOL_TYPE.BLOCK, 'test-name')
fillStoragePoolForm(PoolType.BLOCK, 'test-name')
);
});

Expand All @@ -119,15 +119,15 @@ describe('Filesystem pool on ODF UI', () => {
});

it('creates a new pool', () => {
createStoragePool(POOL_TYPE.FILESYSTEM, poolName);
createStoragePool(PoolType.FILESYSTEM, poolName);

cy.log(`Verify ${POOL_TYPE.FILESYSTEM} pool creation`);
cy.log(`Verify ${PoolType.FILESYSTEM} pool creation`);
cy.byTestID(`${poolFullName}-replicas`).contains('2');
cy.byTestID(`${poolFullName}-compression`).contains('Enabled');
});

it(`updates a non-default pool`, () => {
cy.log(`Updating a newly created ${POOL_TYPE.FILESYSTEM} pool`);
cy.log(`Updating a newly created ${PoolType.FILESYSTEM} pool`);
openStoragePoolKebab(poolFullName);
cy.byTestActionID('Edit Pool').click();
cy.contains('Edit Storage Pool');
Expand All @@ -152,6 +152,6 @@ describe('Filesystem pool on ODF UI', () => {
it('actions on the default pool are not allowed', () => {
cy.log('Kebab action should be disabled');
openStoragePoolKebab(CEPH_DEFAULT_FS_POOL_NAME, true);
cy.log(poolMessage[POOL_PROGRESS.NOTALLOWED]);
cy.log(poolMessage[PoolProgress.NOTALLOWED]);
});
});
49 changes: 8 additions & 41 deletions cypress/views/block-pool.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import {
CEPH_DEFAULT_BLOCK_POOL_NAME,
POOL_PROGRESS,
PoolProgress,
} from '../constants/storage-pool-const';
import { STORAGE_SYSTEM_NAME } from '../consts';
import { app } from '../support/pages/app';
import { NS } from '../utils/consts';
import { ODFCommon } from '../views/odf-common';
import { triggerPoolFormFooterAction } from './storage-pool';

// Pool var
export const poolName: string = 'example.pool';
export const replicaCount: string = '2';
export const scName: string = 'testing-sc';

export const poolMessage: {
[key in POOL_PROGRESS]?: string;
[key in PoolProgress]?: string;
} = {
[POOL_PROGRESS.FAILED]: `Pool "${poolName}" already exists`,
[POOL_PROGRESS.CREATED]: `Pool ${poolName} was successfully created`,
[POOL_PROGRESS.NOTALLOWED]:
[PoolProgress.FAILED]: `Pool "${poolName}" already exists`,
[PoolProgress.CREATED]: `Pool ${poolName} was successfully created`,
[PoolProgress.NOTALLOWED]:
"Pool management tasks are not supported for default pool and ODF's external mode.",
[POOL_PROGRESS.BOUNDED]: `${poolName} cannot be deleted. When a pool is bounded to PVC it cannot be deleted. Please detach all the resources from StorageClass(es):`,
[PoolProgress.BOUNDED]: `${poolName} cannot be deleted. When a pool is bounded to PVC it cannot be deleted. Please detach all the resources from StorageClass(es):`,
};

export const navigateToBlockPool = () => {
Expand All @@ -40,40 +41,6 @@ export const populateBlockPoolForm = () => {
cy.byTestID('compression-checkbox').check();
};

export enum Actions {
created = 'created',
failed = 'failed',
notAllowed = 'notAllowed',
bound = 'bounded',
}

export const verifyFooterActions = (action: string) => {
switch (action) {
case Actions.failed:
cy.log('Check try-again-action and finish-action are enabled');
cy.byLegacyTestID('modal-try-again-action').should('be.visible');
cy.byLegacyTestID('modal-finish-action').click();
break;
case Actions.created:
cy.log('Check finish-action is enabled');
cy.byLegacyTestID('modal-finish-action').click();
break;
case Actions.notAllowed:
cy.log('Check close-action is enabled');
cy.byLegacyTestID('modal-close-action').click();
break;
case Actions.bound:
cy.log('Check go-to-pvc-list-action and close-action are enabled');
cy.byLegacyTestID('modal-go-to-pvc-list-action').should('be.visible');
cy.byLegacyTestID('modal-close-action').click();
break;
default:
cy.log(`Invoke ${action} action`);
cy.byLegacyTestID('confirm-action').scrollIntoView();
cy.byLegacyTestID('confirm-action').click();
}
};

export const verifyBlockPoolJSON = (
compressionEnabled: boolean = true,
replica: string = replicaCount
Expand All @@ -100,7 +67,7 @@ export const verifyBlockPoolJSON = (
export const createBlockPool = () => {
cy.byTestID('item-create').click();
populateBlockPoolForm();
verifyFooterActions('create');
triggerPoolFormFooterAction('create');
app.waitForLoad();
cy.log('Verify a new block pool creation');
cy.byTestID('status-text').should('contain', 'Ready', { timeout: 2 * 60000 });
Expand Down
Loading

0 comments on commit ec0a05e

Please sign in to comment.