Run stress tests on private Asp.Net Core package (#33860)
authorAlexander Nikolaev <55398552+alnikola@users.noreply.github.com>
Tue, 24 Mar 2020 16:35:00 +0000 (17:35 +0100)
committerGitHub <noreply@github.com>
Tue, 24 Mar 2020 16:35:00 +0000 (17:35 +0100)
Currently, it's possible to run stress tests on privately built CoreCLR and libraries by executing load-corefx-testhost.ps1 -b followed by run-docker-compose.ps1 -b. However, it was not possible to run the stress server on a private Asp.Net Core package which is used for private libraries build.

This PR adds a new -pa parameter to run-docker-compose.ps1 which builds a server container with a private Asp.Net Core package version.

eng/docker/build-docker-sdk.ps1
eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile [new file with mode: 0644]
eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile [new file with mode: 0644]
src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.ps1
src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.ps1

index 76c1ce7..a7c3094 100755 (executable)
@@ -6,7 +6,8 @@
 Param(
   [string][Alias('t')]$imageName = "dotnet-sdk-libs-current",
   [string][Alias('c')]$configuration = "Release",
-  [switch][Alias('w')]$buildWindowsContainers
+  [switch][Alias('w')]$buildWindowsContainers,
+  [switch][Alias('pa')]$privateAspNetCore
 )
 
 $ErrorActionPreference = "Stop"
@@ -22,17 +23,38 @@ if ($buildWindowsContainers)
   & "$REPO_ROOT_DIR/libraries.cmd" -ci -c $configuration -runtimeConfiguration release
   
   # Dockerize the build artifacts
-  docker build --tag $imageName `
+  if($privateAspNetCore)
+  {
+    docker build --tag $imageName `
+      --build-arg CONFIGURATION=$configuration `
+      --build-arg TESTHOST_LOCATION=. `
+      --file "$PSScriptRoot/libraries-sdk-aspnetcore.windows.Dockerfile" `
+      "$REPO_ROOT_DIR/artifacts/bin/testhost"
+  }
+  else
+  {
+    docker build --tag $imageName `
       --build-arg CONFIGURATION=$configuration `
       --build-arg TESTHOST_LOCATION=. `
       --file "$PSScriptRoot/libraries-sdk.windows.Dockerfile" `
       "$REPO_ROOT_DIR/artifacts/bin/testhost"
+  }
 }
 else 
 {
   # Docker build libraries and copy to dotnet sdk image
+  if($privateAspNetCore)
+  {
+    docker build --tag $imageName `
+      --build-arg CONFIGURATION=$configuration `
+      --file "$PSScriptRoot/libraries-sdk-aspnetcore.linux.Dockerfile" `
+      $REPO_ROOT_DIR
+  }
+  else
+  {
   docker build --tag $imageName `
       --build-arg CONFIGURATION=$configuration `
       --file "$PSScriptRoot/libraries-sdk.linux.Dockerfile" `
       $REPO_ROOT_DIR
+  }
 }
diff --git a/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile b/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile
new file mode 100644 (file)
index 0000000..f352d29
--- /dev/null
@@ -0,0 +1,36 @@
+# Builds and copies library artifacts into target dotnet sdk image
+ARG BUILD_BASE_IMAGE=mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-f39df28-20191023143754
+ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/core/sdk:3.0.100-buster
+
+FROM $BUILD_BASE_IMAGE as corefxbuild
+
+WORKDIR /repo
+COPY . .
+
+ARG CONFIGURATION=Release
+RUN ./src/coreclr/build.sh -release -skiptests -clang9 && \
+    ./libraries.sh -c $CONFIGURATION -runtimeconfiguration release
+
+FROM $SDK_BASE_IMAGE as target
+
+ARG TESTHOST_LOCATION=/repo/artifacts/bin/testhost
+ARG TFM=netcoreapp5.0
+ARG OS=Linux
+ARG ARCH=x64
+ARG CONFIGURATION=Release
+
+ARG COREFX_SHARED_FRAMEWORK_NAME=Microsoft.NETCore.App
+ARG ASPNETCORE_SHARED_NAME=Microsoft.AspNetCore.App
+ARG SOURCE_COREFX_VERSION=5.0.0
+ARG TARGET_SHARED_FRAMEWORK=/usr/share/dotnet/shared
+ARG TARGET_COREFX_VERSION=3.0.0
+
+COPY --from=corefxbuild \
+    $TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/* \
+    $TARGET_SHARED_FRAMEWORK/$COREFX_SHARED_FRAMEWORK_NAME/$TARGET_COREFX_VERSION/
+COPY --from=corefxbuild \
+    $TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/* \
+    $TARGET_SHARED_FRAMEWORK/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/
+COPY --from=corefxbuild \
+    $TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$ASPNETCORE_SHARED_NAME/$SOURCE_COREFX_VERSION/* \
+    $TARGET_SHARED_FRAMEWORK/$ASPNETCORE_SHARED_NAME/$TARGET_COREFX_VERSION/
\ No newline at end of file
diff --git a/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile b/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile
new file mode 100644 (file)
index 0000000..59aa7f0
--- /dev/null
@@ -0,0 +1,26 @@
+# escape=`
+# Simple Dockerfile which copies library build artifacts into target dotnet sdk image
+ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/core/sdk:3.0.100-nanoserver-1809
+FROM $SDK_BASE_IMAGE as target
+
+ARG TESTHOST_LOCATION=".\\artifacts\\bin\\testhost"
+ARG TFM=netcoreapp5.0
+ARG OS=Windows_NT
+ARG ARCH=x64
+ARG CONFIGURATION=Release
+
+ARG COREFX_SHARED_FRAMEWORK_NAME=Microsoft.NETCore.App
+ARG ASPNETCORE_SHARED_NAME=Microsoft.AspNetCore.App
+ARG SOURCE_COREFX_VERSION=5.0.0
+ARG TARGET_SHARED_FRAMEWORK="C:\\Program Files\\dotnet\\shared"
+ARG TARGET_COREFX_VERSION=3.0.0
+
+COPY `
+    $TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\ `
+    $TARGET_SHARED_FRAMEWORK\$COREFX_SHARED_FRAMEWORK_NAME\$TARGET_COREFX_VERSION\
+COPY `
+    $TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\ `
+    $TARGET_SHARED_FRAMEWORK\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\
+COPY `
+    $TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$ASPNETCORE_SHARED_NAME\$SOURCE_COREFX_VERSION\ `
+    $TARGET_SHARED_FRAMEWORK\$ASPNETCORE_SHARED_NAME\$TARGET_COREFX_VERSION\
index 60dfaa6..216eb9f 100755 (executable)
@@ -6,6 +6,7 @@ Param(
     [string][Alias('c')]$configuration = "Release", # Build configuration for libraries and stress suite
     [switch][Alias('w')]$useWindowsContainers, # Use windows containers, if available
     [switch][Alias('b')]$buildCurrentLibraries, # Drives the stress test using libraries built from current source
+    [switch][Alias('pa')]$privateAspNetCore, # Drive the stress test using a private Asp.Net Core package, requires -b to be set
     [switch][Alias('o')]$buildOnly, # Build, but do not run the stress app
     [string][Alias('t')]$sdkImageName, # Name of the sdk image name, if built from source.
     [string]$clientStressArgs = "",
@@ -19,16 +20,30 @@ $COMPOSE_FILE = "$PSScriptRoot/docker-compose.yml"
 
 if ($buildCurrentLibraries)
 {
+    if ([string]::IsNullOrEmpty($sdkImageName))
+    {
+        $sdkImageName = "dotnet-sdk-libs-current"
+    }
+
     $LIBRARIES_BUILD_ARGS = " -t $sdkImageName -c $configuration"
     if($useWindowsContainers)
     {
         $LIBRARIES_BUILD_ARGS += " -w"
     }
+    if($privateAspNetCore)
+    {
+        $LIBRARIES_BUILD_ARGS += " -p"
+    }
 
     Invoke-Expression "& $REPO_ROOT_DIR/eng/docker/build-docker-sdk.ps1 $LIBRARIES_BUILD_ARGS"
 
     if (!$?) { exit 1 }
 }
+elseif ($privateAspNetCore) {
+    write-output "Using a private Asp.Net Core package (-pa) requires using privately built libraries. Please, enable it with -b switch."
+    write-output "USAGE: . $($MyInvocation.InvocationName) -b -pa <args>"
+    exit 1
+}
 
 # Dockerize the stress app using docker-compose
 
index 81dd794..72e9922 100755 (executable)
@@ -6,6 +6,7 @@ Param(
     [string][Alias('c')]$configuration = "Release", # Build configuration for libraries and stress suite
     [switch][Alias('w')]$useWindowsContainers, # Use windows containers, if available
     [switch][Alias('b')]$buildCurrentLibraries, # Drives the stress test using libraries built from current source
+    [switch][Alias('pa')]$privateAspNetCore, # Drive the stress test using a private Asp.Net Core package, requires -b to be set
     [switch][Alias('o')]$buildOnly, # Build, but do not run the stress app
     [string][Alias('t')]$sdkImageName, # Name of the sdk image name, if built from source.
     [string]$clientStressArgs = "",
@@ -19,16 +20,30 @@ $COMPOSE_FILE = "$PSScriptRoot/docker-compose.yml"
 
 if ($buildCurrentLibraries)
 {
+    if ([string]::IsNullOrEmpty($sdkImageName))
+    {
+        $sdkImageName = "dotnet-sdk-libs-current"
+    }
+
     $LIBRARIES_BUILD_ARGS = " -t $sdkImageName -c $configuration"
     if($useWindowsContainers)
     {
         $LIBRARIES_BUILD_ARGS += " -w"
     }
+    if($privateAspNetCore)
+    {
+        $LIBRARIES_BUILD_ARGS += " -p"
+    }
 
     Invoke-Expression "& $REPO_ROOT_DIR/eng/docker/build-docker-sdk.ps1 $LIBRARIES_BUILD_ARGS"
 
     if (!$?) { exit 1 }
 }
+elseif ($privateAspNetCore) {
+    write-output "Using a private Asp.Net Core package (-pa) requires using privately built libraries. Please, enable it with -b switch."
+    write-output "USAGE: . $($MyInvocation.InvocationName) -b -pa <args>"
+    exit 1
+}
 
 # Dockerize the stress app using docker-compose