Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/VirtualClient/VirtualClient.Main/BootstrapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ protected void Validate()
"The Azure tenant ID must be provided on the command line (--tenant-id) to install a certificate.");
}
}

if (!string.IsNullOrWhiteSpace(this.PackageName) && this.PackageStore == null)
{
throw new ArgumentException(
"A package store must be provided on the command line (--package-store) when installing packages.");
}
}
}
}
5 changes: 0 additions & 5 deletions src/VirtualClient/VirtualClient.Main/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,6 @@ private static Command CreateBootstrapSubcommand(string[] args, CancellationToke
"Use --package to install a package or --cert-name to install a certificate.");
}

if (package != null && packageStore == null)
{
throw new ArgumentException("The package store URI must be provided (--package-store) when installing a package.");
}

// Certificate installation requires both --cert-name and --key-vault.
if (certName != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ protected void SetHostMetadataTelemetryProperties(IEnumerable<string> profiles,
new Dictionary<string, object>
{
{ "exitWait", this.ExitWait },
{ "layout", this.Layout.ToString() },
{ "layout", this.Layout?.ToString() },
Comment thread
nchapagain001 marked this conversation as resolved.
{ "logToFile", this.LogToFile },
{ "iterations", this.Iterations?.ProfileIterations },
{ "profiles", string.Join(",", profiles.Select(p => Path.GetFileName(p))) },
Expand Down
46 changes: 39 additions & 7 deletions src/VirtualClient/VirtualClient.UnitTests/BootstrapCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@ public void BootstrapCommandValidatesRequiredParametersForCertificateInstallatio
}

[Test]
public void BootstrapCommandValidatesRequiredParametersForPackageDownloads()
public void BootstrapCommandDoesNotRequirePackageStoredParameterForPackageDownloads()
{
// It will use default vc package store.
var command = new TestBootstrapCommand();
command.PackageName = "any-package.zip";
Exception error = Assert.Throws<ArgumentException>(() => command.Validate());

Assert.AreEqual(
"A package store must be provided on the command line (--package-store) when installing packages.",
error.Message);
Assert.DoesNotThrow(() => command.Validate());
}

[Test]
Expand Down Expand Up @@ -116,7 +113,7 @@ public void BootstrapCommandExecutesTheExpectedProfileToBootstrapPackages()
var command = new TestBootstrapCommand
{
PackageName = "any-package.zip",
PackageStore = new DependencyBlobStore(DependencyStore.Packages, "https://any.storage"),
// PackageStore is no longer required
Name = "any-package"
};

Expand Down Expand Up @@ -148,6 +145,41 @@ public void BootstrapCommandProvidesTheExpectedParametersToTheProfileToBootstrap
}
}

[Test]
public void BootstrapCommandDoesNotRequirePackageStoreForPackageInstallation()
{
// Arrange - Create command with only package name, no package store
var command = new TestBootstrapCommand
{
PackageName = "any-package.zip"
};

// Act & Assert - Should not throw ArgumentException
Assert.DoesNotThrow(() => command.Validate());
}

[Test]
public void BootstrapCommandExecutesTheExpectedProfileToBootstrapPackagesWithoutPackageStore()
{
using (CancellationTokenSource tokenSource = new CancellationTokenSource())
{
// Arrange - No PackageStore provided
var command = new TestBootstrapCommand
{
PackageName = "any-package.zip",
Name = "any-package"
};

// Act
command.Initialize(Array.Empty<string>(), this.mockFixture.PlatformSpecifics);

// Assert - Profile should still be set up correctly
Assert.IsNotEmpty(command.Profiles);
Assert.AreEqual(1, command.Profiles.Count());
Assert.AreEqual(1, command.Profiles.Count(p => p.ProfileName == "BOOTSTRAP-PACKAGE.json"));
}
}

internal class TestBootstrapCommand : BootstrapCommand
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,18 @@ private static Tuple<string, string> GetAccessTokenPair()

return new Tuple<string, string>(decodedOriginalBytes, decodedObscuredBytes);
}

[Test]
public void SetHostMetadataTelemetryPropertiesDoesNotThrowWhenLayoutIsNull()
{
// Layout is not mandatory for setting host metadata properties.
this.command.Layout = null;

string profile = "TEST-WORKLOAD-PROFILE.json";
List<string> profiles = new List<string> { this.mockFixture.GetProfilesPath(profile) };

// Act & Assert - Should not throw expection
Assert.DoesNotThrow(() => this.command.SetHostMetadataTelemetryProperties(profiles, this.mockFixture.Dependencies));
}
}
}
Loading