Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void SetupFixture()
ComponentTypeCache.Instance.LoadComponentTypes(TestDependencies.TestDirectory);

this.mockFixture.SetupWorkloadPackage("wget", expectedFiles: "linux-x64/wget2");
this.mockFixture.SetupFile("redis", "redis-6.2.1/src/redis-server", new byte[0]);
this.mockFixture.SetupFile("redis", "src/redis-server", new byte[0]);
this.mockFixture.SystemManagement.Setup(mgr => mgr.GetCpuInfoAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(new CpuInfo("AnyName", "AnyDescription", 1, 4, 1, 0, true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ public async Task RedisPackageInstallationExecutesExpectedInstallationCommandsOn
}
}

[Test]
[TestCase(Architecture.X64, "linux-x64")]
[TestCase(Architecture.Arm64, "linux-arm64")]
public async Task RedisPackageInstallationExecutesExpectedInstallationCommandsOnAzLinux(Architecture architecture, string platformArchitecture)
{
this.SetupDefaultMockBehavior(PlatformID.Unix, architecture);

LinuxDistributionInfo mockInfo = new LinuxDistributionInfo()
{
OperationSystemFullName = "TestAzLinux",
LinuxDistribution = LinuxDistribution.AzLinux
};

this.mockFixture.SystemManagement.Setup(sm => sm.GetLinuxDistributionAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(mockInfo);

using (TestRedisPackageInstallation installation = new TestRedisPackageInstallation(this.mockFixture.Dependencies, this.mockFixture.Parameters))
{
await installation.ExecuteAsync(CancellationToken.None);

Assert.IsTrue(this.mockFixture.ProcessManager.CommandsExecuted($"dnf update"));
Assert.IsTrue(this.mockFixture.ProcessManager.CommandsExecuted($"dnf install redis -y"));
}
}

private void SetupDefaultMockBehavior(PlatformID platform = PlatformID.Unix, Architecture architecture = Architecture.X64)
{
this.mockFixture.Setup(platform, architecture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace VirtualClient.Dependencies
/// <summary>
/// Provides functionality for installing latest version of Redis from Apt package manager on specific OS distribution version.
/// </summary>
[SupportedPlatforms("linux-arm64,linux-x64")]
[SupportedPlatforms("linux-arm64,linux-x64", throwError: true)]
public class RedisPackageInstallation : VirtualClientComponent
{
private IFileSystem fileSystem;
Expand Down Expand Up @@ -81,25 +81,20 @@ public string Version
/// <returns></returns>
protected override async Task InitializeAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
if (this.Platform != PlatformID.Unix)
{
throw new WorkloadException($"Unsupported platform. The platform '{this.Platform}' is not supported.", ErrorReason.NotSupported);
}
LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken);
this.Logger.LogMessage($"Print Distro Info:{distroInfo}", telemetryContext);
this.Logger.LogMessage($"Print LinuxDistribution:{distroInfo.LinuxDistribution}", telemetryContext);

if (this.Platform == PlatformID.Unix)
switch (distroInfo.LinuxDistribution)
{
LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken);

switch (distroInfo.LinuxDistribution)
{
case LinuxDistribution.Ubuntu:
break;

default:
throw new WorkloadException(
$"Redis installation is not supported by Virtual Client on the current Unix/Linux distro '{distroInfo.LinuxDistribution}'.",
ErrorReason.LinuxDistributionNotSupported);
}
case LinuxDistribution.Ubuntu:
break;
case LinuxDistribution.AzLinux:
break;
default:
throw new WorkloadException(
$"Redis installation is not supported by Virtual Client on the current Unix/Linux distro '{distroInfo.LinuxDistribution}'.",
ErrorReason.LinuxDistributionNotSupported);
}

this.PackagePath = this.PlatformSpecifics.GetPackagePath(this.PackageName);
Expand All @@ -122,20 +117,22 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
case LinuxDistribution.Debian:
await this.InstallOnUbuntuAsync(telemetryContext, cancellationToken);
break;
case LinuxDistribution.AzLinux:
await this.InstallOnAzLinuxAsync(telemetryContext, cancellationToken);
break;
}
}
}

private async Task InstallOnUbuntuAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
if (this.Version != string.Empty)
if (!string.IsNullOrEmpty(this.Version))
{
this.installRedisCommand = $"install redis={this.Version} -y";
}
else
{
this.installRedisCommand = $"install redis -y";

}

await this.ExecuteCommandAsync("apt", "update", Environment.CurrentDirectory, telemetryContext, cancellationToken)
Expand All @@ -154,5 +151,35 @@ await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cance
.ConfigureAwait(false);

}

private async Task InstallOnAzLinuxAsync(EventContext telemetryContext, CancellationToken cancellationToken)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried tdnf?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tdnf also works, is it preferred!?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on AzLinux yes, on RHEL still use dnf. You don;t have to change it right now, you could add a comment that tdnf also works. I heard AzLinux eventually wants to move to tdnf entirely

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this would also work on RHEL/Fedora distros?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I haven't tested these cases. Should I also include RHEL/Fedora distros?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, Redis is important enough that we need more than ubuntu and AzLinux

{
if (!string.IsNullOrEmpty(this.Version))
{
this.installRedisCommand = $"install redis-{this.Version} -y";
}
else
{
this.installRedisCommand = $"install redis -y";

Comment thread
RakeshwarK marked this conversation as resolved.
}

await this.ExecuteCommandAsync("dnf", "update -y", Environment.CurrentDirectory, telemetryContext, cancellationToken)
.ConfigureAwait(false);
await this.ExecuteCommandAsync("dnf", this.installRedisCommand, Environment.CurrentDirectory, telemetryContext, cancellationToken)
.ConfigureAwait(false);

this.fileSystem.Directory.CreateDirectory(this.PackagePath);
this.fileSystem.Directory.CreateDirectory(this.PlatformSpecifics.Combine(this.PackagePath, "src"));

await this.ExecuteCommandAsync("cp", $"/usr/bin/redis-server {this.PlatformSpecifics.Combine(this.PackagePath, "src")}", Environment.CurrentDirectory, telemetryContext, cancellationToken)
.ConfigureAwait(false);

DependencyPath redisPackage = new DependencyPath(this.PackageName, this.PackagePath);
await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cancellationToken)
.ConfigureAwait(false);

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,18 @@
}
},
{
"Type": "WgetPackageInstallation",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested the changes in ubuntu?

@RakeshwarK Rakesh (RakeshwarK) Dec 19, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some issue with Redis, entering protected mode in ubuntu even without these changes, but the changes were running fine on AZ Linux.

"Type": "RedisPackageInstallation",
"Parameters": {
"Scenario": "InstallRedisPackage",
"PackageName": "redis",
"PackageUri": "https://github.com/redis/redis/archive/refs/tags/6.2.1.tar.gz",
"SubPath": "redis-6.2.1",
"Notes": "Example path to package -> /packages/redis/redis-6.2.1"
}
},
{
"Type": "ExecuteCommand",
"Parameters": {
"Scenario": "CompileRedis",
"SupportedPlatforms": "linux-x64,linux-arm64",
"Command": "make",
"WorkingDirectory": "{PackagePath:redis}"
"Scenario": "InstallRedisPackageFromAptRepository",
"PackageName": "redis"
}
},
{
"Type": "GitRepoClone",
"Parameters": {
"Scenario": "CloneMemtierRepo",
"RepoUri": "https://github.com/RedisLabs/memtier_benchmark",
"Commit": "1.4.0",
"PackageName": "memtier"
}
},
Expand All @@ -86,7 +75,7 @@
"Parameters": {
"Scenario": "CompileMemtier",
"SupportedPlatforms": "linux-x64,linux-arm64",
"Command": "git checkout 1.4.0&&autoreconf -ivf&&bash -c './configure'&&make",
"Command": "autoreconf -ivf&&bash -c './configure'&&make",
"WorkingDirectory": "{PackagePath:memtier}"
}
},
Expand Down
33 changes: 5 additions & 28 deletions src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,41 +234,18 @@
}
},
{
"Type": "DependencyPackageInstallation",
"Type": "RedisPackageInstallation",
"Parameters": {
"Scenario": "InstallKeysForRedisTLS",
"BlobContainer": "packages",
"BlobName": "redisresources.zip",
"PackageName": "redisresources",
"Extract": true
"Scenario": "InstallRedisPackageFromAptRepository",
"PackageName": "redis"
}
},
{
"Type": "WgetPackageInstallation",
"Parameters": {
"Scenario": "InstallRedisPackage",
"PackageName": "redis",
"PackageUri": "https://github.com/redis/redis/archive/refs/tags/6.2.1.tar.gz",
"SubPath": "redis-6.2.1",
"Notes": "Example path to package -> /packages/redis/redis-6.2.1"
}
},
{
"Type": "ExecuteCommand",
"Parameters": {
"Scenario": "CompileRedis",
"SupportedPlatforms": "linux-x64,linux-arm64",
"IsTLSEnabled": "$.Parameters.IsTLSEnabled",
"BUILD_TLS": "{calculate({IsTLSEnabled} ? \"yes\" : \"no\" )}",
"Command": "make BUILD_TLS={BUILD_TLS}",
"WorkingDirectory": "{PackagePath:redis}"
}
},
{
"Type": "GitRepoClone",
"Parameters": {
"Scenario": "CloneMemtierRepo",
"RepoUri": "https://github.com/RedisLabs/memtier_benchmark",
"Commit": "1.4.0",
"PackageName": "memtier"
}
},
Expand All @@ -277,7 +254,7 @@
"Parameters": {
"Scenario": "CompileMemtier",
"SupportedPlatforms": "linux-x64,linux-arm64",
"Command": "git checkout 1.4.0&&autoreconf -ivf&&bash -c './configure'&&make",
"Command": "autoreconf -ivf&&bash -c './configure'&&make",
"WorkingDirectory": "{PackagePath:memtier}"
}
},
Expand Down