Commit 267e5195 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: More tests for ComputePartition_checkAllocatedSlaState

parent f3002bee
Pipeline #38291 failed with stage
in 0 seconds
compute_partition = context compute_partition = context
sla_error_list = []
compute_node = compute_partition.getParentValue() compute_node = compute_partition.getParentValue()
assert compute_node.getPortalType() == 'Compute Node' assert compute_node.getPortalType() == 'Compute Node'
instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance') instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance')
assert instance is not None, 'Instance is None' assert instance is not None, 'Instance is None'
assert instance.getValidationState() != 'validated', 'Instance is invalid' if instance.getValidationState() != 'validated' or \
instance.getSlapState() == 'destroy_requested':
# Outdated catalog or instance under garbage collection,
# we skip for now.
return sla_error_list
sla_error_list = []
sla_dict = instance.getSlaXmlAsDict() sla_dict = instance.getSlaXmlAsDict()
if not sla_dict: if not sla_dict:
return sla_error_list return sla_error_list
......
...@@ -5,7 +5,11 @@ assert compute_node.getPortalType() == 'Compute Node' ...@@ -5,7 +5,11 @@ assert compute_node.getPortalType() == 'Compute Node'
instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance') instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance')
assert instance is not None, 'Instance is None' assert instance is not None, 'Instance is None'
assert instance.getValidationState() != 'validated', 'Instance is invalid' if instance.getValidationState() != 'validated' or \
instance.getSlapState() == 'destroy_requested':
# Outdated catalog or instance under garbage collection,
# we skip for now.
return
project = instance.getFollowUpValue() project = instance.getFollowUpValue()
assert project is not None, 'Project is None' assert project is not None, 'Project is None'
......
...@@ -98,7 +98,29 @@ class TestSlapOSCrmCheckProjectAllocationConsistencyState(TestSlapOSCrmMonitorin ...@@ -98,7 +98,29 @@ class TestSlapOSCrmCheckProjectAllocationConsistencyState(TestSlapOSCrmMonitorin
self._test_alarm_not_visited(alarm, self.compute_node, self._test_alarm_not_visited(alarm, self.compute_node,
"ComputeNode_checkProjectAllocationConsistencyState") "ComputeNode_checkProjectAllocationConsistencyState")
################################################################################ def test_ComputeNode_checkProjectAllocationConsistencyState_alarm_2_node_1_call(self):
project = self.addProject()
self._makeComputeNode(project)
compute_node_a = self.compute_node
compute_node_a.edit(monitor_scope='enabled')
self._makeComputeNode(project)
compute_node_b = self.compute_node
compute_node_b.edit(monitor_scope='enabled')
self.assertNotEqual(compute_node_a.getUid(), compute_node_b.getUid())
self.tic()
alarm = self.portal.portal_alarms.slapos_crm_project_allocation_consistency
script_name = "ComputeNode_checkProjectAllocationConsistencyState"
with TemporaryAlarmScript(self.portal, script_name, attribute=None):
alarm.activeSense()
self.tic()
content_a = compute_node_a.workflow_history['edit_workflow'][-1]['comment']
content_b = compute_node_b.workflow_history['edit_workflow'][-1]['comment']
# The alarm should group by project, so only one out of many should reached.
self.assertNotEqual(content_a, content_b)
self.assertIn('Visited by %s' % script_name, [content_a, content_b])
class TestSlapOSCrmMonitoringCheckComputeNodeProjectState(TestSlapOSCrmMonitoringMixin): class TestSlapOSCrmMonitoringCheckComputeNodeProjectState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1 launch_caucase = 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment