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

WebSocketProtocolTests causing failures in NETFX Outerloop #24967

Closed
rmkerr opened this issue Feb 8, 2018 · 7 comments
Closed

WebSocketProtocolTests causing failures in NETFX Outerloop #24967

rmkerr opened this issue Feb 8, 2018 · 7 comments
Assignees
Labels
area-System.Net test-bug Problem in test source code (most likely)
Milestone

Comments

@rmkerr
Copy link
Contributor

rmkerr commented Feb 8, 2018

NETFX Outerloop test runs have been failing for a few weeks now with the following error:

16:24:49 Build FAILED.
16:24:49 
16:24:49 D:\j\workspace\windows-TGrou---bb3e71cd\Tools\tests.targets(492,5): warning :    System.Net.WebSockets.WebSocketProtocol.Tests  Total: 7, Errors: 0, Failed: 2, Skipped: 0, Time: 1.331s [D:\j\workspace\windows-TGrou---bb3e71cd\src\System.Net.WebSockets.WebSocketProtocol\tests\System.Net.WebSockets.WebSocketProtocol.Tests.csproj]
16:24:49 D:\j\workspace\windows-TGrou---bb3e71cd\Tools\tests.targets(492,5): warning MSB3073: The command "D:\j\workspace\windows-TGrou---bb3e71cd\bin/tests/System.Net.WebSockets.WebSocketProtocol.Tests/netfx-Windows_NT-Release-x86//RunTests.cmd D:\j\workspace\windows-TGrou---bb3e71cd\bin/testhost/netfx-Windows_NT-Release-x86/" exited with code 1. [D:\j\workspace\windows-TGrou---bb3e71cd\src\System.Net.WebSockets.WebSocketProtocol\tests\System.Net.WebSockets.WebSocketProtocol.Tests.csproj]
16:24:49 D:\j\workspace\windows-TGrou---bb3e71cd\Tools\tests.targets(500,5): error : One or more tests failed while running tests from 'System.Net.WebSockets.WebSocketProtocol.Tests' please check D:\j\workspace\windows-TGrou---bb3e71cd\bin/tests/System.Net.WebSockets.WebSocketProtocol.Tests/netfx-Windows_NT-Release-x86/testResults.xml for details! [D:\j\workspace\windows-TGrou---bb3e71cd\src\System.Net.WebSockets.WebSocketProtocol\tests\System.Net.WebSockets.WebSocketProtocol.Tests.csproj]
16:24:49 D:\j\workspace\windows-TGrou---bb3e71cd\dir.traversal.targets(77,5): error : (No message specified) [D:\j\workspace\windows-TGrou---bb3e71cd\src\tests.builds]

There have been ~200 runs that have failed at the same point. As far as I can tell the issue first occurred on January 18th. Based on that date and an offline discussion with the team I think the issue was probably introduced by PR dotnet/corefx#26429.

You can find a few instances of failed runs here: 1, 2, 3

cc: @Priya91

@davidsh
Copy link
Contributor

davidsh commented Feb 8, 2018

We should fix/disable the tests to reduce noise.

@stephentoub
Copy link
Member

stephentoub commented Feb 8, 2018

@rmkerr, can you share a link to failure details?

@rmkerr
Copy link
Contributor Author

rmkerr commented Feb 8, 2018

I added a few links to failed runs in the description. The start date and number of occurrences came from Kusto. If you'd like I can save that info to an excel file and share it as well.

@stephentoub
Copy link
Member

@rmkerr, thanks. Are there any successful runs of the test on netfx?

@stephentoub
Copy link
Member

@Priya91, were you successful with this test on netfx? I don't think it can work as written, as the desktop HttpClient will return a read-only stream, which is why the assert is failing. Here's a stripped-down version of the test highlighting the issue:

using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        Uri uri = new Uri("http://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx");
        HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
        KeyValuePair<string, string> secKeyAndSecWebSocketAccept = CreateSecKeyAndSecWebSocketAccept();
        AddWebSocketHeaders(request, secKeyAndSecWebSocketAccept.Key);
        var handler = new HttpClient();
        using (HttpResponseMessage response = await handler.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, CancellationToken.None).ConfigureAwait(false))
        {
            Console.WriteLine(response.StatusCode);
            using (Stream connectedStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
            {
                Console.WriteLine(connectedStream.GetType());
                Console.WriteLine(connectedStream.CanRead);
                Console.WriteLine(connectedStream.CanWrite);
            }
        }
    }

    private static KeyValuePair<string, string> CreateSecKeyAndSecWebSocketAccept()
    {
        string secKey = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
        using (SHA1 sha = SHA1.Create())
        {
            return new KeyValuePair<string, string>(
                secKey,
                Convert.ToBase64String(sha.ComputeHash(Encoding.ASCII.GetBytes(secKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))));
        }
    }

    private static void AddWebSocketHeaders(HttpRequestMessage request, string secKey)
    {
        request.Headers.TryAddWithoutValidation("Connection", "Upgrade");
        request.Headers.TryAddWithoutValidation("Upgrade", "websocket");
        request.Headers.TryAddWithoutValidation("Sec-WebSocket-Version", "13");
        request.Headers.TryAddWithoutValidation("Sec-WebSocket-Key", secKey);
    }
}

and it outputs:

SwitchingProtocols
System.Net.Http.StreamContent+ReadOnlyStream
True
False

The test should be changed to just use a socket directly on the client side, so that it's not reliant on HttpClient behaviors.

@stephentoub
Copy link
Member

I'll fix it... I need to anyway for dotnet/corefx#26964 to pass on netfx.

@rmkerr
Copy link
Contributor Author

rmkerr commented Feb 8, 2018

As far as I can tell the test that has issues is WebSocketProtocol_CreateFromConnectedStream_Succeeds, though that whole test class was added at the same time and might have issues. It looks like it was added in that PR on the 18th, and has never passed on NETFX.

@stephentoub stephentoub self-assigned this Feb 8, 2018
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net test-bug Problem in test source code (most likely)
Projects
None yet
Development

No branches or pull requests

4 participants