Skip to content

Commit f5ec3e8

Browse files
committed
Trying to override LogAssert in Manager.cls to capture the interoperability processes after the production starts in %UnitTest.TestProduction test cases
1 parent 46edaaf commit f5ec3e8

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

cls/TestCoverage/Manager.cls

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Property SourceNamespace As %String(MAXLEN = 255) [ Internal, Private ];
5050

5151
Property ProcessIDs As %List [ Internal, Private ];
5252

53+
Property InteroperabilityProcesses As %Boolean [ InitialExpression = 0, Internal, Private ];
54+
5355
Property Run As TestCoverage.Data.Run;
5456

5557
/// Known coverage targets (already snapshotted). <br />
@@ -176,6 +178,24 @@ Method CoverageTargetsSet(%value) As %Status [ Internal, Private ]
176178
Quit $$$OK
177179
}
178180

181+
Method LogAssert(success, action, description, extra, location)
182+
{
183+
set ^IRIS.TEMPCG($i(^IRIS.TEMPCG)) = "We're in LogAssert"
184+
do ##super(success, action, description, extra, location)
185+
if (..InteroperabilityProcesses) {
186+
// Collect the list of PIDs used by Interoperability processes in the current namespace
187+
// Run unit tests collecting coverage in that specific list of processes (plus the current process)
188+
&sql(select %DLIST(Process) into :tProcessIDs from %SYS.ProcessQuery_SS() where "User" = '_Ensemble')
189+
If (SQLCODE < 0) {
190+
Throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,%msg)
191+
}
192+
if ('$LISTFIND(tProcessIDs, $Job)) {
193+
set $LIST(tProcessIDs, *+1) = $Job
194+
}
195+
set ..ProcessIDs = tProcessIDs
196+
}
197+
}
198+
179199
Method StartCoverageTracking() As %Status [ Private ]
180200
{
181201
Set tSC = $$$OK
@@ -242,33 +262,7 @@ Method StartCoverageTracking() As %Status [ Private ]
242262
}
243263
}
244264
}
245-
ElseIf ($list(tProcessIDs, 1)="Interop")
246-
{
247-
// Collect the list of PIDs used by Interoperability processes in the current namespace
248-
// Run unit tests collecting coverage in that specific list of processes (plus the current process)
249-
&sql(select %DLIST(Process) into :tProcessIDs from %SYS.ProcessQuery_SS() where "User" = '_Ensemble')
250-
If (SQLCODE < 0) {
251-
Throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,%msg)
252-
}
253-
if ('$LISTFIND(tProcessIDs, $Job)) {
254-
set $LIST(tProcessIDs, *+1) = $Job
255-
}
256-
// Extra check to make sure that monitor is stopped (another chance to get problem processes to unmap from shared memory)
257-
// Sometimes the monitor does not stop right away if there are other processes that are being monitored.
258-
// The root cause of this is unknown and could use further investigation at some point.
259-
Set tMaxAttempts = 5
260-
For {
261-
Set tUnmappedAll = $zu(84,0,0)
262-
Hang 1
263-
If (tUnmappedAll) {
264-
Quit
265-
}
266-
If ($Increment(tUnmapCounter) > tMaxAttempts) {
267-
Set tMsg = $$$FormatText("Some process(es) still holding on to shared memory for line by line monitor after %1 attempts to release. See console log or cstat -p-1 for details.",tMaxAttempts)
268-
$$$ThrowStatus($$$ERROR($$$GeneralError,tMsg))
269-
}
270-
}
271-
}
265+
272266
set ^IRIS.TEMPCG($i(^IRIS.TEMPCG)) = tProcessIDs
273267
Set tMetrics = $ListBuild("RtnLine") _ $Select(..Timing:$ListBuild("Time","TotalTime"),1:"")
274268
$$$ThrowOnError(..Monitor.StartWithScope(tRelevantTargets,tMetrics,tProcessIDs))
@@ -564,6 +558,8 @@ ClassMethod OnBeforeAllTests(manager As TestCoverage.Manager, dir As %String, By
564558
Set tProcessIDs = ""
565559
} ElseIf (tProcessIDs = "") || '$ListValid(tProcessIDs) {
566560
Set tProcessIDs = $ListBuild($Job)
561+
} ElseIf ($list(tProcessIDs, 1)="Interop") {
562+
Set manager.InteroperabilityProcesses = 1
567563
}
568564
Set tTiming = $Get(userparam("Timing"),0)
569565
Set tSubject = $Get(userparam("Subject"))

0 commit comments

Comments
 (0)