-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break L1s into multiple classes (#2822)
* Break L1s into multiple classes * pr fixes * oops * Enable readonly variable test * Attempt to fix stuck functional tests * test * test * test * Read task zip directly from externals * test * test * test * Don't run in parallel * New L1 changes * save * L1 copyright Co-authored-by: Tommy Petty <[email protected]> Co-authored-by: Danny McCormick <[email protected]>
- Loading branch information
1 parent
045f329
commit 011380e
Showing
19 changed files
with
763 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.TeamFoundation.DistributedTask.Pipelines; | ||
using Microsoft.TeamFoundation.DistributedTask.WebApi; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.VisualStudio.Services.Agent.Tests.L1.Worker | ||
{ | ||
[Collection("Worker L1 Tests")] | ||
public class CheckoutL1Tests : L1TestBase | ||
{ | ||
[Fact] | ||
[Trait("Level", "L1")] | ||
[Trait("Category", "Worker")] | ||
public async Task NoCheckout() | ||
{ | ||
try | ||
{ | ||
// Arrange | ||
SetupL1(); | ||
var message = LoadTemplateMessage(); | ||
// Remove checkout | ||
for (var i = message.Steps.Count - 1; i >= 0; i--) | ||
{ | ||
var step = message.Steps[i]; | ||
if (step is TaskStep && ((TaskStep)step).Reference.Name == "Checkout") | ||
{ | ||
message.Steps.RemoveAt(i); | ||
} | ||
} | ||
|
||
// Act | ||
var results = await RunWorker(message); | ||
|
||
// Assert | ||
AssertJobCompleted(); | ||
Assert.Equal(TaskResult.Succeeded, results.Result); | ||
|
||
var steps = GetSteps(); | ||
Assert.Equal(3, steps.Count()); // Init, CmdLine, Finalize | ||
Assert.Equal(0, steps.Where(x => x.Name == "Checkout").Count()); | ||
} | ||
finally | ||
{ | ||
TearDown(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.TeamFoundation.DistributedTask.WebApi; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.VisualStudio.Services.Agent.Tests.L1.Worker | ||
{ | ||
[Collection("Worker L1 Tests")] | ||
public class ConditionsL1Tests : L1TestBase | ||
{ | ||
[Fact] | ||
[Trait("Level", "L1")] | ||
[Trait("Category", "Worker")] | ||
public async Task Conditions_Failed() | ||
{ | ||
try | ||
{ | ||
// Arrange | ||
SetupL1(); | ||
var message = LoadTemplateMessage(); | ||
// Remove all tasks | ||
message.Steps.Clear(); | ||
// Add a normal step and one that only runs on failure | ||
message.Steps.Add(CreateScriptTask("echo This will run")); | ||
var failStep = CreateScriptTask("echo This shouldn't..."); | ||
failStep.Condition = "failed()"; | ||
message.Steps.Add(failStep); | ||
|
||
// Act | ||
var results = await RunWorker(message); | ||
|
||
// Assert | ||
AssertJobCompleted(); | ||
Assert.Equal(TaskResult.Succeeded, results.Result); | ||
|
||
var steps = GetSteps(); | ||
Assert.Equal(4, steps.Count()); // Init, CmdLine, CmdLine, Finalize | ||
var faiLStep = steps[2]; | ||
Assert.Equal(TaskResult.Skipped, faiLStep.Result); | ||
} | ||
finally | ||
{ | ||
TearDown(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.TeamFoundation.DistributedTask.WebApi; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.VisualStudio.Services.Agent.Tests.L1.Worker | ||
{ | ||
[Collection("Worker L1 Tests")] | ||
public class ConfigL1Tests : L1TestBase | ||
{ | ||
[Fact] | ||
[Trait("Level", "L1")] | ||
[Trait("Category", "Worker")] | ||
public async Task TrackingConfigsShouldBeConsistentAcrossRuns() | ||
{ | ||
try | ||
{ | ||
// Arrange | ||
SetupL1(); | ||
FakeConfigurationStore fakeConfigurationStore = GetMockedService<FakeConfigurationStore>(); | ||
var message1 = LoadTemplateMessage(); | ||
// second message is the same definition but a different job with a different repository checked out | ||
var message2 = LoadTemplateMessage(jobId: "642e8db6-0794-4b7b-8fd9-33ee9202a795", jobName: "__default2", jobDisplayName: "Job2", checkoutRepoAlias: "repo2"); | ||
|
||
// Act | ||
var results1 = await RunWorker(message1); | ||
var trackingConfig1 = GetTrackingConfig(message1); | ||
AssertJobCompleted(1); | ||
Assert.Equal(TaskResult.Succeeded, results1.Result); | ||
|
||
// Act2 | ||
var results2 = await RunWorker(message2); | ||
var trackingConfig2 = GetTrackingConfig(message2); | ||
AssertJobCompleted(2); | ||
Assert.Equal(TaskResult.Succeeded, results2.Result); | ||
|
||
// Assert | ||
Assert.Equal(trackingConfig1.BuildDirectory, trackingConfig2.BuildDirectory); | ||
Assert.Equal(trackingConfig1.HashKey, trackingConfig2.HashKey); | ||
} | ||
finally | ||
{ | ||
TearDown(); | ||
} | ||
} | ||
|
||
[Fact] | ||
[Trait("Level", "L1")] | ||
[Trait("Category", "Worker")] | ||
public async Task TrackingConfigsShouldBeConsistentAcrossMulticheckoutRuns() | ||
{ | ||
try | ||
{ | ||
// Arrange | ||
SetupL1(); | ||
FakeConfigurationStore fakeConfigurationStore = GetMockedService<FakeConfigurationStore>(); | ||
var message1 = LoadTemplateMessage(additionalRepos: 2); | ||
message1.Steps.Add(CreateCheckoutTask("Repo2")); | ||
message1.Steps.Add(CreateCheckoutTask("Repo2")); | ||
// second message is the same definition but a different job with a different order of the repos being checked out in a different order | ||
var message2 = LoadTemplateMessage(jobId: "642e8db6-0794-4b7b-8fd9-33ee9202a795", jobName: "__default2", jobDisplayName: "Job2", checkoutRepoAlias: "Repo3", additionalRepos: 2); | ||
message2.Steps.Add(CreateCheckoutTask("Repo2")); | ||
message2.Steps.Add(CreateCheckoutTask("self")); | ||
|
||
// Act | ||
var results1 = await RunWorker(message1); | ||
var trackingConfig1 = GetTrackingConfig(message1); | ||
AssertJobCompleted(1); | ||
Assert.Equal(TaskResult.Succeeded, results1.Result); | ||
|
||
// Act2 | ||
var results2 = await RunWorker(message2); | ||
var trackingConfig2 = GetTrackingConfig(message2); | ||
AssertJobCompleted(2); | ||
Assert.Equal(TaskResult.Succeeded, results2.Result); | ||
|
||
// Assert | ||
Assert.Equal(trackingConfig1.BuildDirectory, trackingConfig2.BuildDirectory); | ||
Assert.Equal(trackingConfig1.HashKey, trackingConfig2.HashKey); | ||
} | ||
finally | ||
{ | ||
TearDown(); | ||
} | ||
} | ||
|
||
[Fact] | ||
[Trait("Level", "L1")] | ||
[Trait("Category", "Worker")] | ||
public async Task TrackingConfigsShouldBeConsistentAcrossRunsWithDifferentCheckouts() | ||
{ | ||
try | ||
{ | ||
// Arrange | ||
SetupL1(); | ||
FakeConfigurationStore fakeConfigurationStore = GetMockedService<FakeConfigurationStore>(); | ||
var message1 = LoadTemplateMessage(additionalRepos: 2); | ||
message1.Variables.Add("agent.useWorkspaceIds", new VariableValue(Boolean.TrueString, false, true)); | ||
|
||
// second message is the same definition but a different job with a different order of the repos being checked out in a different order | ||
var message2 = LoadTemplateMessage(jobId: "642e8db6-0794-4b7b-8fd9-33ee9202a795", jobName: "__default2", jobDisplayName: "Job2", checkoutRepoAlias: "Repo2", additionalRepos: 1); | ||
message2.Variables.Add("agent.useWorkspaceIds", new VariableValue(Boolean.TrueString, false, true)); | ||
|
||
// third message uses the same repos as the first | ||
var message3 = LoadTemplateMessage(additionalRepos: 2); | ||
message3.Variables.Add("agent.useWorkspaceIds", new VariableValue(Boolean.TrueString, false, true)); | ||
|
||
// Act | ||
var results1 = await RunWorker(message1); | ||
var trackingConfig1 = GetTrackingConfig(message1); | ||
AssertJobCompleted(1); | ||
Assert.Equal(TaskResult.Succeeded, results1.Result); | ||
|
||
// Act2 | ||
var results2 = await RunWorker(message2); | ||
var trackingConfig2 = GetTrackingConfig(message2); | ||
AssertJobCompleted(2); | ||
Assert.Equal(TaskResult.Succeeded, results2.Result); | ||
|
||
// Act3 | ||
var results3 = await RunWorker(message3); | ||
var trackingConfig3 = GetTrackingConfig(message3); | ||
AssertJobCompleted(3); | ||
Assert.Equal(TaskResult.Succeeded, results3.Result); | ||
|
||
// Assert - the first and third runs should be consistent | ||
Assert.NotEqual(trackingConfig1.BuildDirectory, trackingConfig2.BuildDirectory); | ||
Assert.Equal(trackingConfig1.BuildDirectory, trackingConfig3.BuildDirectory); | ||
Assert.Equal(trackingConfig1.HashKey, trackingConfig3.HashKey); | ||
} | ||
finally | ||
{ | ||
TearDown(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.