Skip to content

Test failure Microsoft.Extensions.Hosting.WindowsServiceLifetimeTests.ServiceSequenceIsCorrect #93194

Closed

Description

@v-wenyuxu

Failed in: runtime-coreclr libraries-pgo 20231008.1

Failed tests:

net9.0-windows-Release-x86-CoreCLR_checked-syntheticpgo_blend-Windows.10.Amd64.Open
    - Microsoft.Extensions.Hosting.WindowsServiceLifetimeTests.ServiceSequenceIsCorrect

Error message:

Assert.Equal() Failure
                                   ↓ (pos 74)
Expected: ···Service.StartAsync\r\nlifetime started\r\nWindowsServiceLifetime.···
Actual:   ···Service.StartAsync\r\nWindowsServiceLifetime.OnStop\r\nlifetime s···
                                   ↑ (pos 74)

Stack trace:

   at Microsoft.Extensions.Hosting.WindowsServiceLifetimeTests.ServiceSequenceIsCorrect() in /_/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/WindowsServiceLifetimeTests.cs:line 242
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 48

Activity

  1. ghost added
    untriaged
    on Oct 9, 2023
  2. added this to the 9.0.0 milestone on Oct 10, 2023
  3. ghost removed
    untriaged
    on Oct 10, 2023
  4. buyaa-n commented on Oct 10, 2023

    @buyaa-n
    Contributor

    Looks like race condition in the test CC @ericstj

  5. ericstj commented on Oct 10, 2023

    @ericstj
    Member

    Yeah, this test doesn't force the sequence -- it relies on a certain amount of time being enough for the service to reach steady-state:

    serviceTester.Start();
    serviceTester.WaitForStatus(ServiceControllerStatus.Running);
    var statusEx = serviceTester.QueryServiceStatusEx();
    var serviceProcess = Process.GetProcessById(statusEx.dwProcessId);
    // Give a chance for all asynchronous "started" events to be raised, these happen after the service status changes to started
    Thread.Sleep(1000);
    serviceTester.Stop();
    serviceTester.WaitForStatus(ServiceControllerStatus.Stopped);

    We could introduce a synchronization primitive here and have the test wait for that to be signaled by the service.

  6. self-assigned this
    on Jul 25, 2024
  7. added
    in-pr
    on Aug 1, 2024
  8. locked and limited conversation to collaborators on Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-x86area-Extensions-Hostingblocking-clean-ci-optionalin-pros-windows

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions