From 14b1ada4a9dfb50b9dd235101ac9bbb9e5320d57 Mon Sep 17 00:00:00 2001 From: gregarnot Date: Tue, 1 Aug 2023 17:38:50 +0100 Subject: [PATCH] updated to pass jobName with the event, indicate if an event defintion 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 --- models/AEO_SVDC/masl/AEO_SVDC/AEO_SVDC.prj | 2 +- ...rdering_Req_IF_Verification_audit_event.tr | 6 +-- .../job_definitions2/AEOrdering-Test.json | 12 +++++ .../AuditEventType/AuditEventType.xtuml | 18 ++++++++ .../AEOclasses/JobType/JobType.masl | 36 ++++++++++++++- .../ReportedAuditEvent.masl | 5 ++- .../AEOclasses/SystemSpec/SystemSpec.masl | 3 +- .../AEOdomain/AEOrdering/AEOrdering.masl | 2 +- .../AEOrdering/functions/functions.masl | 8 +++- .../AEOdomain/AEOrdering/tests/tests.masl | 44 +++++++++++++++---- .../AEOdomain/Shared/Ordering/Ordering.xtuml | 2 +- .../AEOrdering/AEOdomain/Shared/Shared.xtuml | 8 ++++ 12 files changed, 126 insertions(+), 20 deletions(-) diff --git a/models/AEO_SVDC/masl/AEO_SVDC/AEO_SVDC.prj b/models/AEO_SVDC/masl/AEO_SVDC/AEO_SVDC.prj index e9ea05e6..8e0a7e00 100644 --- a/models/AEO_SVDC/masl/AEO_SVDC/AEO_SVDC.prj +++ b/models/AEO_SVDC/masl/AEO_SVDC/AEO_SVDC.prj @@ -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, diff --git a/models/AEO_SVDC/masl/AEO_SVDC/AEOrdering_Req_IF_Verification_audit_event.tr b/models/AEO_SVDC/masl/AEO_SVDC/AEOrdering_Req_IF_Verification_audit_event.tr index c0eb1558..9faefd29 100644 --- a/models/AEO_SVDC/masl/AEO_SVDC/AEOrdering_Req_IF_Verification_audit_event.tr +++ b/models/AEO_SVDC/masl/AEO_SVDC/AEOrdering_Req_IF_Verification_audit_event.tr @@ -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, @@ -35,7 +35,7 @@ begin jobId, prevAuditEventIds, auditEventId, - auditEventData - // nodeName ?? + auditEventData, + jobName ); end service; diff --git a/models/AEOrdering/config/job_definitions2/AEOrdering-Test.json b/models/AEOrdering/config/job_definitions2/AEOrdering-Test.json index 70a32209..a6759c0f 100644 --- a/models/AEOrdering/config/job_definitions2/AEOrdering-Test.json +++ b/models/AEOrdering/config/job_definitions2/AEOrdering-Test.json @@ -116,5 +116,17 @@ "SequenceStart": true, "SequenceEnd": true } + ], + "UnhappyEvents": [ + { + "EventName": "yyy", + "PackageName": "Unhappy Events", + "Application": "app1" + }, + { + "EventName": "zzz", + "PackageName": "Unhappy Events", + "Application": "app1" + } ] } diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/AuditEventType/AuditEventType.xtuml b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/AuditEventType/AuditEventType.xtuml index 97ec30c4..7d342e5a 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/AuditEventType/AuditEventType.xtuml +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/AuditEventType/AuditEventType.xtuml @@ -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"); diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/JobType/JobType.masl b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/JobType/JobType.masl index f9c78919..ba5cd131 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/JobType/JobType.masl +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/JobType/JobType.masl @@ -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 @@ -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); diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/ReportedAuditEvent/ReportedAuditEvent.masl b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/ReportedAuditEvent/ReportedAuditEvent.masl index 4fbcf4be..dcf89bfd 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/ReportedAuditEvent/ReportedAuditEvent.masl +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/ReportedAuditEvent/ReportedAuditEvent.masl @@ -11,6 +11,7 @@ reportableAuditEventData : ReportableAuditEventDataType; allReportableAuditEventData : sequence of ReportableAuditEventDataType; eventContent : string; auditEventTypes : set of instance of AuditEventType; +jobType : instance of JobType; begin @@ -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 diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/SystemSpec/SystemSpec.masl b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/SystemSpec/SystemSpec.masl index ce15e8ca..afd3ea43 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/SystemSpec/SystemSpec.masl +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOclasses/SystemSpec/SystemSpec.masl @@ -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 diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOrdering.masl b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOrdering.masl index 544a08ae..2ee6de46 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOrdering.masl +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/AEOrdering.masl @@ -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, diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/functions/functions.masl b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/functions/functions.masl index b871dc58..404080d3 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/functions/functions.masl +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/functions/functions.masl @@ -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; diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/tests/tests.masl b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/tests/tests.masl index 81df3a45..00df4f52 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/tests/tests.masl +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/AEOrdering/tests/tests.masl @@ -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 @@ -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"); @@ -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; @@ -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@; @@ -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. diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Ordering/Ordering.xtuml b/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Ordering/Ordering.xtuml index 995ca84d..e164fe8b 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Ordering/Ordering.xtuml +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Ordering/Ordering.xtuml @@ -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, '', diff --git a/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Shared.xtuml b/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Shared.xtuml index 49ed4781..c28fffa6 100644 --- a/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Shared.xtuml +++ b/models/AEOrdering/models/AEOrdering/AEOdomain/Shared/Shared.xtuml @@ -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,