Added unit tests on actions

As we had a low test coverage on actions, I added some more tests
with this patchset. This actually revealed a small bug (typo) in
"change_nova_service_state" which has been fixed in here.

Note that Tempest test also cover these action via the
basic_consolidation strategy.

Change-Id: I2d7116a6fdefee82ca254512a9cf50fc61e3c80e
Closes-Bug: #1523513
This commit is contained in:
Vincent Françoise
2016-02-10 14:59:14 +01:00
parent e3198d25a5
commit 55aeb783e3
3 changed files with 256 additions and 67 deletions

View File

@@ -54,9 +54,9 @@ class ChangeNovaServiceState(base.BaseAction):
target_state = None
if self.state == hstate.HypervisorState.OFFLINE.value:
target_state = False
elif self.status == hstate.HypervisorState.ONLINE.value:
elif self.state == hstate.HypervisorState.ONLINE.value:
target_state = True
return self.nova_manage_service(target_state)
return self._nova_manage_service(target_state)
def revert(self):
target_state = None
@@ -64,9 +64,9 @@ class ChangeNovaServiceState(base.BaseAction):
target_state = True
elif self.state == hstate.HypervisorState.ONLINE.value:
target_state = False
return self.nova_manage_service(target_state)
return self._nova_manage_service(target_state)
def nova_manage_service(self, state):
def _nova_manage_service(self, state):
if state is None:
raise exception.IllegalArgumentException(
message=_("The target state is not defined"))