From 0f3d501a2b81610886f7d518fc06ef9e5b346156 Mon Sep 17 00:00:00 2001 From: Rakesh <153008248+RakeshwarK@users.noreply.github.com> Date: Mon, 13 May 2024 13:55:43 -0700 Subject: [PATCH 1/8] Updated Functional Tests Signed-off-by: Rakesh <153008248+RakeshwarK@users.noreply.github.com> --- .../AspNetBenchProfileTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Actions.FunctionalTests/AspNetBenchProfileTests.cs b/src/VirtualClient/VirtualClient.Actions.FunctionalTests/AspNetBenchProfileTests.cs index 03864f99e2..26a1408bb6 100644 --- a/src/VirtualClient/VirtualClient.Actions.FunctionalTests/AspNetBenchProfileTests.cs +++ b/src/VirtualClient/VirtualClient.Actions.FunctionalTests/AspNetBenchProfileTests.cs @@ -106,7 +106,7 @@ private IEnumerable<string> GetProfileExpectedCommands(PlatformID platform) case PlatformID.Win32NT: commands = new List<string> { - @"dotnet\.exe build -c Release -p:BenchmarksTargetFramework=net7.0", + @"dotnet\.exe build -c Release -p:BenchmarksTargetFramework=net8.0", @"dotnet\.exe .+Benchmarks.dll --nonInteractive true --scenarios json --urls http://localhost:9876 --server Kestrel --kestrelTransport Sockets --protocol http --header ""Accept:.+ keep-alive", @"bombardier\.exe --duration 15s --connections 256 --timeout 10s --fasthttp --insecure -l http://localhost:9876/json --print r --format json" }; @@ -116,7 +116,7 @@ private IEnumerable<string> GetProfileExpectedCommands(PlatformID platform) commands = new List<string> { @"chmod \+x .+bombardier", - @"dotnet build -c Release -p:BenchmarksTargetFramework=net7.0", + @"dotnet build -c Release -p:BenchmarksTargetFramework=net8.0", @"dotnet .+Benchmarks.dll --nonInteractive true --scenarios json --urls http://localhost:9876 --server Kestrel --kestrelTransport Sockets --protocol http --header ""Accept:.+ keep-alive", @"bombardier --duration 15s --connections 256 --timeout 10s --fasthttp --insecure -l http://localhost:9876/json --print r --format json" }; From 099b4d53d5632f0fb71df33c64bc066e3f090318 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Tue, 22 Oct 2024 11:16:00 -0700 Subject: [PATCH 2/8] commit --- .../MemtierPackageInstallation.cs | 164 ++++++++++++++++++ .../RedisPackageInstallation.cs | 2 + 2 files changed, 166 insertions(+) create mode 100644 src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs diff --git a/src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs b/src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs new file mode 100644 index 0000000000..23e6df0a01 --- /dev/null +++ b/src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// in opensoruce to download redis from apt package manager. +namespace VirtualClient.Dependencies +{ + using System; + using System.Collections.Generic; + using System.IO.Abstractions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Extensions.DependencyInjection; + using Microsoft.VisualBasic; + using Newtonsoft.Json; + using Polly; + using VirtualClient.Common; + using VirtualClient.Common.Contracts; + using VirtualClient.Common.Extensions; + using VirtualClient.Common.Platform; + using VirtualClient.Common.Telemetry; + using VirtualClient.Contracts; + + /// <summary> + /// Provides functionality for installing latest version of Redis from Apt package manager on specific OS distribution version. + /// </summary> + [SupportedPlatforms("linux-arm64,linux-x64")] + public class MemtierPackageInstallation : VirtualClientComponent + { + private IFileSystem fileSystem; + private ISystemManagement systemManager; + private string installRedisCommand; + private IPackageManager packageManager; + private IStateManager stateManager; + + /// <summary> + /// Initializes a new instance of the <see cref="MemtierPackageInstallation"/> class. + /// </summary> + /// <param name="dependencies">An enumeration of dependencies that can be used for dependency injection.</param> + /// <param name="parameters">A series of key value pairs that dictate runtime execution.</param> + public MemtierPackageInstallation(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters) + : base(dependencies, parameters) + { + this.RetryPolicy = Policy.Handle<Exception>().WaitAndRetryAsync(5, (retries) => TimeSpan.FromSeconds(retries + 1)); + this.systemManager = dependencies.GetService<ISystemManagement>(); + this.packageManager = this.systemManager.PackageManager; + this.stateManager = this.systemManager.StateManager; + this.fileSystem = this.systemManager.FileSystem; + } + + /// <summary> + /// The version of redis to install from the apt repository.This version should have exact version number and release information. e.g: 5:6.0.16-1ubuntu1 + /// </summary> + public string Version + { + get + { + return this.Parameters.GetValue<string>(nameof(MemtierPackageInstallation.Version), string.Empty); + } + + set + { + this.Parameters[nameof(MemtierPackageInstallation.Version)] = value; + } + } + + /// <summary> + /// A policy that defines how the component will retry when + /// it experiences transient issues. + /// </summary> + public IAsyncPolicy RetryPolicy { get; set; } + + /// <summary> + /// The path to the Redis package for installation. + /// </summary> + protected string PackagePath { get; set; } + + /// <summary> + /// Initializes redis installation requirements. + /// </summary> + /// <param name="telemetryContext">Provides context information that will be captured with telemetry events.</param> + /// <param name="cancellationToken">A token that can be used to cancel the operation.</param> + /// <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); + } + + if (this.Platform == PlatformID.Unix) + { + 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); + } + } + + this.PackagePath = this.PlatformSpecifics.GetPackagePath(this.PackageName); + } + + /// <summary> + /// Executes Redis installation steps. + /// </summary> + /// <param name="telemetryContext">Provides context information that will be captured with telemetry events.</param> + /// <param name="cancellationToken">A token that can be used to cancel the operation.</param> + protected override async Task ExecuteAsync(EventContext telemetryContext, CancellationToken cancellationToken) + { + if (this.Platform == PlatformID.Unix) + { + LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken); + + switch (distroInfo.LinuxDistribution) + { + case LinuxDistribution.Ubuntu: + case LinuxDistribution.Debian: + await this.InstallOnUbuntuAsync(telemetryContext, cancellationToken); + break; + } + } + } + + private async Task InstallOnUbuntuAsync(EventContext telemetryContext, CancellationToken cancellationToken) + { + if (this.Version != string.Empty) + { + this.installRedisCommand = $"install memtier-benchmark={this.Version} -y"; + } + else + { + this.installRedisCommand = $"install memtier-benchmark -y"; + + } + + await this.ExecuteCommandAsync("apt", "install lsb-release curl gpg", Environment.CurrentDirectory, telemetryContext, cancellationToken) + .ConfigureAwait(false); + await this.ExecuteCommandAsync("curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg", Environment.CurrentDirectory, telemetryContext, cancellationToken) + .ConfigureAwait(false); + await this.ExecuteCommandAsync("echo \"deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/redis.list", Environment.CurrentDirectory, telemetryContext, cancellationToken) + .ConfigureAwait(false); + await this.ExecuteCommandAsync("apt", "update", Environment.CurrentDirectory, telemetryContext, cancellationToken) + .ConfigureAwait(false); + await this.ExecuteCommandAsync("apt", this.installRedisCommand, Environment.CurrentDirectory, telemetryContext, cancellationToken) + .ConfigureAwait(false); + + this.fileSystem.Directory.CreateDirectory(this.PackagePath); + this.fileSystem.Directory.CreateDirectory(this.PlatformSpecifics.Combine(this.PackagePath, "memtier_benchmark")); + + await this.ExecuteCommandAsync("cp", $"/usr/bin/memtier_benchmark {this.PlatformSpecifics.Combine(this.PackagePath, "memtier_benchmark")}", Environment.CurrentDirectory, telemetryContext, cancellationToken) + .ConfigureAwait(false); + + DependencyPath redisPackage = new DependencyPath(this.PackageName, this.PackagePath); + await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cancellationToken) + .ConfigureAwait(false); + + } + } +} diff --git a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs index a2a35ce6c4..bd17995e5f 100644 --- a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs +++ b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs @@ -89,6 +89,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can if (this.Platform == PlatformID.Unix) { LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken); + this.Logger.LogMessage($"Print Distro Info:{distroInfo}", telemetryContext); + this.Logger.LogMessage($"Print LinuxDistribution:{distroInfo.LinuxDistribution}", telemetryContext); switch (distroInfo.LinuxDistribution) { From dee457f181de7577f357af74d8c13d732c99f169 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Sun, 15 Dec 2024 21:49:18 -0800 Subject: [PATCH 3/8] Added AzLinux support --- .../RedisPackageInstallationTests.cs | 25 +++++++++++++ .../RedisPackageInstallation.cs | 36 ++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/VirtualClient/VirtualClient.Dependencies.UnitTests/RedisPackageInstallationTests.cs b/src/VirtualClient/VirtualClient.Dependencies.UnitTests/RedisPackageInstallationTests.cs index 61be90443d..cd95b26c6b 100644 --- a/src/VirtualClient/VirtualClient.Dependencies.UnitTests/RedisPackageInstallationTests.cs +++ b/src/VirtualClient/VirtualClient.Dependencies.UnitTests/RedisPackageInstallationTests.cs @@ -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); diff --git a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs index bd17995e5f..5ca04be522 100644 --- a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs +++ b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs @@ -96,7 +96,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can { 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}'.", @@ -124,6 +125,9 @@ 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; } } } @@ -156,5 +160,35 @@ await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cance .ConfigureAwait(false); } + + private async Task InstallOnAzLinuxAsync(EventContext telemetryContext, CancellationToken cancellationToken) + { + if (this.Version != string.Empty) + { + this.installRedisCommand = $"install redis-{this.Version} -y"; + } + else + { + this.installRedisCommand = $"install redis -y"; + + } + + 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); + + } + } } From 321076f095e9d650b151b6cb533e66faa88eb799 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Tue, 17 Dec 2024 09:31:47 -0800 Subject: [PATCH 4/8] undo memtierPkg --- .../MemtierPackageInstallation.cs | 164 ------------------ 1 file changed, 164 deletions(-) delete mode 100644 src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs diff --git a/src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs b/src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs deleted file mode 100644 index 23e6df0a01..0000000000 --- a/src/VirtualClient/VirtualClient.Dependencies/MemtierPackageInstallation.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// in opensoruce to download redis from apt package manager. -namespace VirtualClient.Dependencies -{ - using System; - using System.Collections.Generic; - using System.IO.Abstractions; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.VisualBasic; - using Newtonsoft.Json; - using Polly; - using VirtualClient.Common; - using VirtualClient.Common.Contracts; - using VirtualClient.Common.Extensions; - using VirtualClient.Common.Platform; - using VirtualClient.Common.Telemetry; - using VirtualClient.Contracts; - - /// <summary> - /// Provides functionality for installing latest version of Redis from Apt package manager on specific OS distribution version. - /// </summary> - [SupportedPlatforms("linux-arm64,linux-x64")] - public class MemtierPackageInstallation : VirtualClientComponent - { - private IFileSystem fileSystem; - private ISystemManagement systemManager; - private string installRedisCommand; - private IPackageManager packageManager; - private IStateManager stateManager; - - /// <summary> - /// Initializes a new instance of the <see cref="MemtierPackageInstallation"/> class. - /// </summary> - /// <param name="dependencies">An enumeration of dependencies that can be used for dependency injection.</param> - /// <param name="parameters">A series of key value pairs that dictate runtime execution.</param> - public MemtierPackageInstallation(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters) - : base(dependencies, parameters) - { - this.RetryPolicy = Policy.Handle<Exception>().WaitAndRetryAsync(5, (retries) => TimeSpan.FromSeconds(retries + 1)); - this.systemManager = dependencies.GetService<ISystemManagement>(); - this.packageManager = this.systemManager.PackageManager; - this.stateManager = this.systemManager.StateManager; - this.fileSystem = this.systemManager.FileSystem; - } - - /// <summary> - /// The version of redis to install from the apt repository.This version should have exact version number and release information. e.g: 5:6.0.16-1ubuntu1 - /// </summary> - public string Version - { - get - { - return this.Parameters.GetValue<string>(nameof(MemtierPackageInstallation.Version), string.Empty); - } - - set - { - this.Parameters[nameof(MemtierPackageInstallation.Version)] = value; - } - } - - /// <summary> - /// A policy that defines how the component will retry when - /// it experiences transient issues. - /// </summary> - public IAsyncPolicy RetryPolicy { get; set; } - - /// <summary> - /// The path to the Redis package for installation. - /// </summary> - protected string PackagePath { get; set; } - - /// <summary> - /// Initializes redis installation requirements. - /// </summary> - /// <param name="telemetryContext">Provides context information that will be captured with telemetry events.</param> - /// <param name="cancellationToken">A token that can be used to cancel the operation.</param> - /// <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); - } - - if (this.Platform == PlatformID.Unix) - { - 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); - } - } - - this.PackagePath = this.PlatformSpecifics.GetPackagePath(this.PackageName); - } - - /// <summary> - /// Executes Redis installation steps. - /// </summary> - /// <param name="telemetryContext">Provides context information that will be captured with telemetry events.</param> - /// <param name="cancellationToken">A token that can be used to cancel the operation.</param> - protected override async Task ExecuteAsync(EventContext telemetryContext, CancellationToken cancellationToken) - { - if (this.Platform == PlatformID.Unix) - { - LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken); - - switch (distroInfo.LinuxDistribution) - { - case LinuxDistribution.Ubuntu: - case LinuxDistribution.Debian: - await this.InstallOnUbuntuAsync(telemetryContext, cancellationToken); - break; - } - } - } - - private async Task InstallOnUbuntuAsync(EventContext telemetryContext, CancellationToken cancellationToken) - { - if (this.Version != string.Empty) - { - this.installRedisCommand = $"install memtier-benchmark={this.Version} -y"; - } - else - { - this.installRedisCommand = $"install memtier-benchmark -y"; - - } - - await this.ExecuteCommandAsync("apt", "install lsb-release curl gpg", Environment.CurrentDirectory, telemetryContext, cancellationToken) - .ConfigureAwait(false); - await this.ExecuteCommandAsync("curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg", Environment.CurrentDirectory, telemetryContext, cancellationToken) - .ConfigureAwait(false); - await this.ExecuteCommandAsync("echo \"deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/redis.list", Environment.CurrentDirectory, telemetryContext, cancellationToken) - .ConfigureAwait(false); - await this.ExecuteCommandAsync("apt", "update", Environment.CurrentDirectory, telemetryContext, cancellationToken) - .ConfigureAwait(false); - await this.ExecuteCommandAsync("apt", this.installRedisCommand, Environment.CurrentDirectory, telemetryContext, cancellationToken) - .ConfigureAwait(false); - - this.fileSystem.Directory.CreateDirectory(this.PackagePath); - this.fileSystem.Directory.CreateDirectory(this.PlatformSpecifics.Combine(this.PackagePath, "memtier_benchmark")); - - await this.ExecuteCommandAsync("cp", $"/usr/bin/memtier_benchmark {this.PlatformSpecifics.Combine(this.PackagePath, "memtier_benchmark")}", Environment.CurrentDirectory, telemetryContext, cancellationToken) - .ConfigureAwait(false); - - DependencyPath redisPackage = new DependencyPath(this.PackageName, this.PackagePath); - await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cancellationToken) - .ConfigureAwait(false); - - } - } -} From 331dd5fd3c42e47f4e63673efcd10a7ecc4e8ff8 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Wed, 18 Dec 2024 07:32:57 -0800 Subject: [PATCH 5/8] Commit changes --- .../VirtualClient.Dependencies/RedisPackageInstallation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs index 5ca04be522..2ab9ead790 100644 --- a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs +++ b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs @@ -134,7 +134,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel 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"; } @@ -163,7 +163,7 @@ await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cance private async Task InstallOnAzLinuxAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - if (this.Version != string.Empty) + if (!string.IsNullOrEmpty(this.Version)) { this.installRedisCommand = $"install redis-{this.Version} -y"; } From 8b3cc0c6839b2e0df8cdc0b7fd61cbdccab6beab Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Wed, 18 Dec 2024 08:25:15 -0800 Subject: [PATCH 6/8] Update Profiles --- .../profiles/GET-STARTED-REDIS.json | 18 ++-------- .../profiles/PERF-REDIS.json | 33 ++++++------------- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json b/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json index 14099b5485..a1579e0767 100644 --- a/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json +++ b/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json @@ -55,22 +55,10 @@ } }, { - "Type": "WgetPackageInstallation", + "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" } }, { diff --git a/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json b/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json index 9c46e54911..544b4da50a 100644 --- a/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json +++ b/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json @@ -234,36 +234,23 @@ } }, { - "Type": "DependencyPackageInstallation", + "Type": "RedisPackageInstallation", "Parameters": { - "Scenario": "InstallKeysForRedisTLS", - "BlobContainer": "packages", - "BlobName": "redisresources.zip", - "PackageName": "redisresources", - "Extract": true + "Scenario": "InstallRedisPackageFromAptRepository", + "PackageName": "redis" } }, { - "Type": "WgetPackageInstallation", + "Type": "ExecuteCommand", "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" + "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": "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": { From 001526d28abfef9d3dda31d868b146a6b1c71494 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Wed, 18 Dec 2024 12:45:58 -0800 Subject: [PATCH 7/8] Supported Platforms change --- .../RedisPackageInstallation.cs | 35 +++++++------------ .../profiles/PERF-REDIS.json | 11 ------ 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs index 2ab9ead790..92bc80aaab 100644 --- a/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs +++ b/src/VirtualClient/VirtualClient.Dependencies/RedisPackageInstallation.cs @@ -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; @@ -81,28 +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); - this.Logger.LogMessage($"Print Distro Info:{distroInfo}", telemetryContext); - this.Logger.LogMessage($"Print LinuxDistribution:{distroInfo.LinuxDistribution}", telemetryContext); - - switch (distroInfo.LinuxDistribution) - { - 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); - } + 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); @@ -141,7 +133,6 @@ private async Task InstallOnUbuntuAsync(EventContext telemetryContext, Cancellat else { this.installRedisCommand = $"install redis -y"; - } await this.ExecuteCommandAsync("apt", "update", Environment.CurrentDirectory, telemetryContext, cancellationToken) diff --git a/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json b/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json index 544b4da50a..1fbe517573 100644 --- a/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json +++ b/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json @@ -240,17 +240,6 @@ "PackageName": "redis" } }, - { - "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": { From 67fe5e2667cb1d4e3c87df3f6e74b6602c58a0ba Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari <v-rkambaiahg@microsoft.com> Date: Wed, 18 Dec 2024 21:28:02 -0800 Subject: [PATCH 8/8] commit changes --- .../Redis/RedisServerProfileTests.cs | 2 +- .../VirtualClient.Main/profiles/GET-STARTED-REDIS.json | 3 ++- src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Actions.FunctionalTests/Redis/RedisServerProfileTests.cs b/src/VirtualClient/VirtualClient.Actions.FunctionalTests/Redis/RedisServerProfileTests.cs index 37ade6ffce..7548183ed7 100644 --- a/src/VirtualClient/VirtualClient.Actions.FunctionalTests/Redis/RedisServerProfileTests.cs +++ b/src/VirtualClient/VirtualClient.Actions.FunctionalTests/Redis/RedisServerProfileTests.cs @@ -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)); } diff --git a/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json b/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json index a1579e0767..5e9bd3ce38 100644 --- a/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json +++ b/src/VirtualClient/VirtualClient.Main/profiles/GET-STARTED-REDIS.json @@ -66,6 +66,7 @@ "Parameters": { "Scenario": "CloneMemtierRepo", "RepoUri": "https://github.com/RedisLabs/memtier_benchmark", + "Commit": "1.4.0", "PackageName": "memtier" } }, @@ -74,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}" } }, diff --git a/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json b/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json index 1fbe517573..6a00fe9caa 100644 --- a/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json +++ b/src/VirtualClient/VirtualClient.Main/profiles/PERF-REDIS.json @@ -245,6 +245,7 @@ "Parameters": { "Scenario": "CloneMemtierRepo", "RepoUri": "https://github.com/RedisLabs/memtier_benchmark", + "Commit": "1.4.0", "PackageName": "memtier" } }, @@ -253,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}" } },