Skip to content

Commit

Permalink
Enable JitTrace test in release branch (Azure#7508)
Browse files Browse the repository at this point in the history
  • Loading branch information
pragnagopa authored Jun 28, 2021
1 parent b5e2177 commit a64449b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 20 deletions.
12 changes: 11 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
variables:
buildNumber: $[ counter('constant', 13000) ] # Start higher than our AppVeyor versions. Every build (pr or branch) will increment.
buildNumber: $[ counter('constant', 13000) ]
isReleaseBranch: $[contains(variables['Build.SourceBranch'], 'release/')]

pr:
branches:
Expand Down Expand Up @@ -520,6 +521,15 @@ jobs:
arguments: '--filter "Group=ContainerInstanceTests" --no-build'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: DotNetCoreCLI@2
displayName: "Release verification tests"
condition: eq(variables['isReleaseBranch'], 'True')
inputs:
command: 'test'
testRunTitle: "Release verification tests"
arguments: '--filter "Group=ReleaseTests" --no-build'
projects: |
**\WebJobs.Script.Tests.Integration.csproj
- task: PowerShell@2
condition: always()
displayName: 'Checkin secrets'
Expand Down
37 changes: 37 additions & 0 deletions test/WebJobs.Script.Tests.Integration/PreJIT/JitPreparesTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.IO;
using Microsoft.Azure.WebJobs.Script.WebHost;
using Microsoft.Azure.WebJobs.Script.WebHost.Middleware;
using Microsoft.Diagnostics.JitTrace;
using Microsoft.WebJobs.Script.Tests;
using Xunit;

namespace Microsoft.Azure.WebJobs.Script.Tests.PreJIT
{
[Trait(TestTraits.Category, TestTraits.EndToEnd)]
[Trait(TestTraits.Group, TestTraits.ReleaseTests)]
public class JitPreparesTest
{
[Theory]
[InlineData(WarmUpConstants.JitTraceFileName)]
[InlineData(WarmUpConstants.LinuxJitTraceFileName)]
public void ColdStart_JitFailuresTest(string fileName)
{
var path = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HostWarmupMiddleware).Assembly.CodeBase).LocalPath), WarmUpConstants.PreJitFolderName, fileName);

var file = new FileInfo(path);

Assert.True(file.Exists, $"Expected PGO file '{file.FullName}' does not exist. The file was either renamed or deleted.");

JitTraceRuntime.Prepare(file, out int successfulPrepares, out int failedPrepares);

var failurePercentage = (double)failedPrepares / successfulPrepares * 100;

// using 1% as approximate number of allowed failures before we need to regenrate a new PGO file.
Assert.True(failurePercentage < 1.0, $"Number of failed PGOs are more than 1 percent! Current number of failures are {failedPrepares}. This will definitely impact cold start! Time to regenrate PGOs and update the {fileName} file!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,25 +443,6 @@ public async Task Specialization_CustomStartupAddsWebJobsStorage()
}
}

[Theory(Skip = "Will be enforced as part of release build")]
[InlineData(WarmUpConstants.JitTraceFileName)]
[InlineData(WarmUpConstants.LinuxJitTraceFileName)]
public void ColdStart_JitFailuresTest(string fileName)
{
var path = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HostWarmupMiddleware).Assembly.CodeBase).LocalPath), WarmUpConstants.PreJitFolderName, fileName);

var file = new FileInfo(path);

Assert.True(file.Exists, $"Expected PGO file '{file.FullName}' does not exist. The file was either renamed or deleted.");

JitTraceRuntime.Prepare(file, out int successfulPrepares, out int failedPrepares);

var failurePercentage = (double) failedPrepares / successfulPrepares * 100;

// using 1% as approximate number of allowed failures before we need to regenrate a new PGO file.
Assert.True( failurePercentage < 1.0 , $"Number of failed PGOs are more than 1 percent! Current number of failures are {failedPrepares}. This will definitely impact cold start! Time to regenrate PGOs and update the {fileName} file!");
}

private IWebHostBuilder CreateStandbyHostBuilder(params string[] functions)
{
string scriptRootConfigPath = ConfigurationPath.Combine(ConfigurationSectionNames.WebHost, nameof(ScriptApplicationHostOptions.ScriptPath));
Expand Down
5 changes: 5 additions & 0 deletions test/WebJobs.Script.Tests.Shared/TestTraits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static class TestTraits

public const string EndToEnd = "E2E";

/// <summary>
/// Release Tests only run in branches: release/*
/// </summary>
public const string ReleaseTests = "ReleaseTests";

public const string SamplesEndToEnd = "SamplesEndToEndTests";

/// <summary>
Expand Down

0 comments on commit a64449b

Please sign in to comment.