Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
ac424d91
Commit
ac424d91
authored
Dec 04, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: fixes and tests for SLA related tickets.
parent
035e7b8b
Pipeline
#38410
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
398 additions
and
200 deletions
+398
-200
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SoftwareInstance_getReportedErrorDict.py
...s_crm_monitoring/SoftwareInstance_getReportedErrorDict.py
+34
-33
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py
...rtal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py
+364
-167
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SoftwareInstance_getReportedErrorDict.py
View file @
ac424d91
...
@@ -50,8 +50,15 @@ if context.getPortalType() == 'Slave Instance' and compute_node.getPortalType()
...
@@ -50,8 +50,15 @@ if context.getPortalType() == 'Slave Instance' and compute_node.getPortalType()
sla_dict
=
context
.
getSlaXmlAsDict
()
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
:
if
sla_dict
:
instance_sla_error_list
=
[]
instance_title
=
context
.
getTitle
()
instance_title
=
context
.
getTitle
()
# Simple check of instance SLAs
# Simple check of instance SLAs
if
"computer_guid"
in
sla_dict
:
if
"computer_guid"
in
sla_dict
:
...
@@ -60,21 +67,18 @@ if sla_dict:
...
@@ -60,21 +67,18 @@ if sla_dict:
instance_sla_error_list
.
append
(
'computer_guid do not match on: %s (%s != %s)'
%
(
instance_sla_error_list
.
append
(
'computer_guid do not match on: %s (%s != %s)'
%
(
instance_title
,
computer_guid
,
compute_node
.
getReference
()))
instance_title
,
computer_guid
,
compute_node
.
getReference
()))
if
"instance_guid"
in
sla_dict
:
if
"instance_guid"
in
sla_dict
:
instance_guid
=
sla_dict
.
pop
(
"instance_guid"
)
instance_guid
=
sla_dict
.
pop
(
"instance_guid"
)
if
context
.
getPortalType
()
!=
'Slave Instance'
:
if
context
.
getPortalType
()
!=
'Slave Instance'
:
instance_sla_error_list
.
append
(
'instance_guid is provided to a Software Instance: %s'
%
instance_title
)
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
:
else
:
if
compute_node
.
getPortalType
()
==
"Remote Node"
:
software_instance
=
compute_partition
.
getAggregateRelatedValue
(
portal_type
=
'Software Instance'
)
instance_sla_error_list
.
append
(
'instance_guid provided on %s and it is allocated on a REMOTE NODE'
%
instance_title
)
if
software_instance
is
not
None
and
software_instance
.
getReference
()
!=
instance_guid
:
else
:
instance_sla_error_list
.
append
(
'instance_guid do not match on: %s (%s != %s)'
%
(
software_instance
=
compute_partition
.
getAggregateRelatedValue
(
portal_type
=
'Software Instance'
)
instance_title
,
instance_guid
,
software_instance
.
getReference
()))
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
()))
if
'network_guid'
in
sla_dict
:
if
'network_guid'
in
sla_dict
:
network_guid
=
sla_dict
.
pop
(
'network_guid'
)
network_guid
=
sla_dict
.
pop
(
'network_guid'
)
...
@@ -83,31 +87,28 @@ if sla_dict:
...
@@ -83,31 +87,28 @@ if sla_dict:
instance_sla_error_list
.
append
(
'network_guid do not match on: %s (%s != %s)'
%
(
instance_sla_error_list
.
append
(
'network_guid do not match on: %s (%s != %s)'
%
(
instance_title
,
network_guid
,
network_reference
))
instance_title
,
network_guid
,
network_reference
))
project_reference
=
compute_node
.
getFollowUpReference
()
if
'project_guid'
in
sla_dict
:
if
'project_guid'
in
sla_dict
:
project_guid
=
sla_dict
.
pop
(
"project_guid"
)
project_guid
=
sla_dict
.
pop
(
"project_guid"
)
if
project_reference
!=
project_guid
:
if
project_reference
!=
project_guid
:
instance_sla_error_list
.
append
(
'project_guid do not match on: %s (%s != %s)'
%
(
instance_sla_error_list
.
append
(
'project_guid do not match on: %s (%s != %s)'
%
(
instance_title
,
project_guid
,
project_reference
))
instance_title
,
project_guid
,
project_reference
))
instance_project_reference
=
context
.
getFollowUpReference
()
if
instance_sla_error_list
:
if
project_reference
!=
instance_project_reference
:
# Slave instance is allocated but the software instance was already destroyed
instance_sla_error_list
.
append
(
"Instance and Compute node project don't match on: %s (%s != %s)"
%
(
error_dict
[
'notification_message_reference'
]
=
'slapos-crm-instance-tree-has-invalid-sla.notification'
instance_title
,
project_reference
,
instance_project_reference
))
error_dict
=
updateErrorDictWithError
(
error_dict
)
error_text
=
""
for
_e
in
instance_sla_error_list
:
error_text
+=
" * %s
\
n
"
%
_e
if
instance_sla_error_list
:
error_dict
[
'error_text'
]
=
error_text
# Slave instance is allocated but the software instance was already destroyed
error_dict
[
'ticket_description'
]
=
"""%s has invalid Service Level Aggrement.
error_dict
[
'notification_message_reference'
]
=
'slapos-crm-instance-tree-has-invalid-sla.notification'
error_dict
=
updateErrorDictWithError
(
error_dict
)
Detected inconsistencies:
error_text
=
""
for
_e
in
instance_sla_error_list
:
%s"""
%
(
instance_title
,
error_text
)
error_text
+=
" * %s
\
n
"
%
_e
error_dict
[
'message'
]
=
error_dict
[
'ticket_description'
]
return
error_dict
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
# 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.
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMMonitoringAlarm.py
View file @
ac424d91
...
@@ -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,22 @@ class TestSlapOSCrmMonitoringMixin(SlapOSTestCaseMixinWithAbort):
...
@@ -47,6 +57,22 @@ 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
):
class
TestSlapOSCrmCheckProjectAllocationConsistencyState
(
TestSlapOSCrmMonitoringMixin
):
launch_caucase
=
1
launch_caucase
=
1
...
@@ -263,13 +289,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -263,13 +289,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'
,
...
@@ -308,13 +328,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -308,13 +328,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
()
...
@@ -327,8 +342,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -327,8 +342,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'
]
=
\
...
@@ -367,13 +383,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -367,13 +383,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
(
""
)
...
@@ -387,8 +397,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -387,8 +397,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'
]
=
\
...
@@ -427,13 +438,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -427,13 +438,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
(
""
)
...
@@ -451,8 +457,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -451,8 +457,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'
]
=
\
...
@@ -495,19 +502,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -495,19 +502,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
...
@@ -528,8 +530,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -528,8 +530,9 @@ 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
)
self
.
_makeComplexComputeNode
(
project
)
compute_node
=
self
.
compute_node
compute_node
=
self
.
compute_node
self
.
start_requested_software_installation
.
setAccessStatus
(
""
)
self
.
start_requested_software_installation
.
setAccessStatus
(
""
)
...
@@ -549,8 +552,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -549,8 +552,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.
...
@@ -575,8 +579,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -575,8 +579,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.
...
@@ -616,13 +621,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -616,13 +621,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'
,
...
@@ -632,8 +631,9 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -632,8 +631,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
(
""
)
...
@@ -674,14 +674,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin)
...
@@ -674,14 +674,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
...
@@ -776,8 +769,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -776,8 +769,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
()
...
@@ -809,19 +803,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -809,19 +803,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
()
...
@@ -850,8 +839,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -850,8 +839,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
()
...
@@ -882,14 +872,7 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -882,14 +872,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'
,
...
@@ -899,8 +882,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -899,8 +882,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
()
...
@@ -933,20 +917,14 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -933,20 +917,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
()
...
@@ -967,8 +945,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -967,8 +945,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
()
...
@@ -1012,14 +991,7 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -1012,14 +991,7 @@ 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
):
...
@@ -1052,12 +1024,285 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -1052,12 +1024,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
):
...
@@ -1086,32 +1331,9 @@ class TestSlapOSCrmSoftwareInstance_checkInstanceTreeMonitoringState(TestSlapOSC
...
@@ -1086,32 +1331,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
(
TestSlapOSCrmMonitoringMixin
):
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
def
_makeInstanceTree
(
self
):
def
_makeInstanceTree
(
self
):
person
=
self
.
portal
.
person_module
\
person
=
self
.
portal
.
person_module
\
...
@@ -1268,19 +1490,7 @@ class TestSlaposCrmUpdateSupportRequestState(SlapOSTestCaseMixinWithAbort):
...
@@ -1268,19 +1490,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
()
...
@@ -1417,20 +1627,7 @@ class TestSlaposCrmCheckStoppedEventToDeliver(SlapOSTestCaseMixinWithAbort):
...
@@ -1417,20 +1627,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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment