-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_4331_downack_ack_unack_max_args.groovy
136 lines (127 loc) · 6.69 KB
/
test_4331_downack_ack_unack_max_args.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import org.apache.camel.Exchange
import org.apache.camel.Expression
import org.apache.camel.http.common.HttpMethods
import java.time.Instant
import static Exec.ENV
import static Exec.shell
new Simulator()({
annotate_action('Configure EMS simulator to respond to a request to acknowledgment alarm and indicate operation was a success')
emsDownAckMock.resultWaitTime = 10000
emsDownAckMock.expectedMessageCount(1)
emsDownAckMock.returnReplyBody({ Exchange exchange, Class type ->
null
} as Expression)
annotate_action "Send raise alarm event from EMS simulator"
emsSendEvents("""[
{
"notificationType": "notifyNewAlarm",
"alarmType": "CommunicationsAlarm",
"objectClass": "OT_PHYSICAL_TERMINATION_POINT",
"objectInstance": "IRPNetwork=ABCNetwork,Subnet=TN2,BSS=B5C0100",
"notificationId": 123,
"correlatedNotifications": [1, 2],
"eventTime": "1997-01-01T12:00:27.87+00:20",
"systemDN": "DC=www.huawei.com , SubNetwork=1 , ManagementNode=1 , IRPAgent=1",
"alarmId": "AMS:5654",
"agentEntity": "ems_1",
"probableCause": "fire",
"perceivedSeverity": "Critical",
"specificProblem": ["example specific problem 1"],
"additionalText": "Everything is on fire!",
"siteLocation": "Lindau",
"regionLocation": "Bavaria",
"vendorName": "Hewlett Packard Enterprise",
"technologyDomain": "Mobile",
"equipmentModel": "MNM 3000",
"plannedOutageIndication": false,
"customStringAttribute": "custom string value",
"customListAttribute": ["custom value 1", "custom value 2", "custom value 3"]
}
]""")
annotate_action "Wait for the alarm to be received in OC"
long aoIdentifier = LibCheck.unpackOcAlarm(LibCheck.waitOcAlarms().first()).with {
annotate_check "Check AO Event Time is as in original alarm"
assert it['Event Time'] ==
java.time.OffsetDateTime.parse("1997-01-01T12:00:27.87+00:20").toInstant()
annotate_check "Check that State is Outstanding"
assert it[/State/] == "Outstanding"
annotate_check "Check that Acknowledgement User Identifier is not set"
assert it[/Acknowledgement User Identifier/] == null
annotate_check "Check that Acknowledgement Time Stamp is not set"
assert it[/Acknowledgement Time Stamp/] == null
annotate_check "Check original Additional Text has been mapped correctly"
assert it['Additional Text'] =~ /Everything is on fire!/
it['Identifier'] as Long
}
annotate_action "Execute Acknowledge directive"
shell($/$$manage acknowledge oper ${ENV['oc_1']} alarm ${aoIdentifier} UserId='John Doe'/$)
annotate_action "Wait for the alarm to become Acknowledged in OC"
shell($/wait_for_oc_content $$oc_1 'contains "State = Acknowledged"'/$)
LibCheck.unpackOcAlarm(shell($/cat $$0.tmp | extract_alarms_from_oc/$).first()).tap {
annotate_check "Check that AO that became acknowledged is the same which was requested to be acknowledged"
assert it['Identifier'] == aoIdentifier
annotate_check "Check AO Event Time is still as in original alarm"
assert it['Event Time'] ==
java.time.OffsetDateTime.parse("1997-01-01T12:00:27.87+00:20").toInstant()
annotate_check "Check that State is Acknowledged"
assert it[/State/] == /Acknowledged/
annotate_check "Check that Acknowledgement User Identifier is set to the values specified in userId argument"
assert it[/Acknowledgement User Identifier/] == 'John Doe'
annotate_check "Check that Acknowledgement Time Stamp is set around now rather as no Timestamp argument is specified"
assert (Instant.now().minusSeconds(15)).isBefore(it[/Acknowledgement Time Stamp/] as Instant)
annotate_check "Check original Additional Text has not changed"
assert it['Additional Text'] =~ /Everything is on fire!/
}
annotate_action "Check EMS simulator has received one request to acknowledged alarm"
emsDownAckMock.assertIsSatisfied()
assert emsDownAckMock.exchanges.size() == 1
emsDownAckMock.assertExchangeReceived(0).tap {
assert it.message.headers[HTTP_METHOD] == HttpMethods.PATCH.name()
assert parsePath(it) == '/tmb/10/alarms/AMS:5654'
it.message.getMandatoryBody(Map).tap {
assert it.size() == 3
assert it['ackSystemId'] == "Platform"
assert it['ackstate'] == "acknowledged"
assert it['ackUserId'] == "John Doe"
}
}
annotate_action('Configure EMS simulator to respond to a request to unacknowledgment alarm and indicate operation was a success')
emsDownAckMock.reset()
emsDownAckMock.resultWaitTime = 10000
emsDownAckMock.expectedMessageCount(1)
emsDownAckMock.returnReplyBody({ Exchange exchange, Class type ->
null
} as Expression)
annotate_action "Execute Unacknowledge directive"
shell($/$$manage unacknowledge oper ${ENV['oc_1']} alarm ${aoIdentifier} UserId='John Carter'/$)
annotate_action "Wait for the alarm to become Outstanding in OC"
shell($/wait_for_oc_content $$oc_1 'contains "State = Outstanding"'/$)
LibCheck.unpackOcAlarm(shell($/cat $$0.tmp | extract_alarms_from_oc/$).first()).tap {
annotate_check "Check that AO that became acknowledged is the same which was requested to be acknowledged"
assert it['Identifier'] == aoIdentifier
annotate_check "Check AO Event Time is still as in original alarm"
assert it['Event Time'] ==
java.time.OffsetDateTime.parse("1997-01-01T12:00:27.87+00:20").toInstant()
annotate_check "Check that State is Outstanding"
assert it[/State/] == "Outstanding"
annotate_check "Check that Acknowledgement User Identifier is same as specified in UserId argument"
assert it[/Acknowledgement User Identifier/] == "John Carter"
annotate_check "Check that Acknowledgement Time Stamp has become around time when alarm has request to unacknowledge"
assert (Instant.now().minusSeconds(15)).isBefore(it[/Acknowledgement Time Stamp/] as Instant)
annotate_check "Check original Additional Text has not changed"
assert it['Additional Text'] =~ /Everything is on fire!/
}
annotate_action "Check EMS simulator has received one request to acknowledged alarm"
emsDownAckMock.assertIsSatisfied()
assert emsDownAckMock.exchanges.size() == 1
emsDownAckMock.assertExchangeReceived(0).tap {
assert it.message.headers[HTTP_METHOD] == HttpMethods.PATCH.name()
assert parsePath(it) == '/tmb/10/alarms/AMS:5654'
it.message.getMandatoryBody(Map).tap {
assert it.size() == 3
assert it['ackSystemId'] == "Platform"
assert it['ackstate'] == "unacknowledged"
assert it['ackUserId'] == "John Carter"
}
}
})