|
11 | 11 | using Microsoft.Extensions.Logging;
|
12 | 12 | using Moq;
|
13 | 13 | using Xunit;
|
| 14 | +using static Microsoft.Azure.WebJobs.Script.ScriptConstants; |
14 | 15 |
|
15 | 16 | namespace Microsoft.Azure.WebJobs.Script.Tests.Diagnostics
|
16 | 17 | {
|
@@ -178,28 +179,47 @@ public void ParseAzureMonitoringEvents(LogLevel level, string resourceId, string
|
178 | 179 | [Theory]
|
179 | 180 | [MemberData(nameof(LinuxEventGeneratorTestData.GetFunctionExecutionEvents), MemberType = typeof(LinuxEventGeneratorTestData))]
|
180 | 181 | public void ParseFunctionExecutionEvents(string executionId, string siteName, int concurrency, string functionName, string invocationId,
|
181 |
| - string executionStage, long executionTimeSpan, bool success) |
| 182 | + string executionStage, long executionTimeSpan, bool success, bool featureFlagEnabled) |
182 | 183 | {
|
183 |
| - _generator.LogFunctionExecutionEvent(executionId, siteName, concurrency, functionName, invocationId, executionStage, executionTimeSpan, success); |
184 |
| - string evt = _loggers[LinuxEventGenerator.FunctionsExecutionEventsCategory].Events.Single(); |
185 |
| - |
186 |
| - Regex regex = new Regex(LinuxAppServiceEventGenerator.ExecutionEventRegex); |
187 |
| - var match = regex.Match(evt); |
188 |
| - |
189 |
| - Assert.True(match.Success); |
190 |
| - Assert.Equal(10, match.Groups.Count); |
191 |
| - |
192 |
| - var groupMatches = match.Groups.Cast<Group>().Select(p => p.Value).Skip(1).ToArray(); |
193 |
| - Assert.Collection(groupMatches, |
194 |
| - p => Assert.Equal(executionId, p), |
195 |
| - p => Assert.Equal(siteName, p), |
196 |
| - p => Assert.Equal(concurrency.ToString(), p), |
197 |
| - p => Assert.Equal(functionName, p), |
198 |
| - p => Assert.Equal(invocationId, p), |
199 |
| - p => Assert.Equal(executionStage, p), |
200 |
| - p => Assert.Equal(executionTimeSpan.ToString(), p), |
201 |
| - p => Assert.True(Convert.ToBoolean(p)), |
202 |
| - p => Assert.True(DateTime.TryParse(p, out DateTime dt))); |
| 184 | + TestScopedEnvironmentVariable featureFlags = null; |
| 185 | + try |
| 186 | + { |
| 187 | + if (featureFlagEnabled) |
| 188 | + { |
| 189 | + featureFlags = new TestScopedEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsFeatureFlags, FeatureFlagEnableLinuxEPExecutionCount); |
| 190 | + } |
| 191 | + _generator.LogFunctionExecutionEvent(executionId, siteName, concurrency, functionName, invocationId, executionStage, executionTimeSpan, success); |
| 192 | + string evt = _loggers[LinuxEventGenerator.FunctionsExecutionEventsCategory].Events.Single(); |
| 193 | + |
| 194 | + if (featureFlagEnabled) |
| 195 | + { |
| 196 | + Regex regex = new Regex(LinuxAppServiceEventGenerator.ExecutionEventRegex); |
| 197 | + var match = regex.Match(evt); |
| 198 | + |
| 199 | + Assert.True(match.Success); |
| 200 | + Assert.Equal(10, match.Groups.Count); |
| 201 | + |
| 202 | + var groupMatches = match.Groups.Cast<Group>().Select(p => p.Value).Skip(1).ToArray(); |
| 203 | + Assert.Collection(groupMatches, |
| 204 | + p => Assert.Equal(executionId, p), |
| 205 | + p => Assert.Equal(siteName, p), |
| 206 | + p => Assert.Equal(concurrency.ToString(), p), |
| 207 | + p => Assert.Equal(functionName, p), |
| 208 | + p => Assert.Equal(invocationId, p), |
| 209 | + p => Assert.Equal(executionStage, p), |
| 210 | + p => Assert.Equal(executionTimeSpan.ToString(), p), |
| 211 | + p => Assert.True(Convert.ToBoolean(p)), |
| 212 | + p => Assert.True(DateTime.TryParse(p, out DateTime dt))); |
| 213 | + } |
| 214 | + else |
| 215 | + { |
| 216 | + Assert.True(DateTime.TryParse(evt, out DateTime dt)); |
| 217 | + } |
| 218 | + } |
| 219 | + finally |
| 220 | + { |
| 221 | + featureFlags?.Dispose(); |
| 222 | + } |
203 | 223 | }
|
204 | 224 | }
|
205 | 225 | }
|
0 commit comments