-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathTlsOpenSslClientProfileTests.cs
More file actions
71 lines (60 loc) · 2.63 KB
/
Copy pathTlsOpenSslClientProfileTests.cs
File metadata and controls
71 lines (60 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace VirtualClient.Actions
{
using System;
using System.Collections.Generic;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using VirtualClient.Common;
using VirtualClient.Contracts;
[TestFixture]
[Category("Functional")]
public class TlsOpenSslClientProfileTests
{
private DependencyFixture mockFixture;
[SetUp]
public void SetupFixture()
{
this.mockFixture = new DependencyFixture();
this.mockFixture
.Setup(PlatformID.Unix, Architecture.X64, "Client01")
.SetupLayout(
new ClientInstance("Client01", "1.2.3.4", "Client"),
new ClientInstance("Server01", "1.2.3.5", "Server"));
ComponentTypeCache.Instance.LoadComponentTypes(TestDependencies.TestDirectory);
}
[Test]
[TestCase("PERF-CPU-OPENSSL-TLS.json")]
public async Task TlsOpenSslClientCreatesExpectedStateAndExecutesWorkload(string profile)
{
List<string> expectedCommands = new List<string>();
// Setup the expectations for the workload
// - Workload package is installed and exists.
// - Workload binaries/executables exist on the file system.
// - Expected processes are executed.
IPAddress.TryParse("1.2.3.4", out IPAddress ipAddress);
IApiClient apiClient = this.mockFixture.ApiClientManager.GetOrCreateApiClient("1.2.3.4", ipAddress);
State state = new State();
await apiClient.CreateStateAsync(nameof(State), state, CancellationToken.None);
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
{
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
if (arguments?.Contains("s_time") == true)
{
return process;
}
return process;
};
using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies, dependenciesOnly: true))
{
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None);
WorkloadAssert.WorkloadPackageInstalled(this.mockFixture, "openssl");
WorkloadAssert.CommandsExecuted(this.mockFixture, expectedCommands.ToArray());
}
}
}
}