Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Logging usage of unexpected test case in initial test run leads to stryker crash #2929

Closed
Dirk-Peters-BF opened this issue May 2, 2024 · 5 comments
Assignees
Labels
Area: Initialization projects identification and analyze 🐛 Bug Something isn't working

Comments

@Dirk-Peters-BF
Copy link
Contributor

Describe the bug
Stryker run is aborted due to crash when a specific logging call in VsTestRunner.InitialTest Line 60 is used, when a new unexpected test case is detected in the intial test run.

Logs
System.FormatException: Input string was not in a correct format. Failure to parse near offset 132. Expected an ASCII digit.
00:02:36  at System.Text.CompositeFormat.Parse(String format)
00:02:36  at Microsoft.Extensions.Logging.LogValuesFormatter..ctor(String format)
00:02:36  at Microsoft.Extensions.Logging.FormattedLogValues.<>c.<.ctor>b__9_0(String f)
00:02:36  at Microsoft.Extensions.Logging.FormattedLogValues..ctor(String format, Object[] values)
00:02:36  at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
00:02:36  at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, String message, Object[] args)
00:02:36  at Microsoft.Extensions.Logging.LoggerExtensions.LogWarning(ILogger logger, String message, Object[] args)
00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunner.InitialTest(IProjectAndTests project) in //src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunner.cs:line 60
00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunnerPool.<>c__DisplayClass12_0.b__0(VsTestRunner runner) in /
/src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs:line 62
00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunnerPool.RunThis[T](Func2 task) in /_/src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs:line 103 00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunnerPool.InitialTest(IProjectAndTests project) in /_/src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs:line 62 00:02:36  at Stryker.Core.Initialisation.InitialTestProcess.InitialTest(StrykerOptions options, IProjectAndTests project, ITestRunner testRunner) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InitialTestProcess.cs:line 35 00:02:36  at Stryker.Core.Initialisation.InitialisationProcess.InitialTest(StrykerOptions options, SourceProjectInfo projectInfo, ITestRunner testRunner, Boolean throwIfFails) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs:line 128 00:02:36  at Stryker.Core.Initialisation.InitialisationProcess.GetMutationTestInputs(StrykerOptions options, IReadOnlyCollection1 projects, ITestRunner runner) in //src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs:line 106
00:02:36  at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters, ITestRunner runner) in /
/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 66
00:02:36  at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator) in /_/src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 63

Expected behavior
Stryker does not crash.

Desktop (please complete the following information):

  • OS: Linux
  • Type of project: core
  • Framework Version dotnet core 8
  • Stryker Version 4.0.4

Additional context
Reason for abort is wrong usage of Microsoft Logging. String interpolation is used in conjunction with parameters.
I can provide a fix myself, just need a ticket/justification.

@Dirk-Peters-BF Dirk-Peters-BF added the 🐛 Bug Something isn't working label May 2, 2024
@dupdob dupdob self-assigned this May 2, 2024
@dupdob dupdob added the Area: Initialization projects identification and analyze label May 2, 2024
@dupdob
Copy link
Member

dupdob commented May 2, 2024

Thanks for reporting. I am working on a fix.
Actually, the fix is simple, but I want to activate logging for unit tests to ensure there are no similar issues

@Dirk-Peters-BF
Copy link
Contributor Author

As mentioned in the ticket, I am actually working on a fix myself but I am including other, similar logging calls. Not necessarily as severe but nevertheless not quite right.
My Problem for the described problem is to reproduce outside of the original sources.

@dupdob
Copy link
Member

dupdob commented May 2, 2024

Ok
There is a unit test for this situation. Alas, it does not crash as logging is not enabled, so string formatting is simply skipped. So no exception

@dupdob
Copy link
Member

dupdob commented May 3, 2024 via email

Dirk-Peters-BF added a commit to Dirk-Peters-BF/stryker-net that referenced this issue May 3, 2024
- fix combination of string interpolation with parameters in logging
  call in Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunner.cs
- harmonize logging calls:
  * remove string interpolation
  * use parameter name instead of index
  * use constant log messages
Dirk-Peters-BF added a commit to Dirk-Peters-BF/stryker-net that referenced this issue May 3, 2024
- fix combination of string interpolation with parameters in logging
  call in Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunner.cs
- harmonize logging calls:
  * remove string interpolation
  * use parameter name instead of index
  * use constant log messages
@Dirk-Peters-BF
Copy link
Contributor Author

The opened pull request contains the fix + some logging call harmonizing
Since I touched a lot of files for this I'd understand if the pull request is rejected.

Dirk-Peters-BF added a commit to Dirk-Peters-BF/stryker-net that referenced this issue May 15, 2024
- fix combination of string interpolation with parameters in logging
  call in Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunner.cs
- harmonize logging calls:
  * remove string interpolation
  * use parameter name instead of index
  * use constant log messages
rouke-broersma added a commit that referenced this issue May 24, 2024
…2931)

- fix combination of string interpolation with parameters in logging
  call in Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunner.cs
- harmonize logging calls:
  * remove string interpolation
  * use parameter name instead of index
  * use constant log messages

Co-authored-by: Rouke Broersma <rouke.broersma@infosupport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Initialization projects identification and analyze 🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants