diff --git a/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkProjectAllocationConsistencyState.py b/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkProjectAllocationConsistencyState.py index 9290d3d75c4a8ff2db6c5cc04ac271f937e30456..106f1bab3b98d3c9a287a88e0a716d4251ef4bf5 100644 --- a/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkProjectAllocationConsistencyState.py +++ b/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkProjectAllocationConsistencyState.py @@ -1,20 +1,14 @@ -from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery - portal = context.getPortalObject() monitor_enabled_category = portal.restrictedTraverse( "portal_categories/monitor_scope/enabled", None) -portal = context.getPortalObject() portal.portal_catalog.searchAndActivate( + portal_type='Compute Node', validation_state='validated', method_id='ComputeNode_checkProjectAllocationConsistencyState', - node=ComplexQuery( - SimpleQuery(portal_type='Compute Node'), - SimpleQuery(monitor_scope__uid=monitor_enabled_category.getUid()), - logical_operator='and' - ), + monitor_scope__uid=monitor_enabled_category.getUid(), group_by=['follow_up_uid'], method_kw={'tag': tag}, - activate_kw={'tag': tag, 'priority': 2} + activate_kw={'tag': tag, 'priority': 2} ) context.activate(after_tag=tag).getId() diff --git a/master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py b/master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py index b2400be5c53bee9235df385dc32c1d223118aa4b..78b65622e86d928934b6f1036bab75e79066584a 100644 --- a/master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py +++ b/master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py @@ -47,6 +47,58 @@ class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort): return support_request_list[0] return None +class TestSlapOSCrmCheckProjectAllocationConsistencyState(TestSlapOSCrmMonitoringMixin): + launch_caucase = 1 + + ########################################################################## + # slapos_crm_project_allocation_consistency > ComputeNode_checkMonitoringState + ########################################################################## + def test_ComputeNode_checkProjectAllocationConsistencyState_alarm_remoteNode(self): + compute_node, _ = self.addComputeNodeAndPartition(self.addProject(), + portal_type='Remote Node') + self.tic() + alarm = self.portal.portal_alarms.slapos_crm_project_allocation_consistency + self._test_alarm_not_visited(alarm, compute_node, + "ComputeNode_checkProjectAllocationConsistencyState") + + def test_ComputeNode_checkProjectAllocationConsistencyState_alarm_monitoredComputeNodeState(self): + self._makeComputeNode(self.addProject()) + self.tic() + self.assertEqual(self.compute_node.getMonitorScope(), "enabled") + alarm = self.portal.portal_alarms.slapos_crm_project_allocation_consistency + self._test_alarm(alarm, self.compute_node, + "ComputeNode_checkProjectAllocationConsistencyState") + + def test_ComputeNode_checkProjectAllocationConsistencyState_alarm_close_forever(self): + self._makeComputeNode(self.addProject()) + # Set close forever disabled monitor + self.compute_node.edit(allocation_scope='close/forever') + self.tic() + self.assertEqual(self.compute_node.getMonitorScope(), "disabled") + alarm = self.portal.portal_alarms.slapos_crm_project_allocation_consistency + self._test_alarm_not_visited(alarm, self.compute_node, + "ComputeNode_checkProjectAllocationConsistencyState") + + def test_ComputeNode_checkProjectAllocationConsistencyState_alarm_disabledMonitor(self): + self._makeComputeNode(self.addProject()) + self.compute_node.edit(allocation_scope='open', + monitor_scope='disabled') + self.tic() + self.login() + alarm = self.portal.portal_alarms.slapos_crm_project_allocation_consistency + self._test_alarm_not_visited(alarm, self.compute_node, + "ComputeNode_checkProjectAllocationConsistencyState") + + def test_ComputeNode_checkProjectAllocationConsistencyState_alarm_invalidated(self): + self._makeComputeNode(self.addProject()) + self.compute_node.invalidate() + self.tic() + self.login() + alarm = self.portal.portal_alarms.slapos_crm_project_allocation_consistency + self._test_alarm_not_visited(alarm, self.compute_node, + "ComputeNode_checkProjectAllocationConsistencyState") + +################################################################################ class TestSlapOSCrmMonitoringCheckComputeNodeProjectState(TestSlapOSCrmMonitoringMixin): launch_caucase = 1