Shubhendu Tripathi has posted comments on this change.
Change subject: gluster: Added additional can do action check
......................................................................
Patch Set 4:
(9 comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/gluster/GlusterBrickValidator.java
Line 101: }
Line 102:
Line 103: public ValidationResult
canStopOrCommitRemoveBrick(GlusterVolumeEntity volumeEntity,
List<GlusterBrickEntity> paramBricks) {
Line 104: GlusterAsyncTask asyncTask = volumeEntity.getAsyncTask();
Line 105: if (asyncTask != null && asyncTask.getType() ==
GlusterTaskType.REMOVE_BRICK) {
will do that
Line 106: if (paramBricks.isEmpty()) {
Line 107: return new
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED);
Line 108: }
Line 109:
Line 111: if (paramBricks.size() != bricksForTask.size()) {
Line 112: return new
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_PARAMS_INVALID);
Line 113: }
Line 114:
Line 115: int counter = 0;
will do
Line 116: for (GlusterBrickEntity paramBrick : paramBricks) {
Line 117: for (GlusterBrickEntity brick : bricksForTask) {
Line 118: // If parameter brick directory matches with any
brick no need to continue further to check
Line 119: if
(paramBrick.getBrickDirectory().equals(brick.getBrickDirectory()) &&
paramBrick.getServerId() == brick.getServerId()) {
Line 115: int counter = 0;
Line 116: for (GlusterBrickEntity paramBrick : paramBricks) {
Line 117: for (GlusterBrickEntity brick : bricksForTask) {
Line 118: // If parameter brick directory matches with any
brick no need to continue further to check
Line 119: if
(paramBrick.getBrickDirectory().equals(brick.getBrickDirectory()) &&
paramBrick.getServerId() == brick.getServerId()) {
will do that
Line 120: break;
Line 121: }
Line 122: counter++;
Line 123: // If the bricks list exhausted, it means the
parameter brick does found, throw an error
Line 116: for (GlusterBrickEntity paramBrick : paramBricks) {
Line 117: for (GlusterBrickEntity brick : bricksForTask) {
Line 118: // If parameter brick directory matches with any
brick no need to continue further to check
Line 119: if
(paramBrick.getBrickDirectory().equals(brick.getBrickDirectory()) &&
paramBrick.getServerId() == brick.getServerId()) {
Line 120: break;
will do
Line 121: }
Line 122: counter++;
Line 123: // If the bricks list exhausted, it means the
parameter brick does found, throw an error
Line 124: if (counter == bricksForTask.size()) {
Line 123: // If the bricks list exhausted, it means the
parameter brick does found, throw an error
Line 124: if (counter == bricksForTask.size()) {
Line 125: return new
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_PARAMS_INVALID);
Line 126: }
Line 127: }
will do
Line 128: }
Line 129: }
Line 130:
Line 131: return ValidationResult.VALID;
....................................................
File
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/AbstractRemoveGlusterVolumeBricksCommandTest.java
Line 56: brick2.setBrickDirectory("/tmp/test-vol122");
Line 57: brick2.setStatus(GlusterStatus.UP);
Line 58: bricks.add(brick2);
Line 59: return bricks;
Line 60: }
brick dir names are different so they are invalid names which are not there in
bricks for the task
Line 61:
Line 62: protected Object getvolumeWithoutRemoveBricksTask(Guid volumeId) {
Line 63: GlusterVolumeEntity volume =
getVolumeWithRemoveBricksTask(volumeId);
Line 64: volume.getAsyncTask().setType(null);
Line 58: bricks.add(brick2);
Line 59: return bricks;
Line 60: }
Line 61:
Line 62: protected Object getvolumeWithoutRemoveBricksTask(Guid volumeId) {
This method is used in stop and commit remove brick command test classes
Line 63: GlusterVolumeEntity volume =
getVolumeWithRemoveBricksTask(volumeId);
Line 64: volume.getAsyncTask().setType(null);
Line 65: return volume;
Line 66: }
Line 97: brick.setStatus(GlusterStatus.UP);
Line 98: bricks.add(brick);
Line 99: }
Line 100: return bricks;
Line 101: }
this method takes no of bricks to be created and brick dir name is always
suffuxed with counter value. In the method getInvalidBricks() the intention is
to create bricks with names which are not part of bricks list for the task. the
names are created with suffixes "11" and "22".
Line 102:
Line 103: abstract protected GlusterVolumeEntity
getVolumeWithRemoveBricksTask(Guid volumeId);
....................................................
File
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CommitRemoveGlusterVolumeBricksCommandTest.java
Line 211: assertFalse(cmd.canDoAction());
Line 212: }
Line 213:
Line 214: @Test
Line 215: public void canDoActionFailsWithInvalidParams() {
will do
Line 216: List<GlusterBrickEntity> paramBricks1 =
getInvalidNoOfBricks(volumeWithRemoveBricksTask);
Line 217: cmd = spy(new CommitRemoveGlusterVolumeBricksCommand(new
GlusterVolumeRemoveBricksParameters(volumeWithRemoveBricksTask, paramBricks1)));
Line 218: prepareMocks(cmd);
Line 219: assertFalse(cmd.canDoAction());
--
To view, visit http://gerrit.ovirt.org/22353
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Id7f5d3b48985552aa5f74178008beb39ee7a06f9
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shubhendu Tripathi <[email protected]>
Gerrit-Reviewer: Kanagaraj M <[email protected]>
Gerrit-Reviewer: Omer Frenkel <[email protected]>
Gerrit-Reviewer: Sahina Bose <[email protected]>
Gerrit-Reviewer: Shubhendu Tripathi <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches