diff --git a/eng/ci/integration-tests.yml b/eng/ci/integration-tests.yml index 14784e09d1..f185cd8bcd 100644 --- a/eng/ci/integration-tests.yml +++ b/eng/ci/integration-tests.yml @@ -32,6 +32,10 @@ extends: image: 1es-windows-2022 os: windows + sdl: + suppression: + suppressionFile: $(Build.SourcesDirectory)/eng/sdl/.gdnsuppress + stages: - stage: Test jobs: diff --git a/eng/ci/official-build.yml b/eng/ci/official-build.yml index 861f6796f0..5d30161ffb 100644 --- a/eng/ci/official-build.yml +++ b/eng/ci/official-build.yml @@ -66,10 +66,13 @@ extends: name: 1es-pool-azfunc image: 1es-windows-2022 os: windows + sdl: codeql: # Move codeql for source languages to source analysis stage runSourceLanguagesInSourceAnalysis: true + suppression: + suppressionFile: $(Build.SourcesDirectory)/eng/sdl/.gdnsuppress spotBugs: enabled: false # Explicitly disabling as our JavaWorker package causes this to light up and subsequently fail. diff --git a/eng/ci/templates/jobs/run-unit-tests.yml b/eng/ci/templates/jobs/run-unit-tests.yml index 97ed382438..b1c07b8eb3 100644 --- a/eng/ci/templates/jobs/run-unit-tests.yml +++ b/eng/ci/templates/jobs/run-unit-tests.yml @@ -2,6 +2,12 @@ jobs: - job: RunUnitTests displayName: Run Unit Tests + variables: + - name: test_projects + value: | + **/ExtensionsMetadataGeneratorTests.csproj + **/WebJobs.Script.Tests.csproj + templateContext: outputParentDirectory: $(Build.ArtifactStagingDirectory) outputs: @@ -15,15 +21,28 @@ jobs: steps: - template: /eng/ci/templates/install-dotnet.yml@self + - task: DotNetCoreCLI@2 + displayName: Restore + inputs: + command: custom + custom: restore + arguments: -v m + projects: $(test_projects) + + - task: DotNetCoreCLI@2 + displayName: Build + inputs: + command: build + arguments: -v m -c release --no-restore + projects: $(test_projects) + - task: DotNetCoreCLI@2 displayName: Unit Tests inputs: command: test testRunTitle: Unit Tests - arguments: -v n - projects: | - **\ExtensionsMetadataGeneratorTests.csproj - **\WebJobs.Script.Tests.csproj + arguments: -v m -c release --no-build + projects: $(test_projects) - task: CopyFiles@2 displayName: Copy deps.json diff --git a/eng/ci/templates/official/jobs/run-integration-tests.yml b/eng/ci/templates/official/jobs/run-integration-tests.yml index 48230a0daf..d11a37abd3 100644 --- a/eng/ci/templates/official/jobs/run-integration-tests.yml +++ b/eng/ci/templates/official/jobs/run-integration-tests.yml @@ -8,8 +8,9 @@ jobs: os: windows variables: - IntegrationProject: test/WebJobs.Script.Tests.Integration/WebJobs.Script.Tests.Integration.csproj - IsReleaseBranch: $[contains(variables['Build.SourceBranch'], 'release/')] + test_projects: test/WebJobs.Script.Tests.Integration/WebJobs.Script.Tests.Integration.csproj + is_release: $[contains(variables['Build.SourceBranch'], 'release/')] + test_args: -c release --no-build steps: - template: /eng/ci/templates/install-dotnet.yml@self @@ -45,12 +46,6 @@ jobs: command: ci workingDir: sample/CustomHandlerRetry - - task: DotNetCoreCLI@2 - displayName: Build Integration.csproj - inputs: - command: build - projects: $(IntegrationProject) - - task: AzurePowerShell@5 displayName: Checkout secrets inputs: @@ -74,6 +69,7 @@ jobs: Write-Host "##vso[task.setvariable variable=ConnectionStrings__CosmosDB]$env:CosmosDbSecretMap" Write-Host "##vso[task.setvariable variable=AzureWebJobsEventHubSender]$env:AzureWebJobsEventHubSenderSecretMap" Write-Host "##vso[task.setvariable variable=AzureWebJobsEventHubReceiver]$env:AzureWebJobsEventHubReceiverSecretMap" + Write-Host "##vso[task.setvariable variable=AzureWebJobsEventHubPath]testhub" env: AzureWebJobsStorageSecretMap: $(Storage) AzureWebJobsSecondaryStorageSecretMap: $(SecondaryStorage) @@ -81,13 +77,28 @@ jobs: AzureWebJobsEventHubSenderSecretMap: $(EventHub) AzureWebJobsEventHubReceiverSecretMap: $(EventHub) + - task: DotNetCoreCLI@2 + displayName: Restore + inputs: + command: custom + custom: restore + arguments: -v m + projects: $(test_projects) + + - task: DotNetCoreCLI@2 + displayName: Build + inputs: + command: build + arguments: -v m -c release --no-restore + projects: $(test_projects) + - task: DotNetCoreCLI@2 displayName: C# end to end tests inputs: command: test testRunTitle: C# end to end tests - arguments: '--filter "Group=CSharpEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=CSharpEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Node end to end tests @@ -95,8 +106,8 @@ jobs: inputs: command: test testRunTitle: Node end to end tests - arguments: '--filter "Group=NodeEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=NodeEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Direct load end to end tests @@ -104,8 +115,8 @@ jobs: inputs: command: test testRunTitle: Direct load end to end tests - arguments: '--filter "Group=DirectLoadEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=DirectLoadEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: F# end to end tests @@ -113,8 +124,8 @@ jobs: inputs: command: test testRunTitle: F# end to end tests - arguments: '--filter "Group=FSharpEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=FSharpEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Language worker end to end tests @@ -122,8 +133,8 @@ jobs: inputs: command: test testRunTitle: Language worker end to end tests - arguments: '--filter "Group=LanguageWorkerSelectionEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=LanguageWorkerSelectionEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Node script host end to end tests @@ -131,8 +142,8 @@ jobs: inputs: command: test testRunTitle: Node script host end to end tests - arguments: '--filter "Group=NodeScriptHostTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=NodeScriptHostTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Raw assembly end to end tests @@ -140,8 +151,8 @@ jobs: inputs: command: test testRunTitle: Raw assembly end to end tests - arguments: '--filter "Group=RawAssemblyEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=RawAssemblyEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Samples end to end tests @@ -149,8 +160,8 @@ jobs: inputs: command: test testRunTitle: Samples end to end tests - arguments: '--filter "Group=SamplesEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=SamplesEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Drain mode end to end tests @@ -158,8 +169,8 @@ jobs: inputs: command: test testRunTitle: Drain mode end to end tests - arguments: '--filter "Group=DrainModeEndToEndTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=DrainModeEndToEndTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Standby mode end to end tests Windows @@ -167,8 +178,8 @@ jobs: inputs: command: test testRunTitle: Standby mode end to end tests Windows - arguments: '--filter "Group=StandbyModeEndToEndTests_Windows" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=StandbyModeEndToEndTests_Windows" $(test_args)' + projects: $(test_projects) # Disabled to unblock in 202401. Will fix shortly. # - task: DotNetCoreCLI@2 @@ -177,8 +188,8 @@ jobs: # inputs: # command: test # testRunTitle: Standby mode end to end tests Linux - # arguments: '--filter "Group=StandbyModeEndToEndTests_Linux" --no-build' - # projects: $(IntegrationProject) + # arguments: '--filter "Group=StandbyModeEndToEndTests_Linux" $(test_args)' + # projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Linux container end to end tests Windows @@ -186,17 +197,17 @@ jobs: inputs: command: test testRunTitle: Linux container end to end tests Windows - arguments: '--filter "Group=ContainerInstanceTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=ContainerInstanceTests" $(test_args)' + projects: $(test_projects) - task: DotNetCoreCLI@2 displayName: Release verification tests - condition: ${{ eq(variables.IsReleaseBranch, true) }} + condition: ${{ eq(variables.is_release, true) }} inputs: command: test testRunTitle: Release verification tests - arguments: '--filter "Group=ReleaseTests" --no-build' - projects: $(IntegrationProject) + arguments: '--filter "Group=ReleaseTests" $(test_args)' + projects: $(test_projects) - task: AzurePowerShell@5 condition: always() diff --git a/eng/ci/templates/official/jobs/run-non-e2e-tests.yml b/eng/ci/templates/official/jobs/run-non-e2e-tests.yml index a283cea3b3..21bdb5e387 100644 --- a/eng/ci/templates/official/jobs/run-non-e2e-tests.yml +++ b/eng/ci/templates/official/jobs/run-non-e2e-tests.yml @@ -4,11 +4,11 @@ jobs: pool: name: 1es-pool-azfunc - image: 1es-windows-2022 + image: 1es-windows-2022 os: windows variables: - IntegrationProject: test/WebJobs.Script.Tests.Integration/WebJobs.Script.Tests.Integration.csproj + test_projects: test/WebJobs.Script.Tests.Integration/WebJobs.Script.Tests.Integration.csproj steps: - template: /eng/ci/templates/install-dotnet.yml@self @@ -33,12 +33,6 @@ jobs: targetType: inline script: 'Install-Module -Name Az.Storage -RequiredVersion 1.11.0 -Scope CurrentUser -Force -AllowClobber' - - task: DotNetCoreCLI@2 - displayName: Build Integration.csproj - inputs: - command: build - projects: $(IntegrationProject) - - task: AzurePowerShell@5 displayName: Checkout secrets inputs: @@ -72,13 +66,28 @@ jobs: az login --service-principal -u $(ARM_CLIENT_ID) --tenant $(ARM_TENANT_ID) --allow-no-subscriptions --federated-token $(ARM_ID_TOKEN) displayName: 'Login to Azure' + - task: DotNetCoreCLI@2 + displayName: Restore + inputs: + command: custom + custom: restore + arguments: -v m + projects: $(test_projects) + + - task: DotNetCoreCLI@2 + displayName: Build + inputs: + command: build + arguments: -v m -c release --no-restore + projects: $(test_projects) + - task: DotNetCoreCLI@2 displayName: Non-E2E integration tests inputs: command: test testRunTitle: Non-E2E integration tests - arguments: '--filter "Category!=E2E"' - projects: $(IntegrationProject) + arguments: '--filter "Category!=E2E" -c release --no-build' + projects: $(test_projects) env: AzureWebJobsStorage: $(Storage) AzureWebJobsSecondaryStorage: $(SecondaryStorage) @@ -89,6 +98,7 @@ jobs: AzureWebJobsSecretStorageKeyVaultTenantId: $(AzureTenantId) AzureWebJobsSecretStorageKeyVaultClientId: $(AzureClientId) AzureWebJobsSecretStorageKeyVaultClientSecret: $(AzureClientSecret) + AzureWebJobsEventHubPath: testhub - task: AzurePowerShell@5 condition: always() diff --git a/eng/sdl/.gdnsuppress b/eng/sdl/.gdnsuppress new file mode 100644 index 0000000000..6b6e57ec06 --- /dev/null +++ b/eng/sdl/.gdnsuppress @@ -0,0 +1,65 @@ +{ + "hydrated": false, + "version": "1.0.0", + "suppressionSets": { + "default": { + "name": "default", + "createdDate": "2024-07-01 19:36:04Z", + "lastUpdatedDate": "2024-07-01 19:36:04Z" + } + }, + "results": { + "f1e5ee29e845d190153e848d09bb89833962f9c6f66780d1e78538457442729e": { + "signature": "f1e5ee29e845d190153e848d09bb89833962f9c6f66780d1e78538457442729e", + "alternativeSignatures": [ + "77837171ff1c48bab672e310c4c9a32ccb21e692ca895b2ca6e1bcde7a1abd9a" + ], + "target": "out/bin/WebJobs.Script/release/workers/dotnet-isolated/bin/FunctionsNetHost.exe", + "memberOf": [ + "default" + ], + "tool": "binskim", + "ruleId": "BA2008", + "createdDate": "2024-07-01 19:36:04Z" + }, + "073837647d84d1a96c3bf6e4030c6be939b84ea13fa989374285acb5c9a3239c": { + "signature": "073837647d84d1a96c3bf6e4030c6be939b84ea13fa989374285acb5c9a3239c", + "alternativeSignatures": [ + "b5d61f7c79519a106dead18e5db7686344b80a9d0f16f6e22be8880ebc17a89a" + ], + "target": "out/bin/WebJobs.Script.Grpc/release/workers/dotnet-isolated/bin/FunctionsNetHost.exe", + "memberOf": [ + "default" + ], + "tool": "binskim", + "ruleId": "BA2008", + "createdDate": "2024-07-01 19:36:04Z" + }, + "c82e50a25e624db5140ff636d33bbbc6396bc41724f35e1e2e2a3a4c3be7b6d8": { + "signature": "c82e50a25e624db5140ff636d33bbbc6396bc41724f35e1e2e2a3a4c3be7b6d8", + "alternativeSignatures": [ + "53a01cb91737f8b90c6e0cc3377dac6116da5c8243873a7c9cdec73856689114" + ], + "target": "out/bin/WebJobs.Script.Tests.Integration/release/workers/dotnet-isolated/bin/FunctionsNetHost.exe", + "memberOf": [ + "default" + ], + "tool": "binskim", + "ruleId": "BA2008", + "createdDate": "2024-07-01 19:36:04Z" + }, + "b368ec157fee48c5a06dcf06d7e810d9dfd7d57f0ba1aa28154e5819c6720640": { + "signature": "b368ec157fee48c5a06dcf06d7e810d9dfd7d57f0ba1aa28154e5819c6720640", + "alternativeSignatures": [ + "f05bf31dfdfbf61385a64b1d1f6a0afb79da831809ac23dda0985922185bcd6a" + ], + "target": "out/bin/WebJobs.Script.WebHost/release/workers/dotnet-isolated/bin/FunctionsNetHost.exe", + "memberOf": [ + "default" + ], + "tool": "binskim", + "ruleId": "BA2008", + "createdDate": "2024-07-01 19:36:04Z" + } + } +} \ No newline at end of file diff --git a/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/CSharpPrecompiledTestFixture.cs b/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/CSharpPrecompiledTestFixture.cs index 8965f7e3be..cc1324c9e7 100644 --- a/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/CSharpPrecompiledTestFixture.cs +++ b/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/CSharpPrecompiledTestFixture.cs @@ -6,11 +6,12 @@ namespace Microsoft.Azure.WebJobs.Script.Tests.Integration.WebHostEndToEnd { public class CSharpPrecompiledEndToEndTestFixture : EndToEndTestFixture { - private const string TestPathTemplate = "..\\..\\{0}\\debug"; + private const string TestPathTemplate = "..\\..\\{0}\\{1}"; + private readonly IDisposable _dispose; public CSharpPrecompiledEndToEndTestFixture(string testProjectName, IDictionary envVars = null, string functionWorkerRuntime = "dotnet") - : base(string.Format(TestPathTemplate, testProjectName), testProjectName, functionWorkerRuntime) + : base(string.Format(TestPathTemplate, testProjectName, TestHelpers.BuildConfig), testProjectName, functionWorkerRuntime) { if (envVars != null) { diff --git a/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/HostProcessLauncher.cs b/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/HostProcessLauncher.cs index eac97adc50..9d59c2c345 100644 --- a/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/HostProcessLauncher.cs +++ b/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/HostProcessLauncher.cs @@ -40,7 +40,7 @@ public HostProcessLauncher( bool usePublishPath = false) { string template = usePublishPath ? PublishPathTemplate : BuildPathTemplate; - _testPath = Path.GetFullPath(string.Format(template, testProjectName, "debug")); + _testPath = Path.GetFullPath(string.Format(template, testProjectName, TestHelpers.BuildConfig)); _envVars = envVars ?? new Dictionary(); } diff --git a/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SpecializationE2ETests.cs b/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SpecializationE2ETests.cs index 29ba671cab..309f324409 100644 --- a/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SpecializationE2ETests.cs +++ b/test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SpecializationE2ETests.cs @@ -51,8 +51,8 @@ public class SpecializationE2ETests private static readonly string _standbyPath = Path.Combine(Path.GetTempPath(), "functions", "standby", "wwwroot"); private static readonly string _scriptRootConfigPath = ConfigurationPath.Combine(ConfigurationSectionNames.WebHost, nameof(ScriptApplicationHostOptions.ScriptPath)); - private static readonly string _dotnetIsolated60Path = Path.GetFullPath(@"..\..\DotNetIsolated60\debug"); - private static readonly string _dotnetIsolatedUnsuppportedPath = Path.GetFullPath(@"..\..\DotNetIsolatedUnsupportedWorker\debug"); + private static readonly string _dotnetIsolated60Path = Path.GetFullPath($@"..\..\DotNetIsolated60\{TestHelpers.BuildConfig}"); + private static readonly string _dotnetIsolatedUnsuppportedPath = Path.GetFullPath($@"..\..\DotNetIsolatedUnsupportedWorker\{TestHelpers.BuildConfig}"); private static readonly string _dotnetIsolatedEmptyScriptRoot = Path.GetFullPath(@"..\..\..\..\EmptyScriptRoot"); private static Action _customizeScriptHostServices; diff --git a/test/WebJobs.Script.Tests.Shared/TestHelpers.cs b/test/WebJobs.Script.Tests.Shared/TestHelpers.cs index ca98a157e7..87d43113e6 100644 --- a/test/WebJobs.Script.Tests.Shared/TestHelpers.cs +++ b/test/WebJobs.Script.Tests.Shared/TestHelpers.cs @@ -32,6 +32,12 @@ namespace Microsoft.Azure.WebJobs.Script.Tests { public static partial class TestHelpers { +#if DEBUG + public const string BuildConfig = "debug"; +#else + public const string BuildConfig = "release"; +#endif + private const string Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; private static readonly Random Random = new Random(); diff --git a/test/WebJobs.Script.Tests/FunctionsSyncServiceTests.cs b/test/WebJobs.Script.Tests/FunctionsSyncServiceTests.cs index 7265fef6ca..baaa9dd9ec 100644 --- a/test/WebJobs.Script.Tests/FunctionsSyncServiceTests.cs +++ b/test/WebJobs.Script.Tests/FunctionsSyncServiceTests.cs @@ -105,8 +105,8 @@ public async Task StartAsync_PrimaryHost_Running_SyncsTriggers_AfterTimeout() [Fact] public async Task StartAsync_TokenCancelledBeforeTimeout_DoesNotSyncTriggers() { - var cts = new CancellationTokenSource(); - cts.CancelAfter(_testDueTime / 2); + using CancellationTokenSource cts = new(); + cts.Cancel(); await _syncService.StartAsync(cts.Token); await Task.Delay(2 * _testDueTime);