Commit 50d81df1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Implement alarm to check Allocation Consistency

    Add a daily alarm to verify if all instance allocated have proper Allocation Supply configured and if they
    still respect the SLA.

    Extend SoftwareInstance_getReportedErrorDict to verify SLA, since, in general the context of the report should be the instance tree. The calculation is cheap to assert the SLA, and this script already has specific checks to inform the user about bad approaches.
parent b5b946a9
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_checkProjectAllocationConsistencyState</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Check per project and trigger activities to verify all compute nodes (monitored) per project.</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_crm_project_allocation_consistency</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple>
<int>2</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>2</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1288051200.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>sense_method_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create tickets for Compute nodes that contains inconsistent instances</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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(
validation_state='validated',
method_id='ComputeNode_checkProjectAllocationConsistencyState',
node=ComplexQuery(
SimpleQuery(portal_type='Remote Node'),
ComplexQuery(
SimpleQuery(portal_type='Compute Node'),
SimpleQuery(monitor_scope__uid=monitor_enabled_category.getUid()),
logical_operator='and'
),
logical_operator='or'
),
group_by=['follow_up_uid'],
method_kw={'tag': tag},
activate_kw={'tag': tag, 'priority': 2}
)
context.activate(after_tag=tag).getId()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkProjectAllocationConsistencyState</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
import six
portal = context.getPortalObject()
# Remote Node has no monitor scope.
if context.getPortalType() == "Compute Node" and \
context.getMonitorScope() == "disabled":
return
project = context.getFollowUpValue()
if project.Project_isSupportRequestCreationClosed():
return
# Exceptionally, we pre-check if the computer has a ticket already
# Since calculation is a bit expensive to "just try".
monitor_service_uid = portal.service_module.slapos_crm_monitoring.getUid()
ticket_portal_type = "Support Request"
if portal.portal_catalog.getResultValue(
portal_type=ticket_portal_type,
resource__uid=monitor_service_uid,
simulation_state=["validated", "submitted", "suspended"],
causality__uid=context.getUid(),
) is not None:
return
reference = context.getReference()
compute_node_title = context.getTitle()
# Use same dict from monitoring so we are consistent while writting
# Notification messages
error_dict = {
'should_notify': None,
'ticket_title': "%s has missing allocation supplies." % compute_node_title,
'ticket_description': None,
'notification_message_reference': 'slapos-crm-compute_node_check_allocation_supply_state.notification',
'compute_node_title': compute_node_title,
'compute_node_id': reference,
'last_contact': None,
'issue_document_reference': None,
'message': None,
'compute_node_error_dict': {}
}
# Since we would like a single ticket per compute node do all at once:
for compute_partition in context.contentValues(portal_type='Compute Partition'):
if compute_partition.getSlapState() == 'busy':
compute_partition_error_dict = compute_partition.ComputePartition_checkAllocationConsistencyState(
known_error_dict=error_dict['compute_node_error_dict'])
if compute_partition_error_dict:
error_dict['should_notify'] = True
error_dict['compute_node_error_dict'].update(compute_partition_error_dict)
if not error_dict['should_notify']:
return
message = """The following contains instances that has Software Releases/Types that are missing on this %s's Allocation Supply configuration:
""" % context.getPortalType()
# Sample compute_node_error_dict[software_release_url][software_type] = (instance, compute_partition)
for sofware_release_url in error_dict['compute_node_error_dict']:
message += """ * Software Release: %s
""" % sofware_release_url
for sofware_type, value_list in six.iteritems(error_dict['compute_node_error_dict'][sofware_release_url]):
message += """ * Software Type: %s (ie: %s on %s)
""" % (sofware_type, value_list[0].getTitle(), value_list[1].getReference())
error_dict['message'] = message
support_request = project.Project_createTicketWithCausality(
ticket_portal_type,
error_dict['ticket_title'],
error_dict['ticket_description'],
causality=context.getRelativeUrl(),
destination_decision=project.getDestination()
)
if support_request is not None:
support_request.Ticket_createProjectEvent(
error_dict['ticket_title'], 'outgoing', 'Web Message',
portal.service_module.slapos_crm_information.getRelativeUrl(),
text_content=error_dict['message'],
content_type='text/plain',
notification_message=error_dict['notification_message_reference'],
#language=XXX,
substitution_method_parameter_dict=error_dict
)
return support_request
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_checkAllocationConsistencyState</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
portal = context.getPortalObject()
monitor_enabled_category = portal.restrictedTraverse(
"portal_categories/monitor_scope/enabled", None)
project = context.getFollowUpValue(portal_type='Project')
assert project is not None
if project.Project_isSupportRequestCreationClosed():
return
if monitor_enabled_category is not None:
project_uid = project.getUid()
portal.portal_catalog.searchAndActivate(
node=ComplexQuery(
SimpleQuery(portal_type='Remote Node'),
ComplexQuery(
SimpleQuery(portal_type='Compute Node'),
SimpleQuery(monitor_scope__uid=monitor_enabled_category.getUid()),
logical_operator='and'
),
logical_operator='or'
),
validation_state='validated',
follow_up__uid=project_uid,
method_id='ComputeNode_checkAllocationConsistencyState',
# This alarm bruteforce checking all documents,
# without changing them directly.
# Increase priority to not block other activities
activate_kw={'tag': tag, 'priority': 2}
)
project.activate(after_tag=tag).getId()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_checkProjectAllocationConsistencyState</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
compute_partition = context
error_dict = {}
if known_error_dict is None:
known_error_dict = {}
compute_node = compute_partition.getParentValue()
assert compute_node.getPortalType() in ['Compute Node', 'Remote Node']
instance_list = compute_partition.getAggregateRelatedValueList(portal_type=[
'Software Instance', 'Slave Instance'])
for instance in instance_list:
if instance.getValidationState() != 'validated' or \
instance.getSlapState() == 'destroy_requested':
# Outdated catalog or instance under garbage collection,
# we skip for now.
continue
instance_software_release_url = instance.getUrlString()
instance_software_type = instance.getSourceReference()
is_known = False
for _e_dict in [error_dict, known_error_dict]:
if instance_software_release_url in _e_dict:
if instance_software_type in _e_dict[instance_software_release_url]:
# Skip calculate same thing again?
is_known = True
break
# Value was already processed or discovered on some other partition
# so we skip
if is_known:
continue
# Now check allocation supply consistency
instance_tree = instance.getSpecialiseValue(portal_type="Instance Tree")
# if there is an ongoing upgrade decision, skip, since there is already
# a ticket for handle the inconsistency.
if portal.portal_catalog.getResultValue(
portal_type='Upgrade Decision',
aggregate__uid=instance_tree.getUid(),
simulation_state=['started', 'stopped', 'planned', 'confirmed']) is not None:
continue
instance_tree_context = instance_tree.asContext(
default_source_reference=instance_software_type,
url_string=instance_software_release_url)
project = instance.getFollowUpValue()
assert project is not None, 'Project is None'
allocation_cell_list = []
software_product, software_release, software_type = instance_tree_context.InstanceTree_getSoftwareProduct()
if software_product is not None:
allocation_cell_list = project.Project_getSoftwareProductPredicateList(
software_product=software_product,
software_product_type=software_type,
software_product_release=software_release,
destination_value=instance_tree.getDestinationSectionValue(),
node_value=compute_node,
predicate_portal_type='Allocation Supply Cell'
)
if not allocation_cell_list:
# Sampling of the structure.
# error_dict[software_release_url][software_type] = (instance, compute_partition)
value = (instance, compute_partition)
if instance_software_release_url not in error_dict:
error_dict[instance_software_release_url] = {}
if instance_software_type not in error_dict[instance_software_release_url]:
error_dict[instance.getUrlString()][instance_software_type] = value
return error_dict
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>known_error_dict=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputePartition_checkAllocationConsistencyState</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -48,6 +48,68 @@ if context.getPortalType() == 'Slave Instance' and compute_node.getPortalType() ...@@ -48,6 +48,68 @@ if context.getPortalType() == 'Slave Instance' and compute_node.getPortalType()
error_dict['ticket_description'] = error_dict['message'] error_dict['ticket_description'] = error_dict['message']
return error_dict return error_dict
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_title = context.getTitle()
# Simple check of instance SLAs
if "computer_guid" in sla_dict:
computer_guid = sla_dict.pop("computer_guid")
if compute_node.getReference() != computer_guid:
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)
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 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')
network_reference = compute_node.getSubordinationReference()
if network_reference != network_guid:
instance_sla_error_list.append('network_guid do not match on: %s (%s != %s)' % (
instance_title, network_guid, network_reference))
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))
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.
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. # Skip to check if monitor disabled on the compute node.
# Remote node has no state. # Remote node has no state.
if (compute_node.getPortalType() == "Compute Node") and (compute_node.getMonitorScope() != "enabled"): if (compute_node.getPortalType() == "Compute Node") and (compute_node.getMonitorScope() != "enabled"):
......
...@@ -26,6 +26,16 @@ from DateTime import DateTime ...@@ -26,6 +26,16 @@ from DateTime import DateTime
import time import time
class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort): 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): def _makeNotificationMessage(self, reference):
notification_message = self.portal.notification_message_module.newContent( notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message", portal_type="Notification Message",
...@@ -47,6 +57,279 @@ class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort): ...@@ -47,6 +57,279 @@ class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort):
return support_request_list[0] return support_request_list[0]
return None 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
##########################################################################
# slapos_crm_project_allocation_consistency > ComputeNode_checkProjectAllocationConsistencyState
##########################################################################
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(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")
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 TestSlapOSCrmMonitoringCheckAllocationConsistencyState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1
#############################################################################
# ComputeNode_checkProjectAllocationConsistencyState > ComputeNode_checkAllocationConsistencyState
#############################################################################
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkAllocationConsistencyState_script_noAllocationCell(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, \
release_variation, \
type_variation, \
compute_node, \
partition, \
_ = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
ticket = compute_node.ComputeNode_checkAllocationConsistencyState()
# Double check error dict
error_dict = partition.ComputePartition_checkAllocationConsistencyState()
self.assertNotEqual({}, error_dict)
self.assertEqual(1, len(error_dict))
self.assertEqual([release_variation.getUrlString()], error_dict.keys())
self.assertEqual([type_variation.getReference()],
error_dict[release_variation.getUrlString()].keys())
self.assertEqual(partition.getAggregateRelatedValue().getUid(),
error_dict[release_variation.getUrlString()][type_variation.getReference()][0].getUid())
self.assertEqual(partition.getUid(),
error_dict[release_variation.getUrlString()][type_variation.getReference()][1].getUid())
# Try to see if duplicates entries.
error_dict[release_variation.getUrlString()][type_variation.getReference()] = ('a', 'b')
# Pass a known case dont add more entries
self.assertEqual({}, partition.ComputePartition_checkAllocationConsistencyState(
known_error_dict=error_dict))
ticket_title = "%s has missing allocation supplies." % compute_node.getTitle()
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), ticket_title)
self.tic()
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn("The following contains instances that has Software Releases/Types",
event.getTextContent())
self.assertIn(release_variation.getUrlString(), event.getTextContent())
self.assertIn(type_variation.getReference(), event.getTextContent())
self.assertEventTicket(event, ticket, compute_node)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkAllocationConsistencyState_script_hasTicketAlready(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, \
release_variation, \
type_variation, \
compute_node, \
partition, \
_ = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
project = compute_node.getFollowUpValue()
title = "checkAllocationConsistencyState %s" % self.generateNewId()
support_request = project.Project_createTicketWithCausality(
"Support Request", title, title,
causality=compute_node.getRelativeUrl(),
destination_decision=project.getDestination()
)
self.assertNotEqual(support_request, None)
self.tic()
ticket = compute_node.ComputeNode_checkAllocationConsistencyState()
self.assertEqual(ticket, None)
# Double check error dict exists despite ticket isnt created.
error_dict = partition.ComputePartition_checkAllocationConsistencyState()
self.assertNotEqual({}, error_dict)
self.assertEqual(1, len(error_dict))
self.assertEqual([release_variation.getUrlString()], error_dict.keys())
self.assertEqual([type_variation.getReference()],
error_dict[release_variation.getUrlString()].keys())
self.assertEqual(partition.getAggregateRelatedValue().getUid(),
error_dict[release_variation.getUrlString()][type_variation.getReference()][0].getUid())
self.assertEqual(partition.getUid(),
error_dict[release_variation.getUrlString()][type_variation.getReference()][1].getUid())
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkAllocationConsistencyState_script_ongoingUpgrade(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, _, _, \
compute_node, \
partition, \
instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
ud = self.portal.upgrade_decision_module.newContent(
portal_type="Upgrade Decision",
aggregate_value=instance_tree)
ud.plan()
self.tic()
ticket = compute_node.ComputeNode_checkAllocationConsistencyState()
# Double check error dict
error_dict = partition.ComputePartition_checkAllocationConsistencyState()
self.assertEqual({}, error_dict)
self.assertEqual(None, ticket)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 1')
def test_ComputeNode_checkAllocationConsistencyState_script_creationClosed(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, _, _, compute_node, \
_, _ = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
ticket = compute_node.ComputeNode_checkAllocationConsistencyState()
self.assertEqual(None, ticket)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkAllocationConsistencyState_script_monitorDisabled(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, _, _, compute_node, \
_, _ = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
compute_node.setMonitorScope('disabled')
self.tic()
ticket = compute_node.ComputeNode_checkAllocationConsistencyState()
self.assertEqual(None, ticket)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkAllocationConsistencyState_script_RemotenoAllocationCell(self):
with PinnedDateTime(self, DateTime() - 1.1):
_, release_variation, \
type_variation, \
compute_node, \
partition, \
_ = self.bootstrapAllocableInstanceTree(
allocation_state='allocated', node='remote', shared=True)
self.tic()
ticket = compute_node.ComputeNode_checkAllocationConsistencyState()
# Double check error dict
error_dict = partition.ComputePartition_checkAllocationConsistencyState()
self.assertNotEqual({}, error_dict)
self.assertEqual(1, len(error_dict))
self.assertEqual([release_variation.getUrlString()], error_dict.keys())
self.assertEqual([type_variation.getReference()],
error_dict[release_variation.getUrlString()].keys())
self.assertEqual(partition.getAggregateRelatedValue().getUid(),
error_dict[release_variation.getUrlString()][type_variation.getReference()][0].getUid())
self.assertEqual(partition.getUid(),
error_dict[release_variation.getUrlString()][type_variation.getReference()][1].getUid())
# Try to see if duplicates entries.
error_dict[release_variation.getUrlString()][type_variation.getReference()] = ('a', 'b')
# Pass a known case dont add more entries
self.assertEqual({}, partition.ComputePartition_checkAllocationConsistencyState(
known_error_dict=error_dict))
ticket_title = "%s has missing allocation supplies." % compute_node.getTitle()
self.assertNotEqual(ticket, None)
self.assertEqual(ticket.getTitle(), ticket_title)
self.tic()
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertIn("The following contains instances that has Software Releases/Types",
event.getTextContent())
self.assertIn(release_variation.getUrlString(), event.getTextContent())
self.assertIn(type_variation.getReference(), event.getTextContent())
self.assertEventTicket(event, ticket, compute_node)
class TestSlapOSCrmMonitoringCheckComputeNodeProjectState(TestSlapOSCrmMonitoringMixin): class TestSlapOSCrmMonitoringCheckComputeNodeProjectState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1 launch_caucase = 1
...@@ -188,13 +471,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -188,13 +471,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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")
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
...@@ -233,13 +510,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -233,13 +510,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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")
compute_node.setAccessStatus("") compute_node.setAccessStatus("")
message = ticket.SupportRequest_recheckMonitoring() message = ticket.SupportRequest_recheckMonitoring()
...@@ -252,8 +524,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -252,8 +524,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkMonitoringState_stalled_instance"])') 'context.REQUEST["test_ComputeNode_checkMonitoringState_stalled_instance"])')
def test_ComputeNode_checkMonitoringState_script_stalledInstance(self): def test_ComputeNode_checkMonitoringState_script_stalledInstance(self):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
self.portal.REQUEST['test_ComputeNode_checkMonitoringState_stalled_instance'] = \ self.portal.REQUEST['test_ComputeNode_checkMonitoringState_stalled_instance'] = \
...@@ -292,13 +565,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -292,13 +565,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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.start_requested_software_instance.setAccessStatus("") self.start_requested_software_instance.setAccessStatus("")
...@@ -312,8 +579,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -312,8 +579,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkMonitoringState_stalled_instance"])') 'context.REQUEST["test_ComputeNode_checkMonitoringState_stalled_instance"])')
def test_ComputeNode_checkMonitoringState_script_stalledInstanceSingle(self): def test_ComputeNode_checkMonitoringState_script_stalledInstanceSingle(self):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
self.portal.REQUEST['test_ComputeNode_checkMonitoringState_stalled_instance'] = \ self.portal.REQUEST['test_ComputeNode_checkMonitoringState_stalled_instance'] = \
...@@ -352,13 +620,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -352,13 +620,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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.start_requested_software_instance.setAccessStatus("") self.start_requested_software_instance.setAccessStatus("")
self.start_requested_software_installation.setAccessStatus("") self.start_requested_software_installation.setAccessStatus("")
...@@ -376,8 +639,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -376,8 +639,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkMonitoringState_data_array"])') 'context.REQUEST["test_ComputeNode_checkMonitoringState_data_array"])')
def test_ComputeNode_checkMonitoringState_script_modificationArray(self): def test_ComputeNode_checkMonitoringState_script_modificationArray(self):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
self.portal.REQUEST['test_ComputeNode_checkMonitoringState_script_modificationArray'] = \ self.portal.REQUEST['test_ComputeNode_checkMonitoringState_script_modificationArray'] = \
...@@ -420,19 +684,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -420,19 +684,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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")
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkMonitoringState_installation_no_information(self): def test_ComputeNode_checkMonitoringState_installation_no_information(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
# Computer and instances are accessed # Computer and instances are accessed
...@@ -453,9 +712,10 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -453,9 +712,10 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkMonitoringState_installation_oldBuild(self): def test_ComputeNode_checkMonitoringState_installation_oldBuild(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) compute_node, _ = self._makeComputeNode(project)
compute_node = self.compute_node self._makeComplexComputeNode(project)
compute_node = self.compute_node
self.start_requested_software_installation.setAccessStatus("") self.start_requested_software_installation.setAccessStatus("")
# Computer and instances are accessed # Computer and instances are accessed
...@@ -474,8 +734,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -474,8 +734,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
def test_ComputeNode_checkMonitoringState_installation_recentBuild(self): def test_ComputeNode_checkMonitoringState_installation_recentBuild(self):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
# Computer and instances are accessed fine. # Computer and instances are accessed fine.
...@@ -500,8 +761,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -500,8 +761,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'context.REQUEST["test_ComputeNode_checkMonitoringState_notify"])') 'context.REQUEST["test_ComputeNode_checkMonitoringState_notify"])')
def test_ComputeNode_checkMonitoringState_installation_notifySlow(self): def test_ComputeNode_checkMonitoringState_installation_notifySlow(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
# Computer and instances are accessed fine. # Computer and instances are accessed fine.
...@@ -541,13 +803,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -541,13 +803,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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")
@simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '*args, **kwargs', 'return 0')
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
...@@ -557,8 +813,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -557,8 +813,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
'context.REQUEST["test_ComputeNode_checkMonitoringState_notify"])') 'context.REQUEST["test_ComputeNode_checkMonitoringState_notify"])')
def test_ComputeNode_checkMonitoringState_installation_notifyError(self): def test_ComputeNode_checkMonitoringState_installation_notifyError(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
compute_node, _ = self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) compute_node, _ = self._makeComputeNode(project)
self._makeComplexComputeNode(project)
compute_node = self.compute_node compute_node = self.compute_node
self.start_requested_software_installation.setErrorStatus("") self.start_requested_software_installation.setErrorStatus("")
...@@ -599,14 +856,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin) ...@@ -599,14 +856,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
).getTitle() ).getTitle()
) )
self.assertIn(compute_node.getReference(), event.getTextContent()) self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, compute_node)
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")
class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSCrmMonitoringMixin): class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1 launch_caucase = 1
...@@ -701,8 +951,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -701,8 +951,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])') 'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyError(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyError(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue() instance_tree = software_instance.getSpecialiseValue()
...@@ -734,19 +985,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -734,19 +985,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
).getTitle() ).getTitle()
) )
self.assertIn(instance_tree.getReference(), event.getTextContent()) self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, instance_tree)
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")
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyErrorTolerance(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyErrorTolerance(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue() instance_tree = software_instance.getSpecialiseValue()
...@@ -775,8 +1021,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -775,8 +1021,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])') 'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyNotAllocated(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_notifyNotAllocated(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue() instance_tree = software_instance.getSpecialiseValue()
...@@ -807,14 +1054,7 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -807,14 +1054,7 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
).getTitle() ).getTitle()
) )
self.assertIn(instance_tree.getReference(), event.getTextContent()) self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, instance_tree)
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")
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
...@@ -824,8 +1064,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -824,8 +1064,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])') 'context.REQUEST["test_SoftwareInstance_checkInstanceTreeMonitoringState_notify"])')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_close_forever(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_close_forever(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue() instance_tree = software_instance.getSpecialiseValue()
...@@ -858,20 +1099,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -858,20 +1099,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
).getTitle() ).getTitle()
) )
self.assertIn(instance_tree.getReference(), event.getTextContent()) self.assertIn(instance_tree.getReference(), event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, instance_tree)
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")
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_tooEarly(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_tooEarly(self):
with PinnedDateTime(self, DateTime()): with PinnedDateTime(self, DateTime()):
self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue() instance_tree = software_instance.getSpecialiseValue()
...@@ -892,8 +1127,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -892,8 +1127,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
@simulate('Project_isSupportRequestCreationClosed', '', 'return 1') @simulate('Project_isSupportRequestCreationClosed', '', 'return 1')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_closed(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_closed(self):
with PinnedDateTime(self, DateTime() - 1): with PinnedDateTime(self, DateTime() - 1):
self._makeComputeNode(self.addProject()) project = self.addProject()
self._makeComplexComputeNode(self.addProject()) self._makeComputeNode(project)
self._makeComplexComputeNode(project)
software_instance = self.start_requested_software_instance software_instance = self.start_requested_software_instance
instance_tree = software_instance.getSpecialiseValue() instance_tree = software_instance.getSpecialiseValue()
...@@ -937,20 +1173,13 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -937,20 +1173,13 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
event = event_list[0] event = event_list[0]
self.assertIn('#error foo', event.getTextContent()) self.assertIn('#error foo', event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, instance_tree)
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")
@simulate('Project_isSupportRequestCreationClosed', '', 'return 0') @simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_slaveWithoutSoftwareInstance(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_slaveWithoutSoftwareInstance(self):
with PinnedDateTime(self, DateTime() - 1.1): with PinnedDateTime(self, DateTime() - 1.1):
# without instance='node', the slave is allocated w/o software instance # without instance='node', the slave is allocated w/o software instance
# which emulates post unallocation state after the destruction of # which emulates post unallocation state after the destruction of
# the software instance. # the software instance.
_, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree( _, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(
allocation_state='allocated', shared=True) allocation_state='allocated', shared=True)
...@@ -977,12 +1206,285 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -977,12 +1206,285 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
self.assertIn('is allocated on a destroyed software instance', self.assertIn('is allocated on a destroyed software instance',
event.getTextContent()) event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl())
self.assertEqual(event.getSourceProject(), instance_tree.getFollowUp()) self.assertEventTicket(event, ticket, instance_tree)
self.assertEqual(ticket.getSourceProject(), instance_tree.getFollowUp())
self.assertEqual(ticket.getCausality(), instance_tree.getRelativeUrl())
self.assertEqual(ticket.getSimulationState(), "submitted") @simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
self.assertEqual(event.getSimulationState(), "delivered") def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceBadComputeGuid(self):
self.assertEqual(event.getPortalType(), "Web Message") 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') @simulate('Project_isSupportRequestCreationClosed', '', 'return 0')
def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceOnRemoteNode(self): def test_SoftwareInstance_checkInstanceTreeMonitoringState_script_instanceOnRemoteNode(self):
...@@ -1011,32 +1513,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC ...@@ -1011,32 +1513,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
event = event_list[0] event = event_list[0]
self.assertIn('#error foo2', event.getTextContent()) self.assertIn('#error foo2', event.getTextContent())
self.assertEqual(event.getFollowUp(), ticket.getRelativeUrl()) self.assertEventTicket(event, ticket, instance_tree)
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")
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): def _makeInstanceTree(self):
person = self.portal.person_module\ person = self.portal.person_module\
...@@ -1193,19 +1672,7 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort): ...@@ -1193,19 +1672,7 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
self.assertEqual(ticket.getSimulationState(), "invalidated") self.assertEqual(ticket.getSimulationState(), "invalidated")
class TestSlaposCrmCheckStoppedEventToDeliver(SlapOSTestCaseMixinWithAbort): class TestSlaposCrmCheckStoppedEventToDeliver(TestSlapOSCrmMonitoringMixin):
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
def _makeEvent(self, ticket): def _makeEvent(self, ticket):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1342,20 +1809,7 @@ class TestSlaposCrmCheckStoppedEventToDeliver(SlapOSTestCaseMixinWithAbort): ...@@ -1342,20 +1809,7 @@ class TestSlaposCrmCheckStoppedEventToDeliver(SlapOSTestCaseMixinWithAbort):
self.assertEqual(support_request.getSimulationState(), "suspended") self.assertEqual(support_request.getSimulationState(), "suspended")
class TestSlaposCrmCheckSuspendedSupportRequestToReopen(SlapOSTestCaseMixinWithAbort): class TestSlaposCrmCheckSuspendedSupportRequestToReopen(TestSlapOSCrmMonitoringMixin):
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
def test_SupportRequest_checkSuspendedSupportRequestToReopen_alarm_suspended(self): def test_SupportRequest_checkSuspendedSupportRequestToReopen_alarm_suspended(self):
support_request = self._makeSupportRequest() 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