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

Added AzLinux-dnf support for RedisPackageInstallation #417

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
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
0f3d501
Updated Functional Tests
RakeshwarK May 13, 2024
b984341
Merge branch 'microsoft:main' into main
RakeshwarK May 20, 2024
8d36530
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Jun 14, 2024
6629bc9
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Jun 18, 2024
56fe32c
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Jun 26, 2024
e97f648
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Jul 11, 2024
869694b
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Jul 25, 2024
75b1e5c
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Jul 30, 2024
c38abb0
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Aug 2, 2024
8d8831c
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Sep 3, 2024
099b4d5
commit
RakeshwarK Oct 22, 2024
47ee79d
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Nov 12, 2024
dee457f
Added AzLinux support
RakeshwarK Dec 16, 2024
e037e54
Merge branch 'main' of https://github.com/RakeshwarK/VirtualClient
RakeshwarK Dec 17, 2024
67bc6d4
Merge branch 'main' into Redis-Apt
RakeshwarK Dec 17, 2024
321076f
undo memtierPkg
RakeshwarK Dec 17, 2024
331dd5f
Commit changes
RakeshwarK Dec 18, 2024
8b3cc0c
Update Profiles
RakeshwarK Dec 18, 2024
001526d
Supported Platforms change
RakeshwarK Dec 18, 2024
2c035b6
Merge branch 'main' into Redis-Apt
RakeshwarK Dec 18, 2024
67fe5e2
commit changes
RakeshwarK Dec 19, 2024
3be25f8
Merge branch 'Redis-Apt' of https://github.com/RakeshwarK/VirtualClie…
RakeshwarK Dec 19, 2024
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
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
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
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
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
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
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";

RakeshwarK marked this conversation as resolved.
Show resolved Hide 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
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?

Copy link
Contributor Author

@RakeshwarK RakeshwarK Dec 19, 2024

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
Loading