-
Notifications
You must be signed in to change notification settings - Fork 62
Users/nmalkapuram/redis tls combined profile #146
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
04642c1
combining tls and without tls profile for redis
nmalkapuram 68bed80
Added ABC combined profile and separate profiles for different scenarios
nmalkapuram 113ef2d
combining TLS and without TLS for redis and adding installation of re…
nmalkapuram 5190c79
adding unit tests
nmalkapuram 70e6d31
cleanup
nmalkapuram f824655
resolving build errors
nmalkapuram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/VirtualClient/VirtualClient.Dependencies.UnitTests/RedisPackageInstallationTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace VirtualClient.Dependencies | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Runtime.InteropServices; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Moq; | ||
| using NUnit.Framework; | ||
| using VirtualClient.Common.Telemetry; | ||
| using VirtualClient.Contracts; | ||
|
|
||
| [TestFixture] | ||
| [Category("Unit")] | ||
| public class RedisPackageInstallationTests | ||
| { | ||
| private MockFixture mockFixture; | ||
| private DependencyPath mockPackage; | ||
|
|
||
| [SetUp] | ||
| public void SetupTest() | ||
| { | ||
| this.mockFixture = new MockFixture(); | ||
| } | ||
|
|
||
| [Test] | ||
| public void RedisPackageInstallationThrowsIfDistroNotSupportedForLinux() | ||
| { | ||
| this.SetupDefaultMockBehavior(); | ||
| LinuxDistributionInfo mockInfo = new LinuxDistributionInfo() | ||
| { | ||
| OperationSystemFullName = "TestUbuntu", | ||
| LinuxDistribution = LinuxDistribution.SUSE | ||
| }; | ||
|
|
||
| this.mockFixture.SystemManagement.Setup(sm => sm.GetLinuxDistributionAsync(It.IsAny<CancellationToken>())) | ||
| .ReturnsAsync(mockInfo); | ||
|
|
||
| using (TestRedisPackageInstallation installation = new TestRedisPackageInstallation(this.mockFixture.Dependencies, this.mockFixture.Parameters)) | ||
| { | ||
| WorkloadException exception = Assert.ThrowsAsync<WorkloadException>(() => installation.ExecuteAsync(CancellationToken.None)); | ||
| Assert.AreEqual(ErrorReason.LinuxDistributionNotSupported, exception.Reason); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| [TestCase(Architecture.X64, "linux-x64")] | ||
| [TestCase(Architecture.Arm64, "linux-arm64")] | ||
| public async Task RedisPackageInstallationExecutesExpectedInstallationCommandsOnUbuntu(Architecture architecture, string platformArchitecture) | ||
| { | ||
| this.SetupDefaultMockBehavior(PlatformID.Unix, architecture); | ||
|
|
||
| LinuxDistributionInfo mockInfo = new LinuxDistributionInfo() | ||
| { | ||
| OperationSystemFullName = "TestUbuntu", | ||
| LinuxDistribution = LinuxDistribution.Ubuntu | ||
| }; | ||
|
|
||
| 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($"apt update")); | ||
| Assert.IsTrue(this.mockFixture.ProcessManager.CommandsExecuted($"apt install redis -y")); | ||
| } | ||
| } | ||
|
|
||
| private void SetupDefaultMockBehavior(PlatformID platform = PlatformID.Unix, Architecture architecture = Architecture.X64) | ||
| { | ||
| this.mockFixture.Setup(platform, architecture); | ||
| this.mockFixture.Parameters = new Dictionary<string, IConvertible>() | ||
| { | ||
| { "PackageName", "redis" } | ||
| }; | ||
|
|
||
| this.mockPackage = new DependencyPath("redis", this.mockFixture.GetPackagePath("redis")); | ||
| this.mockFixture.FileSystem.Setup(fe => fe.File.Exists(It.IsAny<string>())).Returns(true); | ||
| this.mockFixture.PackageManager.OnGetPackage().ReturnsAsync(this.mockPackage); | ||
| } | ||
|
|
||
| private class TestRedisPackageInstallation : RedisPackageInstallation | ||
| { | ||
| public TestRedisPackageInstallation(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters) | ||
| : base(dependencies, parameters) | ||
| { | ||
| } | ||
|
|
||
| public new Task InitializeAsync(EventContext context, CancellationToken cancellationToken) | ||
| { | ||
| return base.InitializeAsync(context, cancellationToken); | ||
| } | ||
|
|
||
| public new Task ExecuteAsync(EventContext context, CancellationToken cancellationToken) | ||
| { | ||
| return base.ExecuteAsync(context, cancellationToken); | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.