Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use breadcrumbfiles associated with each asset, versus shared #6604

Merged
merged 17 commits into from
Jul 28, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.ComponentModel;
using Azure.Sdk.tools.TestProxy.Common;
using System.Collections.Generic;

namespace Azure.Sdk.Tools.TestProxy.Tests
{
Expand Down Expand Up @@ -584,7 +585,7 @@ public async Task GetPathResolves(string inputJson)

[EnvironmentConditionalSkipFact]
[Trait("Category", "Integration")]
public async Task BreadcrumbContainsMultipleAssetRefs()
public async Task BreadCrumbMaintainsMultipleBreadCrumbs()
{
var inputJson = @"{
""AssetsRepo"": ""Azure/azure-sdk-assets-integration"",
Expand All @@ -611,22 +612,31 @@ public async Task BreadcrumbContainsMultipleAssetRefs()
try
{
var assetStore = (await _defaultStore.ParseConfigurationFile(Path.Join(testFolder, target1))).ResolveAssetsStoreLocation();
var breadCrumbFile = Path.Join(assetStore.ToString(), ".breadcrumb");

var breadCrumbs = new List<string>();

// run 3 restore operations
foreach (var assetsJson in folderStructure)
{
var jsonFileLocation = Path.Join(testFolder, assetsJson);
var parsedJson = await _defaultStore.ParseConfigurationFile(jsonFileLocation);

await _defaultStore.Restore(jsonFileLocation);
var breadCrumbFile = Path.Join(assetStore.ToString(), "breadcrumb", $"{parsedJson.AssetRepoShortHash}.breadcrumb");

breadCrumbs.Add(breadCrumbFile);

await _defaultStore.Restore(jsonFileLocation);
TestHelpers.CheckBreadcrumbAgainstAssetsConfig(parsedJson);
}

var crumbs = File.ReadAllLines(breadCrumbFile).Select(x => new BreadcrumbLine(x));
// double verify they are where we expect
foreach(var crumbFile in breadCrumbs)
{
Assert.True(File.Exists(crumbFile));
}

// we have already validated that each tag contains what we expect, just confirm we aren't eliminating lines now.
Assert.Equal(3, crumbs.Count());
Assert.Equal(3, breadCrumbs.Count());
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public static void CreateFileWithInitialVersion(string testFolder, string fileNa
public static void CheckBreadcrumbAgainstAssetsConfig(GitAssetsConfiguration configuration)
{
var assetsStorePath = configuration.ResolveAssetsStoreLocation();
var breadCrumbFile = Path.Join(assetsStorePath.ToString(), ".breadcrumb");
var breadCrumbFile = Path.Join(assetsStorePath.ToString(), "breadcrumb", $"{configuration.AssetRepoShortHash}.breadcrumb");
var targetKey = configuration.AssetsJsonRelativeLocation.ToString();

Assert.True(File.Exists(breadCrumbFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ public GitStoreBreadcrumb() { }

public string GetBreadCrumbLocation(GitAssetsConfiguration configuration)
{
return Path.Join(configuration.ResolveAssetsStoreLocation().ToString(), ".breadcrumb");
var breadCrumbFolder = Path.Combine(configuration.ResolveAssetsStoreLocation().ToString(), "breadcrumb");

if (!Directory.Exists(breadCrumbFolder))
{
Directory.CreateDirectory(breadCrumbFolder);
}

return Path.Join(breadCrumbFolder, $"{configuration.AssetRepoShortHash}.breadcrumb");
}

/// <summary>
Expand Down