Brennan пре 6 година
родитељ
комит
e3a5f03e24

+ 1 - 1
.azure/pipelines/jobs/default-build.yml

@@ -233,7 +233,7 @@ jobs:
         condition: always()
         inputs:
           testRunner: junit
-          testResultsFiles: '**/TEST-com.microsoft.signalr*.xml'
+          testResultsFiles: '**/TEST-junit-jupiter.xml'
           buildConfiguration: $(BuildConfiguration)
           buildPlatform: $(AgentOsName)
           mergeTestResults: true

+ 5 - 0
.gitattributes

@@ -8,6 +8,11 @@
 ###############################################################################
 *.sh eol=lf
 
+###############################################################################
+# Make gradlew always have LF as line endings
+###############################################################################
+gradlew eol=lf
+
 ###############################################################################
 # Set default behavior for command prompt diff.
 #

+ 1 - 0
Directory.Build.props

@@ -187,5 +187,6 @@
   <Import Project="eng\targets\CSharp.Common.props"  Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
   <Import Project="eng\targets\Wix.Common.props"  Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
   <Import Project="eng\targets\Npm.Common.props"  Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
+  <Import Project="eng\targets\Helix.props" Condition="'$(IsTestProject)' == 'true'" />
 
 </Project>

+ 1 - 0
Directory.Build.targets

@@ -163,5 +163,6 @@
   <Import Project="eng\targets\Wix.Common.targets"  Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
   <Import Project="eng\targets\Npm.Common.targets"  Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
   <Import Project="eng\targets\ReferenceAssembly.targets" Condition=" '$(HasReferenceAssembly)' == 'true' " />
+  <Import Project="eng\targets\Helix.targets" Condition="'$(IsTestProject)' == 'true'" />
 
 </Project>

+ 62 - 0
eng/helix/content/InstallJdk.ps1

@@ -0,0 +1,62 @@
+<#
+.SYNOPSIS
+    Installs JDK into a folder in this repo.
+.DESCRIPTION
+    This script downloads an extracts the JDK.
+.PARAMETER JdkVersion
+    The version of the JDK to install. If not set, the default value is read from global.json
+.PARAMETER Force
+    Overwrite the existing installation
+#>
+param(
+    [string]$JdkVersion,
+    [Parameter(Mandatory = $false)]
+    $InstallDir
+)
+$ErrorActionPreference = 'Stop'
+$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
+
+Set-StrictMode -Version 1
+
+if ($InstallDir) {
+    $installDir = $InstallDir;
+}
+else {
+    $repoRoot = Resolve-Path "$PSScriptRoot\..\.."
+    $installDir = "$repoRoot\.tools\jdk\win-x64\"
+}
+$tempDir = "$installDir\obj"
+if (-not $JdkVersion) {
+    $globalJson = Get-Content "$repoRoot\global.json" | ConvertFrom-Json
+    $JdkVersion = $globalJson.tools.jdk
+}
+
+if (Test-Path $installDir) {
+    if ($Force) {
+        Remove-Item -Force -Recurse $installDir
+    }
+    else {
+        Write-Host "The JDK already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite."
+        exit 0
+    }
+}
+
+Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
+mkdir $tempDir -ea Ignore | out-null
+mkdir $installDir -ea Ignore | out-null
+Write-Host "Starting download of JDK ${JdkVersion}"
+Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -OutFile "$tempDir/jdk.zip"
+Write-Host "Done downloading JDK ${JdkVersion}"
+
+Add-Type -assembly "System.IO.Compression.FileSystem"
+[System.IO.Compression.ZipFile]::ExtractToDirectory("$tempDir/jdk.zip", "$tempDir/jdk/")
+
+Write-Host "Expanded JDK to $tempDir"
+Write-Host "Installing JDK to $installDir"
+Move-Item "$tempDir/jdk/jdk-${JdkVersion}/*" $installDir
+Write-Host "Done installing JDK to $installDir"
+Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
+
+if ($env:TF_BUILD) {
+    Write-Host "##vso[task.prependpath]$installDir\bin"
+}

+ 46 - 0
eng/helix/content/installjdk.sh

@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+# Cause the script to fail if any subcommand fails
+set -e
+
+pushd .
+
+if [ "$JAVA_HOME" != "" ]; then
+    echo "JAVA_HOME is set"
+    exit
+fi
+
+java_version=$1
+arch=$2
+osname=`uname -s`
+if [ "$osname" = "Darwin" ]; then
+   echo "macOS not supported, relying on the machine providing java itself"
+   exit 1
+else
+   platformarch="linux-$arch"
+fi
+echo "PlatformArch: $platformarch"
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+output_dir="$DIR/java"
+url="https://netcorenativeassets.blob.core.windows.net/resource-packages/external/linux/java/jdk-${java_version}_${platformarch}_bin.tar.gz"
+echo "Downloading from: $url"
+tmp="$(mktemp -d -t install-jdk.XXXXXX)"
+
+cleanup() {
+    exitcode=$?
+    if [ $exitcode -ne 0 ]; then
+      echo "Failed to install java with exit code: $exitcode"
+    fi
+    rm -rf "$tmp"
+    exit $exitcode
+}
+
+trap "cleanup" EXIT
+cd "$tmp"
+curl -Lsfo $(basename $url) "$url"
+echo "Installing java from $(basename $url) $url"
+mkdir $output_dir
+echo "Unpacking to $output_dir"
+tar --strip-components 1 -xzf "jdk-${java_version}_${platformarch}_bin.tar.gz" --no-same-owner --directory "$output_dir"
+
+popd

+ 11 - 1
eng/helix/content/installnode.sh

@@ -22,7 +22,17 @@ output_dir="$DIR/node"
 url="http://nodejs.org/dist/v$node_version/node-v$node_version-$platformarch.tar.gz"
 echo "Downloading from: $url"
 tmp="$(mktemp -d -t install-node.XXXXXX)"
-trap "rm -rf $tmp" EXIT
+
+cleanup() {
+    exitcode=$?
+    if [ $exitcode -ne 0 ]; then
+      echo "Failed to install node with exit code: $exitcode"
+    fi
+    rm -rf "$tmp"
+    exit $exitcode
+}
+
+trap "cleanup" EXIT
 cd "$tmp"
 curl -Lsfo $(basename $url) "$url"
 echo "Installing node from $(basename $url) $url"

+ 0 - 1
eng/targets/CSharp.Common.props

@@ -35,6 +35,5 @@
   </ItemDefinitionGroup>
 
   <Import Project="CSharp.ReferenceAssembly.props" Condition="'$(IsReferenceAssemblyProject)' == 'true'" />
-  <Import Project="Helix.props" Condition="'$(IsTestProject)' == 'true'" />
 
 </Project>

+ 1 - 1
eng/targets/CSharp.Common.targets

@@ -30,5 +30,5 @@
 
   <Import Project="Packaging.targets" />
   <Import Project="ResolveReferences.targets" />
-  <Import Project="Helix.targets" Condition="'$(IsTestProject)' == 'true'" />
+
 </Project>

+ 2 - 12
eng/targets/Helix.props

@@ -15,6 +15,8 @@
     <RunQuarantinedTests>false</RunQuarantinedTests>
     <IsWindowsHelixQueue>false</IsWindowsHelixQueue>
     <IsWindowsHelixQueue Condition="$(HelixTargetQueue.Contains('Windows')) or $(HelixTargetQueue.Contains('windows'))">true</IsWindowsHelixQueue>
+    <IsMacHelixQueue>false</IsMacHelixQueue>
+    <IsMacHelixQueue Condition="$(HelixTargetQueue.Contains('OSX')) or $(HelixTargetQueue.Contains('macOs'))">true</IsMacHelixQueue>
     <HelixTestName>$(MSBuildProjectName)--$(TargetFramework)</HelixTestName>
     <HelixUseArchive>false</HelixUseArchive>
     <LoggingTestingDisableFileLogging Condition="'$(IsHelixJob)' == 'true'">false</LoggingTestingDisableFileLogging>
@@ -33,16 +35,4 @@
     <HelixContent Include="$(RepoRoot)eng\helix\content\**\*" />
   </ItemGroup>
 
-  <ItemGroup Condition="'$(TestDependsOnMssql)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
-    <HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
-  </ItemGroup>
-
-  <ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false'">
-    <HelixPreCommand Include="./installnode.sh $(NodeVersion) $(TargetArchitecture)" />
-  </ItemGroup>
-
-  <ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
-    <HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
-  </ItemGroup>
-
 </Project>

+ 19 - 1
eng/targets/Helix.targets

@@ -1,10 +1,26 @@
 <Project>
+  <ItemGroup Condition="'$(TestDependsOnJava)' == 'true'">
+    <HelixPreCommand Condition="'$(IsWindowsHelixQueue)' == 'true'" Include="call RunPowershell.cmd InstallJdk.ps1 11.0.3 %25HELIX_CORRELATION_PAYLOAD%25\jdk &amp;&amp; set %22JAVA_HOME=%25HELIX_CORRELATION_PAYLOAD%25\jdk%22" />
+    <HelixPreCommand Condition="'$(IsWindowsHelixQueue)' != 'true' AND '$(IsMacHelixQueue)' != 'true'" Include="./installjdk.sh 10.0.2 x64 &amp;&amp; if [ &quot;%24JAVA_HOME&quot; = &quot;&quot; ]%3B then export JAVA_HOME=%24PWD/java%3B fi" />
+  </ItemGroup>
+
+  <ItemGroup Condition="'$(TestDependsOnMssql)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
+    <HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
+  </ItemGroup>
+
+  <ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false'">
+    <HelixPreCommand Include="./installnode.sh $(NodeVersion) $(TargetArchitecture)" />
+  </ItemGroup>
+
+  <ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
+    <HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
+  </ItemGroup>
 
   <!-- Item group has to be defined here becasue Helix.props is evaluated before xunit.runner.console.props  -->
   <ItemGroup Condition="$(BuildHelixPayload)">
     <Content Include="@(HelixContent)" />
   </ItemGroup>
-  
+
 <!--
 
 This target is meant to be used when invoking helix tests on one project at a time.
@@ -77,6 +93,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
       <_HelixFriendlyNameTargetQueue Condition="$(HelixTargetQueue.Contains('@'))">$(HelixTargetQueue.Substring(1, $([MSBuild]::Subtract($(HelixTargetQueue.LastIndexOf(')')), 1))))</_HelixFriendlyNameTargetQueue>
     </PropertyGroup>
 
+    <!-- Important: If HelixTargetQueue is not removed here, then Publish will occur for every single queue type. And since Publish shouldn't depend on the queue we can just publish once -->
     <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_PublishHelixArchive" RemoveProperties="HelixTargetQueue;TestRunId" />
 
     <ConvertToAbsolutePath Paths="$(PublishDir)">
@@ -91,6 +108,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
         <PostCommands>@(HelixPostCommand)</PostCommands>
         <Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(TargetFrameworkIdentifier) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
         <Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
+        <Command Condition="$(HelixCommand) != ''">$(HelixCommand)</Command>
         <Timeout>$(HelixTimeout)</Timeout>
       </HelixWorkItem>
     </ItemGroup>

+ 1 - 1
eng/targets/Npm.Common.targets

@@ -119,7 +119,7 @@
     <Move SourceFiles="$(_BackupPackageJson)" DestinationFiles="$(PackageJson)" />
   </Target>
 
-  <Target Name="Test" Condition="'$(IsTestProject)' == 'true'">
+  <Target Name="Test" Condition="'$(IsTestProject)' == 'true' AND '$(SkipTests)' != 'true'">
     <Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
     <Message Importance="High" Text="Running npm tests for $(MSBuildProjectName)" />
     <Yarn Command="$(NpmTestArgs)" StandardOutputImportance="High" StandardErrorImportance="High" />

+ 3 - 0
src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj

@@ -1,4 +1,7 @@
 <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <BuildHelixPayload>false</BuildHelixPayload>
+  </PropertyGroup>
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
       <Configuration>Debug</Configuration>

+ 1 - 0
src/SignalR/clients/java/signalr/.gitignore

@@ -2,6 +2,7 @@
 .gradletasknamecache
 .gradle/
 build/
+/test-results
 .settings/
 out/
 *.class

+ 4 - 2
src/SignalR/clients/java/signalr/build.gradle

@@ -6,6 +6,7 @@ buildscript {
   }
   dependencies {
     classpath "com.diffplug.spotless:spotless-plugin-gradle:3.14.0"
+    classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
   }
 }
 
@@ -16,6 +17,7 @@ plugins {
 
 apply plugin: "java-library"
 apply plugin: "com.diffplug.gradle.spotless"
+apply plugin: 'org.junit.platform.gradle.plugin'
 
 group 'com.microsoft.signalr'
 
@@ -64,8 +66,8 @@ spotless {
     }
 }
 
-test {
-    useJUnitPlatform()
+junitPlatform {
+    reportsDir file('test-results')
 }
 
 task sourceJar(type: Jar) {

+ 28 - 3
src/SignalR/clients/java/signalr/signalr.client.java.javaproj → src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj

@@ -1,5 +1,5 @@
-<Project DefaultTargets="Build">
-  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
+<Project>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
 
   <PropertyGroup>
 
@@ -15,6 +15,9 @@
 
     <!-- Disable gradle daemon on CI since the CI seems to try to wait for the daemon to shut down, which it doesn't do :) -->
     <GradleOptions Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(GradleOptions) -Dorg.gradle.daemon=false</GradleOptions>
+    <PublishDir>$(OutputPath)</PublishDir>
+    <TestDependsOnJava>true</TestDependsOnJava>
+
   </PropertyGroup>
 
   <ItemGroup>
@@ -51,15 +54,37 @@
     <Exec Command="./gradlew $(GradleOptions) compileJava" />
   </Target>
 
-  <Target Name="Test">
+  <Target Name="Test" Condition="'$(SkipTests)' != 'true'">
     <Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
     <Message Text="Running Java client tests" Importance="high" />
     <Message Text="> gradlew $(GradleOptions) test" Importance="high" />
     <Exec Command="./gradlew $(GradleOptions) test" IgnoreStandardErrorWarningFormat="true" />
   </Target>
 
+  <Target Name="Publish">
+    <ItemGroup>
+      <Files Include="**/*.java" />
+      <Files Include="**/gradle-wrapper.jar" />
+      <Files Include="**/gradle-wrapper.properties" />
+      <Files Include="gradlew" />
+      <Files Include="build.gradle" />
+      <Files Include="gradlew.bat" />
+      <Files Include="settings.gradle" />
+      <Files Include="@(Content)" />
+    </ItemGroup>
+    <Copy DestinationFiles="@(Files->'$(PublishDir)\%(RecursiveDir)%(FileName)%(Extension)')" SourceFiles="@(Files)" />
+  </Target>
+
   <PropertyGroup>
     <!-- Pass the Java Package Version down to Gradle -->
     <GradleOptions Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(GradleOptions) -PpackageVersion="$(PackageVersion)"</GradleOptions>
+    <HelixCommand>chmod +x ./gradlew &amp;&amp; ./gradlew $(GradleOptions) test</HelixCommand>
+    <HelixCommand Condition="'$(IsWindowsHelixQueue)' == 'true'">call gradlew $(GradleOptions) test</HelixCommand>
   </PropertyGroup>
+
+  <ItemGroup>
+    <HelixPostCommand Condition="'$(IsWindowsHelixQueue)' != 'true'" Include="cp %24{HELIX_WORKITEM_ROOT}/test-results/TEST-junit-jupiter.xml %24{HELIX_WORKITEM_ROOT}/junit-results.xml" />
+    <HelixPostCommand Condition="'$(IsWindowsHelixQueue)' == 'true'" Include="copy %25HELIX_WORKITEM_ROOT%25\test-results\TEST-junit-jupiter.xml %25HELIX_WORKITEM_ROOT%25\junit-results.xml" />
+  </ItemGroup>
+
 </Project>

+ 2 - 1
src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj

@@ -9,6 +9,7 @@
     <_TestSauceArgs Condition="'$(BrowserTestHostName)' != ''">$(_TestSauceArgs) --use-hostname "$(BrowserTestHostName)"</_TestSauceArgs>
     <NpmTestArgs Condition="'$(DailyTests)' != 'true'">run test:inner --no-color --configuration $(Configuration)</NpmTestArgs>
     <NpmBuildArgs>run build:inner</NpmBuildArgs>
+    <BuildHelixPayload>false</BuildHelixPayload>
   </PropertyGroup>
 
   <ItemGroup>
@@ -18,7 +19,7 @@
 
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
 
-  <Target Name="Test" Condition="'$(IsTestProject)' == 'true'">
+  <Target Name="Test" Condition="'$(IsTestProject)' == 'true' AND '$(SkipTests)' != 'true'">
     <Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
     <Message Importance="High" Text="Running tests for $(MSBuildProjectName)" />
     <Yarn Condition="'$(DailyTests)' != 'true'" Command="$(NpmTestArgs)" />