diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs index 2a0f211808b991..fab17ecdc9966f 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs @@ -42,7 +42,8 @@ public RequestContext(Configuration config, HttpClient httpClient, Random random public int TaskNum { get; } public bool IsCancellationRequested { get; private set; } - public Version HttpVersion => _config.HttpVersion; + public Version HttpVersion => _client.DefaultRequestVersion; + public HttpVersionPolicy HttpVersionPolicy => _client.DefaultVersionPolicy; public int MaxRequestParameters => _config.MaxParameters; public int MaxRequestUriSize => _config.MaxRequestUriSize; public int MaxRequestHeaderCount => _config.MaxRequestHeaderCount; @@ -54,6 +55,7 @@ public RequestContext(Configuration config, HttpClient httpClient, Random random public async Task SendAsync(HttpRequestMessage request, HttpCompletionOption httpCompletion = HttpCompletionOption.ResponseContentRead, CancellationToken? token = null) { request.Version = HttpVersion; + request.VersionPolicy = HttpVersionPolicy; if (token != null) { diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Dockerfile b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Dockerfile index 00b1dd4e35e7e1..0c1b6031ec628b 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Dockerfile +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Dockerfile @@ -1,12 +1,30 @@ -ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:5.0-buster-slim +# use nightly build of 6.0 from main (Debian) +ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:latest FROM $SDK_BASE_IMAGE RUN echo "DOTNET_SDK_VERSION="$DOTNET_SDK_VERSION RUN echo "DOTNET_VERSION="$DOTNET_VERSION +# install dependencies of libmsquic.so +RUN apt-get update -y \ + && apt-get install -y \ + liblttng-ust0 \ + libatomic1 \ + libc6 \ + && apt-get clean + WORKDIR /app COPY . . +# pre-built msquic should be inside stress tests directory so we can copy it to container here +COPY libmsquic.so /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/ +COPY libmsquic.lttng.so /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/ + +# no need to rebuild whole clr+libs with "-b" argument, we can substitute specific dlls only +# for that, pre-build locally for net6.0-Linux-Release, put inside stress tests directory and uncomment copy below +# COPY System.Net.Quic.dll /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/ +# COPY System.Net.Http.dll /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/ + ARG CONFIGURATION=Release RUN dotnet build -c $CONFIGURATION diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj index 57cbb0859dc804..53fe07184ca09c 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 preview enable @@ -13,6 +13,8 @@ + + - \ No newline at end of file + diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs index 17db81103603dd..fe0a13360fd410 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs @@ -65,8 +65,8 @@ HttpMessageHandler CreateHttpHandler() } } - return new HttpClient(CreateHttpHandler()) - { + return new HttpClient(CreateHttpHandler()) + { BaseAddress = _baseAddress, Timeout = _config.DefaultTimeout, DefaultRequestVersion = _config.HttpVersion, @@ -283,7 +283,7 @@ public void RecordCancellation(int operationIndex, TimeSpan elapsed) public void RecordFailure(Exception exn, int operationIndex, TimeSpan elapsed, bool isCancelled, int taskNum, long iteration) { DateTime timestamp = DateTime.Now; - + Interlocked.Increment(ref _totalRequests); Interlocked.Increment(ref _failures[operationIndex]); diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressServer.cs b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressServer.cs index 6012965d2a5097..203b5fc2d9b28d 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressServer.cs +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressServer.cs @@ -108,6 +108,10 @@ void ConfigureListenOptions(ListenOptions listenOptions) } listenOptions.UseHttps(cert); } + if (configuration.HttpVersion == new Version(3,0)) + { + listenOptions.Protocols = HttpProtocols.Http3; + } } else { @@ -118,6 +122,15 @@ void ConfigureListenOptions(ListenOptions listenOptions) } } }); + + if (configuration.HttpVersion == new Version(3,0)) + { + host = host.UseQuic(options => + { + options.Alpn = "h3-29"; + options.IdleTimeout = TimeSpan.FromHours(1); + }); + } }; LoggerConfiguration loggerConfiguration = new LoggerConfiguration();