Commit ac424d91 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: fixes and tests for SLA related tickets.

parent 035e7b8b
Pipeline #38410 failed with stage
in 0 seconds
......@@ -50,8 +50,15 @@ if context.getPortalType() == 'Slave Instance' and compute_node.getPortalType()
sla_dict = context.getSlaXmlAsDict()
instance_sla_error_list = []
instance_project_reference = context.getFollowUpReference()
project_reference = compute_node.getFollowUpReference()
if project_reference != instance_project_reference:
instance_sla_error_list.append("Instance and Compute node project do not match on: %s (%s != %s)" % (
context.getTitle(), project_reference, instance_project_reference))
if sla_dict:
instance_sla_error_list = []
instance_title = context.getTitle()
# Simple check of instance SLAs
if "computer_guid" in sla_dict:
......@@ -60,21 +67,18 @@ if sla_dict:
instance_sla_error_list.append('computer_guid do not match on: %s (%s != %s)' % (
instance_title, computer_guid, compute_node.getReference()))
if "instance_guid" in sla_dict:
instance_guid = sla_dict.pop("instance_guid")
if context.getPortalType() != 'Slave Instance':
instance_sla_error_list.append('instance_guid is provided to a Software Instance: %s' % instance_title)
if "instance_guid" in sla_dict:
instance_guid = sla_dict.pop("instance_guid")
if context.getPortalType() != 'Slave Instance':
instance_sla_error_list.append('instance_guid is provided to a Software Instance: %s' % instance_title)
else:
if compute_node.getPortalType() == "Remote Node":
instance_sla_error_list.append('instance_guid provided on %s and it is allocated on a REMOTE NODE' % instance_title)
else:
if compute_node.getPortalType() == "Remote Node":
instance_sla_error_list.append('instance_guid provided on %s and it is allocated on a REMOTE NODE' % instance_title)
else:
software_instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance')
if software_instance is None:
instance_sla_error_list.append('instance_guid provided on %s but no Software Instance was found' % instance_title)
else:
if software_instance.getReference() != instance_guid:
instance_sla_error_list.append('instance_guid do not match on: %s (%s != %s)' % (
instance_title, instance_guid, software_instance.getReference()))
software_instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance')
if software_instance is not None and software_instance.getReference() != instance_guid:
instance_sla_error_list.append('instance_guid do not match on: %s (%s != %s)' % (
instance_title, instance_guid, software_instance.getReference()))
if 'network_guid' in sla_dict:
network_guid = sla_dict.pop('network_guid')
......@@ -83,31 +87,28 @@ if sla_dict:
instance_sla_error_list.append('network_guid do not match on: %s (%s != %s)' % (
instance_title, network_guid, network_reference))
project_reference = compute_node.getFollowUpReference()
if 'project_guid' in sla_dict:
project_guid = sla_dict.pop("project_guid")
if project_reference != project_guid:
instance_sla_error_list.append('project_guid do not match on: %s (%s != %s)' % (
instance_title, project_guid, project_reference))
instance_project_reference = context.getFollowUpReference()
if project_reference != instance_project_reference:
instance_sla_error_list.append("Instance and Compute node project don't match on: %s (%s != %s)" % (
instance_title, project_reference, instance_project_reference))
if instance_sla_error_list:
# Slave instance is allocated but the software instance was already destroyed
error_dict['notification_message_reference'] = 'slapos-crm-instance-tree-has-invalid-sla.notification'
error_dict = updateErrorDictWithError(error_dict)
error_text = ""
for _e in instance_sla_error_list:
error_text += " * %s\n" % _e
if instance_sla_error_list:
# Slave instance is allocated but the software instance was already destroyed
error_dict['notification_message_reference'] = 'slapos-crm-instance-tree-has-invalid-sla.notification'
error_dict = updateErrorDictWithError(error_dict)
error_text = ""
for _e in instance_sla_error_list:
error_text += " * %s\n" % _e
error_dict['error_text'] = error_text
error_dict['ticket_description'] = "%s has invalid Service Level Aggrement." % instance_title
error_dict['message'] = "%s Detected inconsistencies:\n%s" % (
error_text, error_dict['ticket_description'])
return error_dict
error_dict['error_text'] = error_text
error_dict['ticket_description'] = """%s has invalid Service Level Aggrement.
Detected inconsistencies:
%s""" % (instance_title, error_text)
error_dict['message'] = error_dict['ticket_description']
return error_dict
# Skip to check if monitor disabled on the compute node.
# Remote node has no state.
......
......@@ -26,6 +26,16 @@ from DateTime import DateTime
import time
class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort):
def assertEventTicket(self, event, ticket, tree_or_node):
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), tree_or_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), tree_or_node.getFollowUp())
self.assertEqual(ticket.getCausality(), tree_or_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
def _makeNotificationMessage(self, reference):
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
......@@ -47,6 +57,22 @@ class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort):
return support_request_list[0]
return None
def _makeSupportRequest(self):
person = self.portal.person_module\
.newContent(portal_type="Person")
support_request = self.portal.support_request_module.newContent(
portal_type="Support Request"
)
support_request.submit()
new_id = self.generateNewId()
support_request.edit(
title="Support Request éçà %s" % new_id, #pylint: disable=invalid-encoded-data
reference="TESTSRQ-%s" % new_id,
destination_decision_value=person
)
return support_request
class TestSlapOSCrmCheckProjectAllocationConsistencyState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1
......@@ -263,13 +289,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
@simulate('NotificationTool_getDocumentValue',
......@@ -308,13 +328,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
compute_node.setAccessStatus("")
message = ticket.SupportRequest_recheckMonitoring()
......@@ -327,8 +342,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkMonitoringState_stalled_instance"])')
def test_ComputeNode_checkMonitoringState_script_stalledInstance(self):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
self.portal.REQUEST['test_ComputeNode_checkMonitoringState_stalled_instance'] = \
......@@ -367,13 +383,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
self.start_requested_software_instance.setAccessStatus("")
......@@ -387,8 +397,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkMonitoringState_stalled_instance"])')
def test_ComputeNode_checkMonitoringState_script_stalledInstanceSingle(self):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
self.portal.REQUEST['test_ComputeNode_checkMonitoringState_stalled_instance'] = \
......@@ -427,13 +438,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
self.start_requested_software_instance.setAccessStatus("")
self.start_requested_software_installation.setAccessStatus("")
......@@ -451,8 +457,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkMonitoringState_data_array"])')
def test_ComputeNode_checkMonitoringState_script_modificationArray(self):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
self.portal.REQUEST['test_ComputeNode_checkMonitoringState_script_modificationArray'] = \
......@@ -495,19 +502,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkMonitoringState_installation_no_information(self):
with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
# Computer and instances are accessed
......@@ -528,8 +530,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkMonitoringState_installation_oldBuild(self):
with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
self.start_requested_software_installation.setAccessStatus("")
......@@ -549,8 +552,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkMonitoringState_installation_recentBuild(self):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
# Computer and instances are accessed fine.
......@@ -575,8 +579,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'context.REQUEST["test_ComputeNode_checkMonitoringState_notify"])')
def test_ComputeNode_checkMonitoringState_installation_notifySlow(self):
with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
# Computer and instances are accessed fine.
......@@ -616,13 +621,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
@simulate('NotificationTool_getDocumentValue',
......@@ -632,8 +631,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'context.REQUEST["test_ComputeNode_checkMonitoringState_notify"])')
def test_ComputeNode_checkMonitoringState_installation_notifyError(self):
with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node
self.start_requested_software_installation.setErrorStatus("")
......@@ -674,14 +674,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle()
)
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getSourceProject(), compute_node.getFollowUp())
self.assertEqual(ticket.getCausality(), compute_node.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, compute_node)
class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1
......@@ -776,8 +769,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyError(self):
with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
......@@ -809,19 +803,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
).getTitle()
)
self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyErrorTolerance(self):
with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
......@@ -850,8 +839,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyNotAllocated(self):
with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
......@@ -882,14 +872,7 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
).getTitle()
)
self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
@simulate('NotificationTool_getDocumentValue',
......@@ -899,8 +882,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_close_forever(self):
with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
......@@ -933,20 +917,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
).getTitle()
)
self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_tooEarly(self):
with PinnedDateTime(self, DateTime()):
self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
......@@ -967,8 +945,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
@simulate('Project_isSupportRequestCreationClosed', '', 'return 1')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_closed(self):
with PinnedDateTime(self, DateTime() - 1):
self._makeComputeNode(self.addProject())
self._makeComplexComputeNode(self.addProject())
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
......@@ -1012,14 +991,7 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
event = event_list[0]
self.assertIn('#error foo', event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_slaveWithoutSoftwareInstance(self):
......@@ -1052,12 +1024,285 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
self.assertIn('is allocated on a destroyed software instance',
event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceBadComputeGuid(self):
with PinnedDateTime(self, DateTime() - 1.1):
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
# Something changed before allocation for whatever reason
software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='computer_guid'>%s_foo</parameter>
</instance>""" % self.compute_node.getReference())
instance_tree.setSlaXml(software_instance.getSlaXml())
self.tic()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict(tolerance=30)
self.tic()
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn('has invalid Service Level Aggrement.',
event.getTextContent())
self.assertIn(' computer_guid do not match on:',
event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceBadNetworkGuid(self):
with PinnedDateTime(self, DateTime() - 1.1):
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
# Something changed before allocation for whatever reason
software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='network_guid'>NETFAKE-1</parameter>
</instance>""")
instance_tree.setSlaXml(software_instance.getSlaXml())
self.tic()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict(tolerance=30)
self.tic()
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn('has invalid Service Level Aggrement.',
event.getTextContent())
self.assertIn(' network_guid do not match on:',
event.getTextContent())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceBadProjectGuid(self):
with PinnedDateTime(self, DateTime() - 1.1):
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
# Something changed before allocation for whatever reason
software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='project_guid'>PROJFAKE-1</parameter>
</instance>""")
instance_tree.setSlaXml(software_instance.getSlaXml())
self.tic()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict(tolerance=30)
self.tic()
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn('has invalid Service Level Aggrement.',
event.getTextContent())
self.assertIn(' project_guid do not match on:',
event.getTextContent())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceWrongProject(self):
with PinnedDateTime(self, DateTime() - 1.1):
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
other_project = self.addProject()
# Forcefully move node to some other project
self.compute_node.setFollowUpValue(other_project)
# Double check if the instance is properly allocated on where
# we expect to be.
self.assertEqual(self.compute_node.getRelativeUrl(),
software_instance.getAggregateValue().getParentValue().getRelativeUrl())
self.tic()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict(tolerance=30)
self.tic()
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn('has invalid Service Level Aggrement.',
event.getTextContent())
self.assertIn(' Instance and Compute node project do not match on:',
event.getTextContent())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceBadInstanceGuid(self):
with PinnedDateTime(self, DateTime() - 1.1):
project = self.addProject()
self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue()
# Something changed before allocation for whatever reason
software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='instance_guid'>SIFAKE-1</parameter>
</instance>""")
instance_tree.setSlaXml(software_instance.getSlaXml())
self.tic()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict(tolerance=30)
self.tic()
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn('has invalid Service Level Aggrement.',
event.getTextContent())
self.assertIn(' instance_guid is provided to a Software Instance:',
event.getTextContent())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_slaveInstanceGuidOnRemote(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(
allocation_state='allocated', node='remote', shared=True)
software_instance = instance_tree.getSuccessorValue()
# Something changed before allocation for whatever reason
software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='instance_guid'>SIFAKE-1</parameter>
</instance>""")
instance_tree.setSlaXml(software_instance.getSlaXml())
self.tic()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict(tolerance=30)
self.tic()
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn('has invalid Service Level Aggrement.',
event.getTextContent())
self.assertIn(
' instance_guid provided on test tree and it is allocated on a REMOTE NODE',
event.getTextContent())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_slaveBadInstanceGuid(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(
node='instance', allocation_state='allocated', shared=True)
software_instance = instance_tree.getSuccessorValue()
# Something changed before allocation for whatever reason
software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='instance_guid'>SIFAKE-1</parameter>
</instance>""")
self.tic()
error_dict = software_instance.SoftwareInstance_getReportedErrorDict()
software_instance.SoftwareInstance_checkInstanceTreeMonitoringState()
self.tic()
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertEqual(error_dict['should_notify'], True)
ticket_title = "Instance Tree %s is failing." % (instance_tree.getTitle())
self.assertEqual(error_dict['ticket_title'], ticket_title)
ticket = self._getGeneratedSupportRequest(instance_tree.getUid())
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), error_dict['ticket_title'])
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn(' instance_guid do not match on:', event.getTextContent())
self.assertEventTicket(event, ticket, instance_tree)
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceOnRemoteNode(self):
......@@ -1086,32 +1331,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
event = event_list[0]
self.assertIn('#error foo2', event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted")
self.assertEqual(event.getSimulationState(), "delivered")
self.assertEqual(event.getPortalType(), "Web Message")
self.assertEventTicket(event, ticket, instance_tree)
class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
def _makeSupportRequest(self):
person = self.portal.person_module\
.newContent(portal_type="Person")
support_request = self.portal.support_request_module.newContent(
portal_type="Support Request"
)
support_request.submit()
new_id = self.generateNewId()
support_request.edit(
title="Support Request éçà %s" % new_id, #pylint: disable=invalid-encoded-data
reference="TESTSRQ-%s" % new_id,
destination_decision_value=person
)
return support_request
class TestSlaposCrmUpdateSupportRequestState(TestSlapOSCrmMonitoringMixin):
def _makeInstanceTree(self):
person = self.portal.person_module\
......@@ -1268,19 +1490,7 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
self.assertEqual(ticket.getSimulationState(), "invalidated")
class TestSlaposCrmCheckStoppedEventToDeliver(SlapOSTestCaseMixinWithAbort):
def _makeSupportRequest(self):
support_request = self.portal.support_request_module.newContent(
portal_type="Support Request"
)
support_request.submit()
new_id = self.generateNewId()
support_request.edit(
title= "Support Request éçà %s" % new_id, #pylint: disable=invalid-encoded-data
reference="TESTSRQ-%s" % new_id
)
return support_request
class TestSlaposCrmCheckStoppedEventToDeliver(TestSlapOSCrmMonitoringMixin):
def _makeEvent(self, ticket):
new_id = self.generateNewId()
......@@ -1417,20 +1627,7 @@ class TestSlaposCrmCheckStoppedEventToDeliver(SlapOSTestCaseMixinWithAbort):
self.assertEqual(support_request.getSimulationState(), "suspended")
class TestSlaposCrmCheckSuspendedSupportRequestToReopen(SlapOSTestCaseMixinWithAbort):
def _makeSupportRequest(self):
support_request = self.portal.support_request_module.newContent(
portal_type="Support Request"
)
support_request.submit()
new_id = self.generateNewId()
support_request.edit(
title= "Support Request éçà %s" % new_id, #pylint: disable=invalid-encoded-data
reference="TESTSRQ-%s" % new_id
)
return support_request
class TestSlaposCrmCheckSuspendedSupportRequestToReopen(TestSlapOSCrmMonitoringMixin):
def test_SupportRequest_checkSuspendedSupportRequestToReopen_alarm_suspended(self):
support_request = self._makeSupportRequest()
......
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