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

Initial SslStream stress app work #123

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions eng/pipelines/libraries/stress/http-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ steps:
displayName: Build Corefx

- bash: |
cd '$(HttpStressProject)'
docker build -t $(httpStressImage) --build-arg SDK_BASE_IMAGE=$(sdkBaseImage) --build-arg CONFIGURATION=$(BUILD_CONFIGURATION) .
docker build -t $(httpStressImage) --build-arg SDK_BASE_IMAGE=$(sdkBaseImage) --build-arg CONFIGURATION=$(BUILD_CONFIGURATION) -f src/libraries/System.Net.Http/tests/StressTests/HttpStress/Dockerfile src/libraries
displayName: Build HttpStress

- bash: |
Expand Down
43 changes: 43 additions & 0 deletions eng/pipelines/libraries/stress/ssl-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
trigger: none

schedules:
- cron: "0 13 * * *" # 1PM UTC => 5 AM PST
displayName: HttpStress nightly run
branches:
include:
- master

pool:
name: Hosted Ubuntu 1604

variables:
- template: ../variables.yml
- name: httpStressProject
value: $(sourcesRoot)/System.Net.Http/tests/StressTests/HttpStress/
- name: sslStressProject
value: $(sourcesRoot)/System.Net.Security/tests/StressTests/SslStress/
- name: sdkBaseImage
value: sdk-corefx-current
- name: sslStressImage
value: sslstress

steps:
- checkout: self
clean: true
fetchDepth: 0
lfs: false

- bash: |
docker build -t $(sdkBaseImage) --build-arg CONFIGURATION=$(BUILD_CONFIGURATION) --build-arg BUILD_SCRIPT_NAME=$(buildScriptFileName) -f $(HttpStressProject)corefx.Dockerfile .
displayName: Build Corefx

- bash: |
docker build -t $(sslStressImage) --build-arg SDK_BASE_IMAGE=$(sdkBaseImage) --build-arg CONFIGURATION=$(BUILD_CONFIGURATION) -f $(sslStressProject)/Dockerfile src/libraries
displayName: Build HttpStress

- bash: |
cd '$(HttpStressProject)'
docker-compose up --abort-on-container-exit --no-color
displayName: Run HttpStress
env:
HTTPSTRESS_IMAGE: $(httpStressImage)
45 changes: 45 additions & 0 deletions eng/pipelines/libraries/stress/ssl-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
trigger: none

schedules:
- cron: "0 13 * * *" # 1PM UTC => 5 AM PST
displayName: SslStress nightly run
branches:
include:
- master

pool:
name: Hosted VS2017

variables:
- template: ../variables.yml
- name: httpStressProject
value: $(sourcesRoot)/System.Net.Http/tests/StressTests/HttpStress/
- name: sslStressProject
value: $(sourcesRoot)/System.Net.Security/tests/StressTests/SslStress/

steps:
- checkout: self
clean: true
fetchDepth: 0
lfs: false

- powershell: |
.\$(buildScriptFileName).cmd -ci -c $(BUILD_CONFIGURATION)
displayName: Build Corefx

- powershell: |
# Load testhost sdk in environment
. '$(httpStressProject)\load-corefx-testhost.ps1' -c $(BUILD_CONFIGURATION) -b
# Run the stress suite
cd '$(sslStressProject)'
dotnet run -c $(BUILD_CONFIGURATION) -- $(SSLSTRESS_ARGS)
displayName: Run HttpStress

- task: PublishBuildArtifacts@1
displayName: Publish Logs
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(BUILD_CONFIGURATION)'
PublishLocation: Container
ArtifactName: 'httpstress_$(Agent.Os)_$(Agent.JobName)'
continueOnError: true
condition: always()
14 changes: 6 additions & 8 deletions src/libraries/Common/tests/System/IO/Compression/CRC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

public class CRC
{
// Table of CRCs of all 8-bit messages.
Expand Down Expand Up @@ -32,27 +34,23 @@ private static void make_crc_table()
s_crc_table_computed = true;
}

// Update a running CRC with the bytes buf[0..len-1]--the CRC
// Update a running CRC with the bytes --the CRC
// should be initialized to all 1's, and the transmitted value
// is the 1's complement of the final running CRC (see the
// crc() routine below)).
private static ulong update_crc(ulong crc, byte[] buf, int len)
public static ulong UpdateCRC(ulong crc, ReadOnlySpan<byte> buf)
{
ulong c = crc;
int n;

if (!s_crc_table_computed)
make_crc_table();
for (n = 0; n < len; n++)
for (n = 0; n < buf.Length; n++)
{
c = s_crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
}
return c;
}

internal static string CalculateCRC(byte[] buf) => CalculateCRC(buf, buf.Length);

// Return the CRC of the bytes buf[0..len-1].
internal static string CalculateCRC(byte[] buf, int len) =>
(update_crc(0xffffffffL, buf, len) ^ 0xffffffffL).ToString();
public static ulong CalculateCRC(ReadOnlySpan<byte> buf) => (UpdateCRC(0xffffffffL, buf) ^ 0xffffffffL);
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static void IsZipSameAsDir(Stream archiveFile, string directory, ZipArchi
entrystream.Read(buffer, 0, buffer.Length);
#if NETCOREAPP
uint zipcrc = entry.Crc32;
Assert.Equal(CRC.CalculateCRC(buffer), zipcrc.ToString());
Assert.Equal(CRC.CalculateCRC(buffer), zipcrc);
#endif

if (file.Length != givenLength)
Expand All @@ -183,8 +183,8 @@ public static void IsZipSameAsDir(Stream archiveFile, string directory, ZipArchi
}

Assert.Equal(file.Length, buffer.Length);
string crc = CRC.CalculateCRC(buffer);
Assert.Equal(file.CRC, crc);
ulong crc = CRC.CalculateCRC(buffer);
Assert.Equal(file.CRC, crc.ToString());
}

if (checkTimes)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Text;

namespace HttpStress
{
public static class CRCHelpers
{
public const ulong InitialCrc = 0xffffffffL;

public static ulong UpdateCrC(ulong crc, string text, Encoding? encoding = null)
{
encoding = encoding ?? Encoding.ASCII;
byte[] bytes = encoding.GetBytes(text);
return CRC.UpdateCRC(crc, bytes);
}

public static ulong CalculateCRC(string text, Encoding? encoding = null) => UpdateCrC(InitialCrc, text, encoding) ^ InitialCrc;

public static ulong CalculateHeaderCrc<T>(IEnumerable<(string name, T)> headers, Encoding? encoding = null) where T : IEnumerable<string>
{
ulong checksum = InitialCrc;

foreach ((string name, IEnumerable<string> values) in headers)
{
checksum = UpdateCrC(checksum, name);
foreach (string value in values)
{
checksum = UpdateCrC(checksum, value);
}
}

return checksum ^ InitialCrc;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static (string name, Func<RequestContext, Task> operation)[] Operations =
{
using var req = new HttpRequestMessage(HttpMethod.Get, "/headers");
ctx.PopulateWithRandomHeaders(req.Headers);
ulong expectedChecksum = CRC.CalculateHeaderCrc(req.Headers.Select(x => (x.Key, x.Value)));
ulong expectedChecksum = CRCHelpers.CalculateHeaderCrc(req.Headers.Select(x => (x.Key, x.Value)));

using HttpResponseMessage res = await ctx.SendAsync(req);

Expand Down Expand Up @@ -323,7 +323,7 @@ public static (string name, Func<RequestContext, Task> operation)[] Operations =
async ctx =>
{
string content = ctx.GetRandomString(0, ctx.MaxContentLength);
ulong checksum = CRC.CalculateCRC(content);
ulong checksum = CRCHelpers.CalculateCRC(content);

using var req = new HttpRequestMessage(HttpMethod.Post, "/") { Content = new StringDuplexContent(content) };
using HttpResponseMessage m = await ctx.SendAsync(req);
Expand All @@ -337,7 +337,7 @@ public static (string name, Func<RequestContext, Task> operation)[] Operations =
async ctx =>
{
(string expected, MultipartContent formDataContent) formData = GetMultipartContent(ctx, ctx.MaxRequestParameters);
ulong checksum = CRC.CalculateCRC(formData.expected);
ulong checksum = CRCHelpers.CalculateCRC(formData.expected);

using var req = new HttpRequestMessage(HttpMethod.Post, "/") { Content = formData.formDataContent };
using HttpResponseMessage m = await ctx.SendAsync(req);
Expand All @@ -351,7 +351,7 @@ public static (string name, Func<RequestContext, Task> operation)[] Operations =
async ctx =>
{
string content = ctx.GetRandomString(0, ctx.MaxContentLength);
ulong checksum = CRC.CalculateCRC(content);
ulong checksum = CRCHelpers.CalculateCRC(content);

using var req = new HttpRequestMessage(HttpMethod.Post, "/duplex") { Content = new StringDuplexContent(content) };
using HttpResponseMessage m = await ctx.SendAsync(req, HttpCompletionOption.ResponseHeadersRead);
Expand Down Expand Up @@ -405,7 +405,7 @@ public static (string name, Func<RequestContext, Task> operation)[] Operations =
async ctx =>
{
string content = ctx.GetRandomString(0, ctx.MaxContentLength);
ulong checksum = CRC.CalculateCRC(content);
ulong checksum = CRCHelpers.CalculateCRC(content);

using var req = new HttpRequestMessage(HttpMethod.Post, "/") { Content = new StringContent(content) };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM $SDK_BASE_IMAGE

WORKDIR /app
COPY . .
WORKDIR /app/System.Net.Http/tests/StressTests/HttpStress

ARG CONFIGURATION=Release
RUN dotnet build -c $CONFIGURATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\..\..\Common\tests\System\IO\Compression\CRC.cs" Link="CRC.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine.Experimental" Version="0.3.0-alpha.19317.1" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="4.5.4" />
Expand Down
Loading