Skip to content

macOS is hanging during webcmdlets tests #5464

Closed

Description

Consistent on my macBook and also affecting Travis-CI runs.

I believe James Truher (@JamesWTruher) was investigating if there is a race condition between the test listener being ready and the test case not receiving a response.

Replace HttpListener tests:

Activity

  1. added
    WG-Quality-Test
    on Nov 15, 2017
  2. SteveL-MSFT commented on Nov 15, 2017

    @SteveL-MSFT
    MemberAuthor

    cc Mark Kraus (@markekraus) don't know if you have a mac to repro this

  3. markekraus commented on Nov 15, 2017

    @markekraus
    Contributor

    Steve Lee (@SteveL-MSFT) is this an example of what you are seeing? or are there actual it block fails?
    https://travis-ci.org/PowerShell/PowerShell/jobs/301748042

    Description: Invoke-WebRequest tests/
    
    Name:        Error occurred in Describe block
    
    message:
    
    WebListener did not start before the timeout was reached.
    
    stack-trace:
    
    At /Users/travis/build/PowerShell/PowerShell/test/tools/Modules/WebListener/WebListener.psm1:91 char:13
    

    If so, we can try increasing the time out on the start up timeout here:

    It's possible the addition of the 2 new TLS listener ports takes more time on macOS.

    If you are getting this consistently on your system. run

    Publish-PSTestTools
    Set-Location ./test/tools/WebListener/bin/
    dotnet WebListener.dll ../../Modules/WebListener/ServerCert.pfx password 8083 8084 8085 8086

    See how long it takes to start up.

    I will try to repro this myself.

  4. markekraus commented on Nov 15, 2017

    @markekraus
    Contributor

    ok.. I see something completely different in my macOS system. 1 in 3 launches of the web cmdlet tests I'm getting this:

    [-] Error occurred in Describe block 10.66s
       HttpListener failed to respond
       At /Users/admin/git/PowerShell/test/tools/Modules/HttpListener/HttpListener.psm1:362 char:17
     [-] Error occurred in test script './test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1' 257ms
       Cannot index into a null array.
       at Describe, /Users/admin/git/PowerShell/src/powershell-unix/bin/Linux/netcoreapp2.0/osx.10.12-x64/publish/Modules/Pester/Functions/Describe.ps1: line 117
    

    which is the HttpListener and not WebListener.

    Then 1 in 2 runs that get past that error I get hung up on the Validate Invoke-WebRequest returns empty RelationLink property if there is no Link Header test and have to kill the shell. That test is making a call to the HttpListener.

    I tried increasing the time out on HttpListener to 25, and it reduce the initialization fail to 1 in 5.. ☹️

    I added a -TimeoutSec 5 to the Validate Invoke-WebRequest returns empty RelationLink property if there is no Link Header` and now that test never completely hangs.

    But none of this matches the fails I'm seeing in Travis CI.

  5. SteveL-MSFT commented on Nov 15, 2017

    @SteveL-MSFT
    MemberAuthor

    James Truher (@JamesWTruher) is currently investigating

  6. SteveL-MSFT commented on Nov 20, 2017

    @SteveL-MSFT
    MemberAuthor

    Looks like the hang is related to the old httplistener, I'm going to convert tests to use the new weblistener and get rid of httplistener.

  7. TravisEz13 commented on Nov 20, 2017

    @TravisEz13
    Member
  8. markekraus commented on Nov 20, 2017

    @markekraus
    Contributor

    I'm confused as to why that started failing suddenly. The actual code for HttpListener hasn't been touched for months and I don't see how changing the copyright string would have affected anything. I would blame the WebListener changes being too many threads for CI, but, I see the same thing every now and then in my mac, and HttpListener loads and fails before WebListener even gets the chance to clash.

  9. SteveL-MSFT commented on Nov 20, 2017

    @SteveL-MSFT
    MemberAuthor

    Mark Kraus (@markekraus) it's puzzling why it started failing as the code for both HttpListener and the corresponding tests haven't been touched. The other suspect is that we picked up dotnetcore 2.0.4 servicing preview, but would need a simpler repro if it's an issue in corefx.

    I could try building a private with dotnetcore 2.0.0 to at least eliminate whether it's corefx

    update: still hangs on 2.0.0, so I guess that's good news, but then something changed on our side

  10. SteveL-MSFT commented on Nov 21, 2017

    @SteveL-MSFT
    MemberAuthor

    I reset to beta.8 and rebuilt PSCore6, then ran the RC webcmdlet tests and still hung. At this point, the only thing that changed is macOS.

  11. iSazonov commented on Nov 21, 2017

    @iSazonov
    Collaborator

    On CI Appveyor failed tests is "alias" tests - I think we should remove its (we have separate test set for aliases).

  12. 18 remaining items

  13. iSazonov commented on Nov 22, 2017

    @iSazonov
    Collaborator

    Make sense to add some code hooks to log a status of threads?

  14. markekraus commented on Nov 22, 2017

    @markekraus
    Contributor

    Ok, I give up on this. I cannot reproduce the hangs at all outside of these tests. It must be a combination of things that cause the hang, but it is definitely hanging inside HttpListener. It gets the request, starts processing it and then never sends the response. It claims that it has sent the response, but tcpdump begs to differ. This could be something to do with running a child process, then pester, and then a runspace. If I start HttpListener in the foreground in another console, this never hangs and the tests complete successfully every time.

    I think we just need to move all of the tests to WebListener. I've spent way too much time on this already, when it was always my plan to eventually move these tests over. As much as I would love to know the root cause to this, finding it is out of my depth at this point.

    If we want to keep these from false failing or hanging in CI, I suggest these 2 tests be set to skip on macOS:

    It "Validate Invoke-WebRequest returns empty RelationLink property if there is no Link Header" {

    It "Validate Invoke-WebRequest returns valid RelationLink property with absolute uris if Link Header is present" {

    They are the only 2 that hang with any kind of consistency.

    On the issue of it failing to start. I saw some weird behavior on mac where the dotnet binary would occasionally use local ports including 8080 when it was building TestExe and WebListener. I have no clue why it is doing that, I assume it has some kind of local language engine it is launching or something. in any case, occasionally when it used port 8080, it was not giving up the local port after it finished compiling. I cannot find any reference to dotnet using port 8080, so this is a bit of a mystery to me. It doesn't use 8080 every time and I don't see the same behavior on linux or windows. The failed start issue might easily be averted by using port 8078 instead of 8080.

  15. SteveL-MSFT commented on Nov 22, 2017

    @SteveL-MSFT
    MemberAuthor

    Mark Kraus (@markekraus) for now, I would be fine if you wanted to convert those tests to use the weblistener, but leave the httplistener code so we can investigate root cause later

  16. markekraus commented on Nov 24, 2017

    @markekraus
    Contributor

    #5540 for replacing response tests, since these are the ones I see hanging in macOS the most. I also updated your initial comment to track the progress of replacing the the tests. When HttpListener is no longer starting in the tests, we can consider this issue closed.

  17. TravisEz13 commented on Dec 6, 2017

    @TravisEz13
    Member

    #5540 is merged to RC.2

  18. modified the milestones: 6.0.0-GA, on Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedWG-Quality-Test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions