Skip to content

Commit

Permalink
modify parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Abhishek committed Aug 17, 2023
1 parent c6ec2be commit b65c31a
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public FileUploadDescriptor CreateDescriptor(VirtualClientComponent component, I
return null;
}

public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentStorePathTemplate, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentPathPattern, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
{
throw new NotImplementedException();
}
Expand All @@ -172,7 +172,7 @@ public FileUploadDescriptor CreateDescriptor(VirtualClientComponent component, I
return null;
}

public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentStorePathTemplate, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentPathPattern, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptor_When_Not_Tim
null,
expectedRole);

string contentStorePathTemplate = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
FileUploadDescriptor descriptor = this.descriptorFactory.CreateDescriptor(context, contentStorePathTemplate, timestamped: false);
string contentPathPattern = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
FileUploadDescriptor descriptor = this.descriptorFactory.CreateDescriptor(context, contentPathPattern, timestamped: false);

Assert.AreEqual(expectedExperimentId.ToLowerInvariant(), descriptor.ContainerName);
Assert.AreEqual(expectedFileName, descriptor.BlobName);
Expand Down Expand Up @@ -115,8 +115,8 @@ public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptor_When_Timesta
null,
expectedRole);

string contentStorePathTemplate = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
FileUploadDescriptor descriptor = this.descriptorFactory.CreateDescriptor(context, contentStorePathTemplate, timestamped: true);
string contentPathPattern = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
FileUploadDescriptor descriptor = this.descriptorFactory.CreateDescriptor(context, contentPathPattern, timestamped: true);

Assert.AreEqual(expectedExperimentId.ToLowerInvariant(), descriptor.ContainerName);
Assert.AreEqual(expectedFileName, descriptor.BlobName);
Expand All @@ -132,7 +132,7 @@ public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptor_When_Timesta
[TestCase("customContainer/{parameter1}/{experimentId}/{agentId}/{parameter2}/fixedFolder/{toolName}/{role}/{scenario}", "value1", null)]
[TestCase("customContainer/{parameter1}/{experimentId}/{agentId}/{parameter2}/fixedFolder/{toolName}/{role}/{scenario}", "valueA", "valueB")]
[TestCase("customContainer/{parameter1},stringValue1/{experimentId}/{agentId}/{parameter2}/fixedFolder,stringValue2/{toolName}/{role}/{scenario}", "valueA", "valueB")]
public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptorWithCustomTemplate(string contentStorePathTemplate, string parameter1, string parameter2)
public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptorWithCustomTemplate(string contentPathPattern, string parameter1, string parameter2)
{
this.SetupDefaults();

Expand All @@ -150,7 +150,7 @@ public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptorWithCustomTem
string expectedFileName = $"{this.mockFile.Object.CreationTimeUtc.ToString("yyyy-MM-ddTHH-mm-ss-fffffZ")}-{this.mockFile.Object.Name}";

string expectedBlobPath;
if (contentStorePathTemplate.Contains(","))
if (contentPathPattern.Contains(","))
{
expectedBlobPath = string.Join('/', (new string[] { $"{parameter1},stringValue1", expectedExperimentId, "AgentIdA", parameter2, "fixedFolder,stringValue2", "ToolA", "RoleA", "ScenarioA" })
.Where(i => i != null))
Expand Down Expand Up @@ -183,7 +183,7 @@ public void FileUploadDescriptorFactoryCreatesTheExpectedDescriptorWithCustomTem
null,
"RoleA");

FileUploadDescriptor descriptor = this.descriptorFactory.CreateDescriptor(context, contentStorePathTemplate, parameters: parameters, timestamped: true);
FileUploadDescriptor descriptor = this.descriptorFactory.CreateDescriptor(context, contentPathPattern, parameters: parameters, timestamped: true);

Assert.AreEqual("customContainer", descriptor.ContainerName);
Assert.AreEqual(expectedFileName, descriptor.BlobName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public class FileUploadDescriptorFactory : IFileUploadDescriptorFactory
/// </para>
/// </summary>
/// <param name="fileContext">Provides context about a file to be uploaded.</param>
/// <param name="contentStorePathTemplate">Content path template to use when uploading content to target storage resources.</param>
/// <param name="contentPathPattern">Content path template to use when uploading content to target storage resources.</param>
/// <param name="parameters">Parameters related to the component that produced the file (e.g. the parameters from the component).</param>
/// <param name="manifest">Additional information and metadata related to the blob/file to include in the descriptor alongside the default manifest information.</param>
/// <param name="timestamped">
/// True to to include the file creation time in the file name (e.g. 2023-05-21t09-23-30-23813z-file.log). This is explicit to allow for cases where modification of the
/// file name is not desirable. Default = true (timestamped file names).
/// </param>
public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentStorePathTemplate, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentPathPattern, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
{
fileContext.ThrowIfNull(nameof(fileContext));
contentStorePathTemplate.ThrowIfNullOrWhiteSpace(nameof(contentStorePathTemplate));
contentPathPattern.ThrowIfNullOrWhiteSpace(nameof(contentPathPattern));

string blobName = Path.GetFileName(fileContext.File.Name);

Expand All @@ -66,13 +66,13 @@ public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string con
blobName = FileUploadDescriptor.GetFileName(blobName, fileContext.File.CreationTimeUtc);
}

string blobContainer = GetInlinedContentArgumentValue(fileContext, contentStorePathTemplate.Split('/')[0], parameters);
string blobContainer = GetInlinedContentArgumentValue(fileContext, contentPathPattern.Split('/')[0], parameters);
if (string.IsNullOrWhiteSpace(blobContainer))
{
throw new ArgumentException("The containerName in blob cannot be empty string.", contentStorePathTemplate);
throw new ArgumentException("The containerName in blob cannot be empty string.", contentPathPattern);
}

string blobPath = FileUploadDescriptorFactory.CreateBlobPath(fileContext, contentStorePathTemplate, parameters, blobName);
string blobPath = FileUploadDescriptorFactory.CreateBlobPath(fileContext, contentPathPattern, parameters, blobName);

// Create the default manifest information.
IDictionary<string, IConvertible> fileManifest = FileUploadDescriptor.CreateManifest(fileContext, blobContainer, blobPath, parameters, manifest);
Expand All @@ -88,13 +88,13 @@ public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string con
return descriptor;
}

private static string CreateBlobPath(FileContext fileContext, string contentStorePathTemplate, IDictionary<string, IConvertible> parameters, string blobName)
private static string CreateBlobPath(FileContext fileContext, string contentPathPattern, IDictionary<string, IConvertible> parameters, string blobName)
{
string blobPath = null;
List<string> pathSegments = new List<string>();

int i = 0;
foreach (string element in contentStorePathTemplate.Split('/'))
foreach (string element in contentPathPattern.Split('/'))
{
if (i == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public interface IFileUploadDescriptorFactory
/// to upload to a blob store.
/// </summary>
/// <param name="fileContext">Provides context about a file to be uploaded.</param>
/// <param name="contentStorePathTemplate">Content path template to use when uploading content to target storage resources.</param>
/// <param name="contentPathPattern">Content path template to use when uploading content to target storage resources.</param>
/// <param name="parameters">Parameters related to the component that produced the file (e.g. the parameters from the component).</param>
/// <param name="manifest">Additional information and metadata related to the blob/file to include in the descriptor alongside the default manifest information.</param>
/// <param name="timestamped">
/// True to to include the file creation time in the file name (e.g. 2023-05-21t09-23-30-23813z-file.log). This is explicit to allow for cases where modification of the
/// file name is not desirable. Default = true (timestamped file names).
/// </param>
FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentStorePathTemplate, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true);
FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentPathPattern, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public string ContentPathFormat
/// Parameter defines the content path format/structure using a template to use when uploading content
/// to target storage resources. When not defined the 'Default' structure is used.
/// </summary>
public static string ContentStorePathTemplate { get; set; }
public static string ContentPathPattern { get; set; }

/// <summary>
/// The CPU/processor architecture (e.g. amd64, arm).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static FileUploadDescriptor CreateFileUploadDescriptor(this VirtualClient
IFileUploadDescriptorFactory factory = ComponentTypeCache.Instance.GetFileUploadDescriptorFactory(identifier);
FileUploadDescriptor descriptor = factory.CreateDescriptor(
fileContext,
VirtualClientComponent.ContentStorePathTemplate,
VirtualClientComponent.ContentPathPattern,
parameters,
appendedMetaData,
timestamped);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void ExecuteCommandAsyncExtensionDoesNotSupportAUsernameSuppliedUnlessRun
[ComponentDescription(Id = "Format1234")]
private class TestFileUploadDescriptorFactory_A : IFileUploadDescriptorFactory
{
public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentStorePathTemplate, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
public FileUploadDescriptor CreateDescriptor(FileContext fileContext, string contentPathPattern, IDictionary<string, IConvertible> parameters = null, IDictionary<string, IConvertible> manifest = null, bool timestamped = true)
{
return new FileUploadDescriptor(
$"/any/path/to/blob/{fileContext.File.Name}",
Expand Down
2 changes: 1 addition & 1 deletion src/VirtualClient/VirtualClient.Main/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected CommandBase()
/// Parameter defines the content path format/structure using a template to use when uploading content
/// to target storage resources. When not defined the 'Default' structure is used.
/// </summary>
public string ContentStorePathTemplate { get; set; }
public string ContentPathPattern { get; set; }

/// <summary>s
/// True to have debug/verbose output emitted to standard output on
Expand Down
6 changes: 3 additions & 3 deletions src/VirtualClient/VirtualClient.Main/OptionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ public static Option CreateContentStoreOption(bool required = true, object defau
/// </summary>
/// <param name="required">Sets this option as required.</param>
/// <param name="defaultValue">Sets the default value when none is provided.</param>
public static Option CreateContentStorePathTemplateOption(bool required = true, object defaultValue = null)
public static Option CreateContentPathPatternOption(bool required = true, object defaultValue = null)
{
Option<string> option = new Option<string>(new string[] { "--contentStorePathTemplate", "--contentstorepathtemplate", "--contentPath", "--cspt" })
Option<string> option = new Option<string>(new string[] { "--contentPathPattern", "--contentpathpattern", "--contentPath", "--cspt" })
{
Name = "ContentStorePathTemplate",
Name = "ContentPathPattern",
Description = "A template for virtual folder structure to be followed in contentStore.",
ArgumentHelpName = "pathTemplate",
AllowMultipleArgumentsPerToken = false
Expand Down
4 changes: 2 additions & 2 deletions src/VirtualClient/VirtualClient.Main/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ internal static CommandLineBuilder SetupCommandLine(string[] args, CancellationT
// --contentStore
OptionFactory.CreateContentStoreOption(required: false),

// --contentStorePathTemplate
OptionFactory.CreateContentStorePathTemplateOption(required: false, "{experimentId}/{agentId}/{toolName}/{role}/{scenario}"),
// --contentPathPattern
OptionFactory.CreateContentPathPatternOption(required: false, "{experimentId}/{agentId}/{toolName}/{role}/{scenario}"),

// --debug
OptionFactory.CreateDebugFlag(required: false, false),
Expand Down
2 changes: 1 addition & 1 deletion src/VirtualClient/VirtualClient.Main/RunProfileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public override async Task<int> ExecuteAsync(string[] args, CancellationTokenSou
dependencies = this.InitializeDependencies(args);
logger = dependencies.GetService<ILogger>();
packageManager = dependencies.GetService<IPackageManager>();
VirtualClientComponent.ContentStorePathTemplate = this.ContentStorePathTemplate;
VirtualClientComponent.ContentPathPattern = this.ContentPathPattern;

IEnumerable<string> profileNames = this.GetProfilePaths(dependencies);
this.SetGlobalTelemetryProperties(profileNames, dependencies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DependencyFixture : Fixture
static DependencyFixture()
{
VirtualClientComponent.LogToFile = true;
VirtualClientComponent.ContentStorePathTemplate = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
VirtualClientComponent.ContentPathPattern = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class MockFixture : Fixture
static MockFixture()
{
VirtualClientComponent.LogToFile = true;
VirtualClientComponent.ContentStorePathTemplate = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
VirtualClientComponent.ContentPathPattern = "{experimentId}/{agentId}/{toolName}/{role}/{scenario}";
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public void VirtualClientDefaultCommandRequiresTheProfileOptionBeSupplied()
[TestCase("--contentstore", "https://anystorageaccount.blob.core.windows.net/;SharedAccessSignature=123")]
[TestCase("--content", "https://anystorageaccount.blob.core.windows.net/;SharedAccessSignature=123")]
[TestCase("--cs", "https://anystorageaccount.blob.core.windows.net/;SharedAccessSignature=123")]
[TestCase("--contentStorePathTemplate", "anyname1/anyname2/{experimentId}/{agentId}/anyname3/{toolName}/{role}/{scenario}")]
[TestCase("--contentstorepathtemplate", "anyname1/anyname2/{experimentId}/{agentId}/anyname3/{toolName}/{role}/{scenario}")]
[TestCase("--contentPathPattern", "anyname1/anyname2/{experimentId}/{agentId}/anyname3/{toolName}/{role}/{scenario}")]
[TestCase("--contentpathpattern", "anyname1/anyname2/{experimentId}/{agentId}/anyname3/{toolName}/{role}/{scenario}")]
[TestCase("--contentPath", "anyname1/anyname2/{experimentId}/{agentId}/anyname3/{toolName}/{role}/{scenario}")]
[TestCase("--cspt", "anyname1/anyname2/{experimentId}/{agentId}/anyname3/{toolName}/{role}/{scenario}")]
[TestCase("--debug", null)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ public void ContentStoreOptionValidatesTheConnectionTokenProvided()
}

[Test]
[TestCase("--contentStorePathTemplate")]
[TestCase("--contentstorepathtemplate")]
[TestCase("--contentPathPattern")]
[TestCase("--contentpathpattern")]
[TestCase("--contentPath")]
[TestCase("--cspt")]
public void ContentStorePathTemplateOptionSupportsExpectedAliases(string alias)
public void ContentPathPatternOptionSupportsExpectedAliases(string alias)
{
Option option = OptionFactory.CreateContentStorePathTemplateOption();
Option option = OptionFactory.CreateContentPathPatternOption();
ParseResult result = option.Parse($"{alias}=\"anyname1/anyname2/{{experimentId}}/{{agentId}}/anyname3/{{toolName}}/{{role}}/{{scenario}}\"");
Assert.IsFalse(result.Errors.Any());
}
Expand Down

0 comments on commit b65c31a

Please sign in to comment.