Skip to content

Commit

Permalink
ui/test: update the test for volume
Browse files Browse the repository at this point in the history
should return Ready as status when Ready condition is True

Refs: #2245
  • Loading branch information
ChengYanJin committed Feb 20, 2020
1 parent 8289c56 commit 6807195
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions ui/src/services/NodeVolumesUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
STATUS_PENDING,
STATUS_FAILED,
STATUS_AVAILABLE,
STATUS_READY,
} from '../constants';
import {
computeVolumeGlobalStatus,
Expand Down Expand Up @@ -84,50 +85,50 @@ const testcaseVolumeFailedPvUnknown = {
],
};

const testcaseVolumeAvailablePvFailed = {
rowData: { status: 'Available', name: 'test' },
const testcaseVolumeReadyPvFailed = {
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'test' }, status: { phase: 'Failed' } },
],
};

const testcaseVolumeAvailablePvAvailable = {
rowData: { status: 'Available', name: 'test' },
const testcaseVolumeReadyPvAvailable = {
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'test' }, status: { phase: 'Available' } },
],
};

const testcaseVolumeAvailablePvReleased = {
rowData: { status: 'Available', name: 'test' },
const testcaseVolumeReadyPvReleased = {
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'test' }, status: { phase: 'Released' } },
],
};

const testcaseVolumeAvailablePvPending = {
rowData: { status: 'Available', name: 'test' },
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'test' }, status: { phase: 'Pending' } },
],
};

const testcaseVolumeAvailablePvBound = {
rowData: { status: 'Available', name: 'test' },
const testcaseVolumeReadyPvBound = {
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'test' }, status: { phase: 'Bound' } },
],
};

const testcaseVolumeAvailablePvUnknown = {
rowData: { status: 'Available', name: 'test' },
const testcaseVolumeReadyPvUnknown = {
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'test' }, status: { phase: 'Unknown' } },
],
};

const testcaseVolumeAvailableWithoutPv = {
rowData: { status: 'Available', name: 'test' },
const testcaseVolumeReadyWithoutPv = {
rowData: { status: 'Ready', name: 'test' },
persistentVolumes: [
{ metadata: { name: 'testnoPV' }, status: { phase: 'Available' } },
],
Expand Down Expand Up @@ -216,58 +217,58 @@ it('should return false when volume is failed and PV is unknown', () => {
expect(result).toEqual(false);
});

it('should return true when volume is available and PV is failed', () => {
it('should return true when volume is ready and PV is failed', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailablePvFailed.rowData,
testcaseVolumeAvailablePvFailed.persistentVolumes,
testcaseVolumeReadyPvFailed.rowData,
testcaseVolumeReadyPvFailed.persistentVolumes,
);
expect(result).toEqual(true);
});

it('should return true when volume is available and PV is available', () => {
it('should return true when volume is ready and PV is available', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailablePvAvailable.rowData,
testcaseVolumeAvailablePvAvailable.persistentVolumes,
testcaseVolumeReadyPvAvailable.rowData,
testcaseVolumeReadyPvAvailable.persistentVolumes,
);
expect(result).toEqual(true);
});

it('should return true when volume is available and PV is released', () => {
it('should return true when volume is ready and PV is released', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailablePvReleased.rowData,
testcaseVolumeAvailablePvReleased.persistentVolumes,
testcaseVolumeReadyPvReleased.rowData,
testcaseVolumeReadyPvReleased.persistentVolumes,
);
expect(result).toEqual(true);
});

it('should return false when volume is available and PV is pending', () => {
it('should return false when volume is ready and PV is pending', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailablePvPending.rowData,
testcaseVolumeAvailablePvPending.persistentVolumes,
);
expect(result).toEqual(false);
});

it('should return false when volume is available and PV is bound', () => {
it('should return false when volume is ready and PV is bound', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailablePvBound.rowData,
testcaseVolumeAvailablePvBound.persistentVolumes,
testcaseVolumeReadyPvBound.rowData,
testcaseVolumeReadyPvBound.persistentVolumes,
);
expect(result).toEqual(false);
});

it('should return false when volume is available and PV is unknown', () => {
it('should return false when volume is ready and PV is unknown', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailablePvUnknown.rowData,
testcaseVolumeAvailablePvUnknown.persistentVolumes,
testcaseVolumeReadyPvUnknown.rowData,
testcaseVolumeReadyPvUnknown.persistentVolumes,
);
expect(result).toEqual(false);
});

it('should return false when volume is available and there is no PV', () => {
it('should return false when volume is ready and there is no PV', () => {
const result = isVolumeDeletable(
testcaseVolumeAvailableWithoutPv.rowData,
testcaseVolumeAvailableWithoutPv.persistentVolumes,
testcaseVolumeReadyWithoutPv.rowData,
testcaseVolumeReadyWithoutPv.persistentVolumes,
);
expect(result).toEqual(true);
});
Expand Down Expand Up @@ -301,12 +302,10 @@ it('should return Unkown when volume has no Ready condition', () => {
expect(result).toEqual(STATUS_UNKNOWN);
});

it('should return Available when Ready condition is True', () => {
const volumeStatus = {'conditions': [
{'type': 'Ready', 'status': 'True'}
]};
it('should return Ready when Ready condition is True', () => {
const volumeStatus = { conditions: [{ type: 'Ready', status: 'True' }] };
const result = computeVolumeGlobalStatus('test', volumeStatus);
expect(result).toEqual(STATUS_AVAILABLE);
expect(result).toEqual(STATUS_READY);
});

it('should return Failed when Ready condition is False', () => {
Expand Down

0 comments on commit 6807195

Please sign in to comment.