@@ -88,34 +88,37 @@ public AgentLogBase(ITestOutputHelper testLogger)
88
88
89
89
public abstract IEnumerable < string > GetFileLines ( ) ;
90
90
91
- public string GetAccountId ( TimeSpan ? timeoutOrZero = null )
91
+ public string GetAccountId ( )
92
92
{
93
- var reportingAppLink = GetReportingAppLink ( timeoutOrZero ) ;
93
+ var reportingAppLink = GetReportingAppLink ( ) ;
94
94
var reportingAppUri = new Uri ( reportingAppLink ) ;
95
95
var accountId = reportingAppUri . Segments [ 2 ] ;
96
96
if ( accountId == null )
97
97
throw new Exception ( "Could not find account ID in second segment of reporting app link: " + reportingAppLink ) ;
98
98
return accountId . TrimEnd ( '/' ) ;
99
99
}
100
100
101
- public string GetApplicationId ( TimeSpan ? timeoutOrZero = null )
101
+ public string GetApplicationId ( )
102
102
{
103
- var reportingAppLink = GetReportingAppLink ( timeoutOrZero ) ;
103
+ var reportingAppLink = GetReportingAppLink ( ) ;
104
104
var reportingAppUri = new Uri ( reportingAppLink ) ;
105
105
var applicationId = reportingAppUri . Segments [ 4 ] ;
106
106
if ( applicationId == null )
107
107
throw new Exception ( "Could not find application ID in second segment of reporting app link: " + reportingAppLink ) ;
108
108
return applicationId . TrimEnd ( '/' ) ;
109
109
}
110
110
111
- public string GetCrossProcessId ( TimeSpan ? timeoutOrZero = null )
111
+ public string GetCrossProcessId ( )
112
112
{
113
113
return $@ "{ GetAccountId ( ) } #{ GetApplicationId ( ) } ";
114
114
}
115
115
116
- public string GetReportingAppLink ( TimeSpan ? timeoutOrZero = null )
116
+ private string GetReportingAppLink ( )
117
117
{
118
- var match = WaitForLogLine ( AgentReportingToLogLineRegex , timeoutOrZero ) ;
118
+ var match = TryGetLogLine ( AgentReportingToLogLineRegex ) ;
119
+ if ( ! match . Success || match . Groups . Count < 2 )
120
+ throw new Exception ( "Could not find reporting app link in log file." ) ;
121
+
119
122
return match . Groups [ 1 ] . Value ;
120
123
}
121
124
@@ -164,23 +167,19 @@ public IEnumerable<Match> WaitForLogLines(string regularExpression, TimeSpan? ti
164
167
165
168
var timeout = timeoutOrZero ?? TimeSpan . Zero ;
166
169
167
- _testLogger ? . WriteLine ( $ "{ Timestamp } WaitForLogLines Waiting for expression: { regularExpression } . Duration: { timeout . TotalSeconds : N0} seconds. Minimum count: { minimumCount } ") ;
168
-
169
170
var timeTaken = Stopwatch . StartNew ( ) ;
170
171
do
171
172
{
172
173
var matches = TryGetLogLines ( regularExpression ) . ToList ( ) ;
173
174
if ( matches . Count >= minimumCount )
174
175
{
175
- _testLogger ? . WriteLine ( $ "{ Timestamp } WaitForLogLines Matched expression: { regularExpression } in { timeTaken . Elapsed . TotalSeconds : N1} s.") ;
176
176
return matches ;
177
177
}
178
178
179
179
Thread . Sleep ( TimeSpan . FromMilliseconds ( 100 ) ) ;
180
180
} while ( timeTaken . Elapsed < timeout ) ;
181
181
182
182
var message = $ "{ Timestamp } Log line did not appear a minimum of { minimumCount } times within { timeout . TotalSeconds : N0} seconds. Expected line expression: { regularExpression } ";
183
- _testLogger ? . WriteLine ( message ) ;
184
183
throw new Exception ( message ) ;
185
184
}
186
185
0 commit comments