Skip to content

Commit

Permalink
updated to pass jobName with the event, indicate if an event defintio…
Browse files Browse the repository at this point in the history
…n is sequenced and report either job fail due to blocked events or job complete if there are no blocked events when SVDC reports job is completedd
  • Loading branch information
gregarnot committed Aug 1, 2023
1 parent 397f9da commit 14b1ada
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 20 deletions.
2 changes: 1 addition & 1 deletion models/AEO_SVDC/masl/AEO_SVDC/AEO_SVDC.prj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ project AEO_SVDC is

terminator Req_IF_Verification is
public service audit_event ( jobId: in string,
nodeName: in string,
bName: in string,
application: in string,
auditEventType: in string,
auditEventId: in string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public service AEOrdering::Req_IF_Verification~>audit_event ( jobId: in string,
nodeName: in string,
jobName: in string,
application: in string,
auditEventType: in string,
auditEventId: in string,
Expand Down Expand Up @@ -35,7 +35,7 @@ begin
jobId,
prevAuditEventIds,
auditEventId,
auditEventData
// nodeName ??
auditEventData,
jobName
);
end service;
12 changes: 12 additions & 0 deletions models/AEOrdering/config/job_definitions2/AEOrdering-Test.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,17 @@
"SequenceStart": true,
"SequenceEnd": true
}
],
"UnhappyEvents": [
{
"EventName": "yyy",
"PackageName": "Unhappy Events",
"Application": "app1"
},
{
"EventName": "zzz",
"PackageName": "Unhappy Events",
"Application": "app1"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,24 @@ INSERT INTO O_ATTR
"937e7b24-4016-44da-abc5-a7bf3c67b00c",
'',
'');
INSERT INTO O_NBATTR
VALUES ("8307fce7-f9c9-4f80-81dc-eaf322d71924",
"387c8f68-277a-4047-a914-04ba096d94dd");
INSERT INTO O_BATTR
VALUES ("8307fce7-f9c9-4f80-81dc-eaf322d71924",
"387c8f68-277a-4047-a914-04ba096d94dd");
INSERT INTO O_ATTR
VALUES ("8307fce7-f9c9-4f80-81dc-eaf322d71924",
"387c8f68-277a-4047-a914-04ba096d94dd",
"bf2277d3-b905-4438-bf8b-868172553e91",
'isSequenced',
'',
'',
'isSequenced',
0,
"937e7b24-4016-44da-abc5-a7bf3c67b00c",
'',
'');
INSERT INTO O_ID
VALUES (0,
"387c8f68-277a-4047-a914-04ba096d94dd");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ begin
isSequenceStart => sequenceStart, isSequenceEnd => sequenceEnd,
staleAuditEventDuration => this.staleAuditEventDuration,
blockedAuditEventDuration => this.blockedAuditEventDuration,
previousEventTypes => previousEventTypes, isBreak => isBreak);
previousEventTypes => previousEventTypes, isBreak => isBreak, isSequenced => true);
link eventType R6 application;
link eventType R12 this;
else
Expand Down Expand Up @@ -171,6 +171,40 @@ begin

end loop;
end if;
if jobTypeJSONObject'contains("UnhappyEvents") and jobTypeJSONObject["UnhappyEvents"].kind = JSON::Array then
for eventTypeJSONElement in JSON::get_array(jobTypeJSONObject["UnhappyEvents"]) loop
eventTypeName := "";
sequenceName := "";
occurrenceId := 1;
applicationName := "";
sequenceStart := false;
sequenceEnd := false;
isBreak := false;
hasDynamicControl := false;
previousEventTypes := emptyPreviousEventTypes;
eventDefJSONObject := JSON::get_object(eventTypeJSONElement);
eventTypeName := JSON::get_string(eventDefJSONObject["EventName"]);
applicationName := JSON::get_string(eventDefJSONObject["Application"]);

// now we have extracted the data create the event
application := find_one Application(applicationName = applicationName);
if application = null then
application := create Application(applicationName => applicationName);
end if;

eventType := find_one AuditEventType(eventType = eventTypeName and applicationName = applicationName and occurrenceId = occurrenceId);
if eventType = null then
eventType := create unique AuditEventType(eventType => eventTypeName, occurrenceId => occurrenceId,
applicationName => applicationName, sequenceName => sequenceName,
isSequenceStart => sequenceStart, isSequenceEnd => sequenceEnd,
staleAuditEventDuration => this.staleAuditEventDuration,
blockedAuditEventDuration => this.blockedAuditEventDuration,
previousEventTypes => previousEventTypes, isBreak => isBreak, isSequenced => false);
link eventType R6 application;
link eventType R12 this;
end if;
end loop;
end if;
else
logMessage := "AEOrdering::JobType.loadEventTypes : Failed to process event type for unknown Job Type " & jobTypeName;
Logger::log(Logger::Error, "AEOrdering", logMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ reportableAuditEventData : ReportableAuditEventDataType;
allReportableAuditEventData : sequence of ReportableAuditEventDataType;
eventContent : string;
auditEventTypes : set of instance of AuditEventType;
jobType : instance of JobType;

begin

Expand Down Expand Up @@ -49,10 +50,10 @@ begin
allReportableAuditEventData := allReportableAuditEventData & reportableAuditEventData;
end if;
end loop;

jobType := auditEvent -> R7.AuditEventType -> R12.JobType;
logMessage := "AEOrdering::ReportedAuditEvent.reportEvent : REPORTING EVENT JobId = " & job.jobId & " : EventId = " & auditEvent.auditEventId & " EventType = " & auditEvent.eventType & " : PreviousEventId = " & auditEvent.reportedPrevEventIds'image;
Logger::log(Logger::Debug, "AEOrdering", logMessage);
Req_IF_Verification~>audit_event(job.jobId, auditEvent.reportedNodeName, auditEvent.reportedApplication, auditEvent.reportedEventType,
Req_IF_Verification~>audit_event(job.jobId, jobType.jobTypeName, auditEvent.reportedApplication, auditEvent.reportedEventType,
auditEvent.auditEventId, auditEvent.reportedAuditEventTime, auditEvent.reportedPrevEventIds, allReportableAuditEventData);
// check for any following events that need reporting
for followedByEvent in (auditEvent -> R11.isFollowedBy.AuditEvent) loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ begin
eventDefinitions := emptyEventDefinitions;
for auditEventType in (job -> R12.AuditEventType() ordered_by (auditEventTypeId)) loop
eventDefinitions := eventDefinitions & (auditEventType.sequenceName, auditEventType.eventType, auditEventType.occurrenceId,
auditEventType.previousEventTypes, auditEventType.isSequenceStart, auditEventType.isSequenceEnd, auditEventType.isBreak);
auditEventType.previousEventTypes, auditEventType.isSequenceStart, auditEventType.isSequenceEnd,
auditEventType.isBreak, auditEventType.isSequenced);
end loop;
Req_IF_Verification~>jobDefinition(job.jobTypeName, eventDefinitions);
// report any dynamic controls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end service;

//! ACTIVITY BEGIN. 'b096e6d3-30f2-4a4c-a458-775fb73552d2' DO NOT EDIT THIS LINE.
public service AEOrdering::Req_IF_Verification~>audit_event ( jobId : in string,
nodeName : in string,
jobName : in string,
application : in string,
auditEventType : in string,
auditEventId : in string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ job : instance of Job;
begin
job := find_one Job(jobId = jobId);
if job /= null then
job.jobDeleted();
// check if we have any blocked events and if so fail the job otherwise delete the job
if (job -> R9.AuditEvent -> R4.BlockedAuditEvent)'length > 0 then
job.failJob("JobId = " & job.jobId & " : FailureReason = Job ended with blocked events");
else
job.jobDeleted();
Req_IF_Verification~>jobComplete(jobId);
end if;
end if;

end service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,42 @@ begin

for jobDefinition in reportedJobDefinitions loop
if jobDefinition.jobName = "AEOrdering-Test" then
if jobDefinition.eventDefinitions'length = 6 then
if jobDefinition.eventDefinitions'length = 8 then
for reportEventDefinition in jobDefinition.eventDefinitions loop
if reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "aaa" and reportEventDefinition.occurrenceId = 1 then
if reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "aaa" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = true then
null;
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "bbb" and reportEventDefinition.occurrenceId = 1 then
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "bbb" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = true then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 1), "Unexepected previous event types eventType = bbb");
for previousEventType in reportEventDefinition.previousEventTypes loop
Assertions::assertTrue((previousEventType.previousEventTypeName = "aaa" and previousEventType.occurrenceId = 1), "");
end loop;
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "ccc" and reportEventDefinition.occurrenceId = 1 then
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "ccc" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = true then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 1), "Unexepected previous event types eventType = ccc");
for previousEventType in reportEventDefinition.previousEventTypes loop
Assertions::assertTrue((previousEventType.previousEventTypeName = "bbb" and previousEventType.occurrenceId = 1 and previousEventType.constraintDefinitionId = "cccEventXOR" and previousEventType.constraintValue = "XOR"), "");
end loop;
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "ddd" and reportEventDefinition.occurrenceId = 1 then
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "ddd" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = true then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 1), "Unexepected previous event types eventType = ddd");
for previousEventType in reportEventDefinition.previousEventTypes loop
Assertions::assertTrue((previousEventType.previousEventTypeName = "ccc" and previousEventType.occurrenceId = 1), "");
end loop;
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "eee" and reportEventDefinition.occurrenceId = 1 then
elsif reportEventDefinition.sequenceName = "SEQUENCE1" and reportEventDefinition.eventType = "eee" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = true then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 1), "Unexepected previous event types eventType = eee");
for previousEventType in reportEventDefinition.previousEventTypes loop
Assertions::assertTrue((previousEventType.previousEventTypeName = "ddd" and previousEventType.occurrenceId = 1), "");
end loop;
elsif reportEventDefinition.sequenceName = "SEQUENCE2" and reportEventDefinition.eventType = "fff" and reportEventDefinition.occurrenceId = 1 then
elsif reportEventDefinition.sequenceName = "SEQUENCE2" and reportEventDefinition.eventType = "fff" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = true then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 0), "Unexepected previous event types eventType = fff");
elsif reportEventDefinition.sequenceName = "" and reportEventDefinition.eventType = "yyy" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = false then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 0), "Unexepected previous event types eventType = fff");
elsif reportEventDefinition.sequenceName = "" and reportEventDefinition.eventType = "zzz" and reportEventDefinition.occurrenceId = 1 and reportEventDefinition.isSequenced = false then
Assertions::assertTrue((reportEventDefinition.previousEventTypes'length = 0), "Unexepected previous event types eventType = fff");
else
Assertions::assertTrue(false, "Unknown reported event definitions for AEOrdering-Test");
end if;
end loop;
else
Assertions::assertTrue(false, "Test Config File: Failed to find the correct number of reported event definitions for AEOrdering-Test, expected 6 found " & (jobDefinition.eventDefinitions'length)'image);
Assertions::assertTrue(false, "Test Config File: Failed to find the correct number of reported event definitions for AEOrdering-Test, expected 8 found " & (jobDefinition.eventDefinitions'length)'image);
end if;
elsif jobDefinition.jobName = "Other-Test-Job" then
if jobDefinition.eventDefinitions'length = 3 then
Expand Down Expand Up @@ -284,7 +288,7 @@ begin
verificationAuditEvents:= find _TEST_Req_IF_Verification_audit_event();
Assertions::assertTrue((verificationAuditEvents'length = 6), "Test Ordered Job: Invalid number of verification audit event = " & verificationAuditEvents'length'image);

verificationAuditEvent := find_one _TEST_Req_IF_Verification_audit_event(auditEventId = "1");
verificationAuditEvent := find_one _TEST_Req_IF_Verification_audit_event(auditEventId = "1" and jobName = "AEOrdering-Test");
Assertions::assertTrue((verificationAuditEvent /= null), "Test Ordered Job: Failed to find` verification audit event id = 1");
Assertions::assertTrue((verificationAuditEvent.prevAuditEventIds'length = 0), "Test Ordered Job: Failed as verification audit event id = 1 reported prevEventIds was invalid");

Expand Down Expand Up @@ -518,6 +522,7 @@ auditEventTime : timestamp;
job : instance of Job;
verificationAuditEvents : sequence of instance of _TEST_Req_IF_Verification_audit_event;
verificationAuditEvent : instance of _TEST_Req_IF_Verification_audit_event;
verificationFailedJobs : sequence of instance of _TEST_Req_IF_Verification_failedJob;
prevEventIds : sequence of string;
emptyPrevEventIds : sequence of string;
auditEventData : AuditEventDataType;
Expand Down Expand Up @@ -573,6 +578,7 @@ begin
Assertions::assertTrue((verificationAuditEvent /= null), "Test Job Complete: Failed to find verification audit event id = 3");
Assertions::assertTrue((verificationAuditEvent.prevAuditEventIds'length = 1 and verificationAuditEvent.prevAuditEventIds[verificationAuditEvent.prevAuditEventIds'first] = "2"), "Test Job Complete: Failed as verification audit event id = 2 reported prevEventIds was invalid");
AEOrdering::checkJobComplete();
delete verificationAuditEvents;

// create a failed job
auditEventTime := timestamp'now - @PT24H@;
Expand All @@ -588,6 +594,26 @@ begin
// verify that the job was completed
AEOrdering::checkJobComplete();

// create a blocked job
verificationFailedJobs := find _TEST_Req_IF_Verification_failedJob();
delete verificationFailedJobs;
auditEventTime := timestamp'now;
prevEventIds := emptyPrevEventIds & "1";
AEOrdering::AcceptEvent("3", "node1", "app1", "bbb", "2", auditEventTime'image, prevEventIds, auditEventData);
job := find_one Job(jobId = "3");
if job /= null then
// the job should be failed so generate the delete job event
AEOrdering::deleteJob("3");;
Test::service_event_queue();
Test::service_event_queue();
verificationFailedJobs := find _TEST_Req_IF_Verification_failedJob(jobId = "3");
Assertions::assertTrue((verificationFailedJobs'length = 1), "Test Job Failure: Invalid number of failed jobs event = " & verificationFailedJobs'length'image);
Assertions::assertTrue(((find verificationFailedJobs(jobId = "3"))'length = 1), "Test Job Failure: Failed to find failed job id = 3");
delete verificationFailedJobs;
else
Test::fail("", 1, "Test Job Complete: Failed to find Failed Job");
end if;

end service;
//! ACTIVITY END. DO NOT EDIT THIS LINE.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ INSERT INTO C_PP
VALUES ("8b62da26-4b46-4c6a-9681-bd43cc074c92",
"d25f951a-f55e-4e11-b9ed-d95798d582a5",
"ca05455a-8231-467f-be9a-63be44793e6a",
'nodeName',
'jobName',
'',
0,
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,14 @@ INSERT INTO S_MBR
"937e7b24-4016-44da-abc5-a7bf3c67b00c",
"130aea57-5f08-4749-ad9a-75f5c7d998a3",
'');
INSERT INTO S_MBR
VALUES ("82573ab5-c45f-4f53-a2e9-3da384a9595c",
'isSequenced',
'',
"2ad0c5b9-f515-4c1b-9afb-f283927665c0",
"937e7b24-4016-44da-abc5-a7bf3c67b00c",
"6218b11e-e7e5-4346-8396-8f655e31ca9d",
'');
INSERT INTO PE_PE
VALUES ("2ad0c5b9-f515-4c1b-9afb-f283927665c0",
1,
Expand Down

0 comments on commit 14b1ada

Please sign in to comment.