|
5 | 5 | using System.Collections.Generic;
|
6 | 6 | using System.Linq;
|
7 | 7 | using System.Text.RegularExpressions;
|
| 8 | +using Microsoft.Azure.WebJobs.Script.Tests.Workers; |
8 | 9 | using Microsoft.Azure.WebJobs.Script.WebHost;
|
9 | 10 | using Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics;
|
10 | 11 | using Microsoft.Extensions.Logging;
|
@@ -36,7 +37,9 @@ public LinuxAppServiceEventGeneratorTests()
|
36 | 37 | [LinuxEventGenerator.FunctionsMetricsCategory] =
|
37 | 38 | new MockLinuxAppServiceFileLogger(LinuxEventGenerator.FunctionsMetricsCategory, string.Empty, null),
|
38 | 39 | [LinuxEventGenerator.FunctionsDetailsCategory] =
|
39 |
| - new MockLinuxAppServiceFileLogger(LinuxEventGenerator.FunctionsDetailsCategory, string.Empty, null) |
| 40 | + new MockLinuxAppServiceFileLogger(LinuxEventGenerator.FunctionsDetailsCategory, string.Empty, null), |
| 41 | + [LinuxEventGenerator.FunctionsExecutionEventsCategory] = |
| 42 | + new MockLinuxAppServiceFileLogger(LinuxEventGenerator.FunctionsExecutionEventsCategory, string.Empty, null) |
40 | 43 | };
|
41 | 44 |
|
42 | 45 | var loggerFactoryMock = new Mock<LinuxAppServiceFileLoggerFactory>(MockBehavior.Strict);
|
@@ -171,5 +174,32 @@ public void ParseAzureMonitoringEvents(LogLevel level, string resourceId, string
|
171 | 174 | p => Assert.Equal(properties, UnNormalize(p)),
|
172 | 175 | p => Assert.True(DateTime.TryParse(p, out DateTime dt)));
|
173 | 176 | }
|
| 177 | + |
| 178 | + [Theory] |
| 179 | + [MemberData(nameof(LinuxEventGeneratorTestData.GetFunctionExecutionEvents), MemberType = typeof(LinuxEventGeneratorTestData))] |
| 180 | + public void ParseFunctionExecutionEvents(string executionId, string siteName, int concurrency, string functionName, string invocationId, |
| 181 | + string executionStage, long executionTimeSpan, bool success) |
| 182 | + { |
| 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))); |
| 203 | + } |
174 | 204 | }
|
175 | 205 | }
|
0 commit comments