Skip to content

Commit bf6aadd

Browse files
authored
Merge branch 'microsoft:main' into rkambaiahgar/ParameterSets
2 parents 5fe5a97 + 1d74242 commit bf6aadd

29 files changed

Lines changed: 797 additions & 56 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.27
1+
2.0.29

src/VirtualClient/Module.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
<!-- Microsoft.Windows.Compatibility -->
8484
<Microsoft_Windows_Compatibility_PackageVersion>9.0.3</Microsoft_Windows_Compatibility_PackageVersion>
8585

86+
<!-- MimeMapping -->
87+
<MimeMapping_PackageVersion>3.1.0</MimeMapping_PackageVersion>
88+
8689
<!-- Moq -->
8790
<Moq_PackageVersion>4.18.2</Moq_PackageVersion>
8891

src/VirtualClient/VirtualClient.Actions.FunctionalTests/CompressionProfileTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ private IEnumerable<string> GetProfileExpectedCommands(PlatformID platform, Arch
140140
{
141141
commands = new List<string>
142142
{
143-
$"sudo wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
143+
$"sudo wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
144144
$"sudo unzip silesia.zip -d silesia",
145145
$"sudo bash -c \"pbzip2 -fv /home/user/tools/VirtualClient/packages/pbzip2/silesia/*\"",
146146
$"sudo bash -c \"pbzip2 -fvd /home/user/tools/VirtualClient/packages/pbzip2/silesia/*\"",
147-
$"sudo wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
147+
$"sudo wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
148148
$"sudo unzip silesia.zip -d silesia",
149149
$"sudo bash -c \"gzip -rvf /home/user/tools/VirtualClient/packages/gzip/silesia\"",
150150
$"sudo bash -c \"gzip -rvfd /home/user/tools/VirtualClient/packages/gzip/silesia\""
@@ -154,7 +154,7 @@ private IEnumerable<string> GetProfileExpectedCommands(PlatformID platform, Arch
154154
{
155155
commands = new List<string>
156156
{
157-
$"wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
157+
$"wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
158158
$"unzip silesia.zip -d silesia",
159159
$"7z a -bt -mx1 -mmt -mm=LZMA -r 7zLZMAFastestMode.7z C:\\users\\any\\tools\\VirtualClient\\packages\\7zip\\silesia\\*",
160160
$"7z a -bt -mx7 -mmt -mm=LZMA -r 7zLZMAMaximumMode.7z C:\\users\\any\\tools\\VirtualClient\\packages\\7zip\\silesia\\*",

src/VirtualClient/VirtualClient.Actions.FunctionalTests/Redis/RedisServerProfileTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace VirtualClient.Actions
88
using System.Linq;
99
using System.Net;
1010
using System.Runtime.InteropServices;
11+
using System.Text;
1112
using System.Threading;
1213
using System.Threading.Tasks;
1314
using Moq;
@@ -44,6 +45,24 @@ public void SetupFixture()
4445
[TestCase("PERF-REDIS.json")]
4546
public async Task RedisMemtierWorkloadProfileInstallsTheExpectedDependenciesOfServerOnUnixPlatform(string profile)
4647
{
48+
using var memoryProcess = new InMemoryProcess
49+
{
50+
StandardOutput = new ConcurrentBuffer(
51+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")),
52+
OnStart = () => true,
53+
OnHasExited = () => true
54+
};
55+
56+
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
57+
{
58+
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
59+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
60+
{
61+
return memoryProcess;
62+
}
63+
64+
return process;
65+
};
4766
using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
4867
{
4968
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None)
@@ -86,10 +105,21 @@ public async Task RedisMemtierWorkloadProfileExecutesTheWorkloadAsExpectedOfServ
86105
});
87106

88107
await apiClient.CreateStateAsync(nameof(ServerState), state, CancellationToken.None);
108+
using var memoryProcess = new InMemoryProcess
109+
{
110+
StandardOutput = new ConcurrentBuffer(
111+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")),
112+
OnStart = () => true,
113+
OnHasExited = () => true
114+
};
89115

90116
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
91117
{
92118
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
119+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
120+
{
121+
return memoryProcess;
122+
}
93123

94124
return process;
95125
};

src/VirtualClient/VirtualClient.Actions.UnitTests/Compressor7zip/Compressor7zipExecutorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public async Task Compressor7zipExecutorGetsDefaultFileIfInputFileOrDirNotProvid
8080
{ nameof(Compression7zipExecutor.PackageName), "7zip" },
8181
{ nameof(Compression7zipExecutor.Scenario), "mockScenario" }
8282
};
83-
string expectedCommand = $"wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip";
83+
string expectedCommand = $"wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip";
8484

8585
bool commandExecuted = false;
8686
this.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -172,7 +172,7 @@ public async Task Compressor7zipExecutorExecutesTheCorrectCommandsWithInstallati
172172
string mockPackagePath = this.mockPackage.Path;
173173
List<string> expectedCommands = new List<string>
174174
{
175-
$"wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
175+
$"wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
176176
$"unzip silesia.zip -d silesia",
177177
$"7z testOption1 testOption2 {this.PlatformSpecifics.Combine(mockPackagePath, "silesia/*")}"
178178
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[
2+
{
3+
"Name": "metric1",
4+
"Value": 0,
5+
"Unit": "unit1",
6+
"MetaData": {
7+
"metadata1": 0.1,
8+
"metadata2": "m2"
9+
}
10+
},
11+
{
12+
"Name": "metric2",
13+
"Value": -1,
14+
"Unit": "unit2",
15+
"MetaData": {
16+
"metadata1": "m3",
17+
"metadata2": true
18+
}
19+
},
20+
{
21+
"Name": "metric3",
22+
"Value": 1.2,
23+
"Unit": "unit3",
24+
"MetaData": {
25+
"metadata1": "m5",
26+
"metadata2": -2
27+
}
28+
},
29+
{
30+
"Name": "metric4",
31+
"Value": 1.0,
32+
"MetaData": {
33+
"metadata1": "m7",
34+
"metadata2": "m8"
35+
}
36+
},
37+
{
38+
"Name": "metric5",
39+
"Value": "1.24",
40+
"Unit": "unit5"
41+
},
42+
{
43+
"Name": "metric6",
44+
"Value": "-5.8"
45+
}
46+
]

src/VirtualClient/VirtualClient.Actions.UnitTests/Gzip/GzipExecutorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public async Task GzipExecutorGetsDefaultFileIfInputFileOrDirNotProvided()
8888
{ nameof(GzipExecutor.PackageName), "gzip" },
8989
{ nameof(GzipExecutor.Scenario), "mockScenario" }
9090
};
91-
string expectedCommand = $"sudo wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip";
91+
string expectedCommand = $"sudo wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip";
9292

9393
bool commandExecuted = false;
9494
this.mockFixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -180,7 +180,7 @@ public async Task GzipExecutorExecutesTheCorrectCommandsWithInstallationIfInputF
180180
string mockPackagePath = this.mockPackage.Path;
181181
List<string> expectedCommands = new List<string>
182182
{
183-
$"sudo wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
183+
$"sudo wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
184184
$"sudo unzip silesia.zip -d silesia",
185185
$"sudo bash -c \"gzip testOption1 testOption2 {this.mockFixture.PlatformSpecifics.Combine(mockPackagePath, "silesia")}\""
186186
};

src/VirtualClient/VirtualClient.Actions.UnitTests/Hpcg/HpcgExecutorTests.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33

44
namespace VirtualClient.Actions
55
{
6+
using Microsoft.Azure.Amqp.Framing;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
9+
using Moq;
10+
using Newtonsoft.Json;
11+
using Newtonsoft.Json.Linq;
12+
using NUnit.Framework;
613
using System;
14+
using System.Collections;
715
using System.Collections.Generic;
816
using System.Diagnostics;
917
using System.IO;
1018
using System.Linq;
19+
using System.Runtime.Intrinsics.X86;
1120
using System.Threading;
1221
using System.Threading.Tasks;
13-
using Microsoft.Extensions.DependencyInjection;
14-
using Moq;
15-
using Newtonsoft.Json;
16-
using Newtonsoft.Json.Linq;
17-
using NUnit.Framework;
18-
using VirtualClient.Contracts;
22+
using VirtualClient.Common.Contracts;
1923
using VirtualClient.Common.Extensions;
2024
using VirtualClient.Common.Telemetry;
21-
using VirtualClient.Common.Contracts;
25+
using VirtualClient.Contracts;
2226

2327
[TestFixture]
2428
[Category("Unit")]
@@ -176,8 +180,12 @@ public async Task HpcgExecutorWritesExpectedRunShellFile()
176180
.Returns(false)
177181
.Returns(true);
178182

183+
179184
string expectedFile = $". {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit/share/spack/setup-env.sh" + Environment.NewLine
180-
+ "spack install --reuse -n -y hpcg@9.8 %gcc +openmp ^openmpi@6.66.666" + Environment.NewLine
185+
+ $"mkdir -p {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit/opt/spack/.spack-db" + Environment.NewLine
186+
+ $"sudo chown -R $(whoami):$(whoami) {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit" + Environment.NewLine
187+
+ $"chmod -R u+rwx {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit" + Environment.NewLine
188+
+ "spack install --reuse -n -y hpcg@9.8 %gcc ^openmpi@6.66.666" + Environment.NewLine
181189
+ $"spack load hpcg@9.8 %gcc ^openmpi@6.66.666" + Environment.NewLine
182190
+ $"mpirun --np 7 --use-hwthread-cpus --allow-run-as-root xhpcg";
183191

src/VirtualClient/VirtualClient.Actions.UnitTests/Pbzip2/Pzip2ExecutorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public async Task Pbzip2ExecutorGetsDefaultFileIfInputFileOrDirNotProvided()
8787
{ nameof(Pbzip2Executor.PackageName), "pbzip2" },
8888
{ nameof(Pbzip2Executor.Scenario), "mockScenario" }
8989
};
90-
string expectedCommand = $"sudo wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip";
90+
string expectedCommand = $"sudo wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip";
9191

9292
bool commandExecuted = false;
9393
this.mockFixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -179,7 +179,7 @@ public async Task Pbzip2ExecutorExecutesTheCorrectCommandsWithInstallationIfInpu
179179
string mockPackagePath = this.mockPackage.Path;
180180
List<string> expectedCommands = new List<string>
181181
{
182-
$"sudo wget https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
182+
$"sudo wget --no-check-certificate https://sun.aei.polsl.pl//~sdeor/corpus/silesia.zip",
183183
$"sudo unzip silesia.zip -d silesia",
184184
$"sudo bash -c \"pbzip2 testOption1 testOption2 {this.mockFixture.PlatformSpecifics.Combine(mockPackagePath, "silesia/*")}\""
185185
};

src/VirtualClient/VirtualClient.Actions.UnitTests/Redis/RedisServerExecutorTests.cs

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ namespace VirtualClient.Actions
55
{
66
using System;
77
using System.Collections.Generic;
8+
using System.Linq;
89
using System.Net;
10+
using System.Text;
911
using System.Threading;
1012
using System.Threading.Tasks;
1113
using Microsoft.Extensions.DependencyInjection;
1214
using Moq;
1315
using NUnit.Framework;
1416
using VirtualClient.Actions.Memtier;
17+
using VirtualClient.Common;
1518
using VirtualClient.Common.Telemetry;
1619
using VirtualClient.Contracts;
1720

@@ -21,13 +24,19 @@ public class RedisServerExecutorTests
2124
{
2225
private MockFixture fixture;
2326
private DependencyPath mockRedisPackage;
27+
private InMemoryProcess memoryProcess;
2428

2529
[SetUp]
2630
public void SetupTests()
2731
{
2832
this.fixture = new MockFixture();
2933
this.fixture.Setup(PlatformID.Unix);
30-
34+
this.memoryProcess = new InMemoryProcess
35+
{
36+
ExitCode = 0,
37+
OnStart = () => true,
38+
OnHasExited = () => true
39+
};
3140
this.mockRedisPackage = new DependencyPath("redis", this.fixture.GetPackagePath("redis"));
3241

3342
this.fixture.Parameters = new Dictionary<string, IConvertible>()
@@ -62,6 +71,17 @@ public async Task RedisServerExecutorConfirmsTheExpectedPackagesOnInitialization
6271
{
6372
using (var component = new TestRedisServerExecutor(this.fixture.Dependencies, this.fixture.Parameters))
6473
{
74+
this.fixture.ProcessManager.OnCreateProcess = (command, arguments, workingDirectory) =>
75+
{
76+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
77+
{
78+
this.memoryProcess.StandardOutput = new ConcurrentBuffer(
79+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")
80+
);
81+
return this.memoryProcess;
82+
}
83+
return this.memoryProcess;
84+
};
6585
await component.InitializeAsync(EventContext.None, CancellationToken.None);
6686
this.fixture.PackageManager.Verify(mgr => mgr.GetPackageAsync(this.mockRedisPackage.Name, It.IsAny<CancellationToken>()));
6787
}
@@ -83,6 +103,13 @@ public async Task RedisMemtierServerExecutorExecutesExpectedProcessWhenBindingTo
83103

84104
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDirectory) =>
85105
{
106+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
107+
{
108+
this.memoryProcess.StandardOutput = new ConcurrentBuffer(
109+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")
110+
);
111+
return this.memoryProcess;
112+
}
86113
expectedCommands.Remove($"{exe} {arguments}");
87114
return this.fixture.Process;
88115
};
@@ -113,6 +140,13 @@ public async Task RedisMemtierServerExecutorExecutesExpectedProcessWhenBindingTo
113140

114141
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDirectory) =>
115142
{
143+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
144+
{
145+
this.memoryProcess.StandardOutput = new ConcurrentBuffer(
146+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")
147+
);
148+
return this.memoryProcess;
149+
}
116150
expectedCommands.Remove($"{exe} {arguments}");
117151
return this.fixture.Process;
118152
};
@@ -140,6 +174,13 @@ public async Task RedisMemtierServerExecutorExecutesExpectedProcessWhenNotBindin
140174

141175
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDirectory) =>
142176
{
177+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
178+
{
179+
this.memoryProcess.StandardOutput = new ConcurrentBuffer(
180+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")
181+
);
182+
return this.memoryProcess;
183+
}
143184
expectedCommands.Remove($"{exe} {arguments}");
144185
return this.fixture.Process;
145186
};
@@ -149,6 +190,38 @@ public async Task RedisMemtierServerExecutorExecutesExpectedProcessWhenNotBindin
149190
}
150191
}
151192

193+
[Test]
194+
public async Task RedisServerExecutorCapturesRedisVersionSuccessfully()
195+
{
196+
using (var executor = new TestRedisServerExecutor(this.fixture.Dependencies, this.fixture.Parameters))
197+
{
198+
this.fixture.ProcessManager.OnCreateProcess = (command, arguments, workingDirectory) =>
199+
{
200+
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
201+
{
202+
this.memoryProcess.StandardOutput = new ConcurrentBuffer(
203+
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")
204+
);
205+
return this.memoryProcess;
206+
}
207+
return this.memoryProcess;
208+
};
209+
// Act
210+
await executor.InitializeAsync(EventContext.None, CancellationToken.None);
211+
// Assert
212+
var messages = this.fixture.Logger.MessagesLogged($"{nameof(TestRedisServerExecutor)}.RedisVersionCaptured");
213+
Assert.IsNotEmpty(messages, "Expected at least one log message indicating the Redis version was captured.");
214+
bool versionCapturedCorrectly = messages.Any(msg =>
215+
{
216+
var eventContext = msg.Item3 as EventContext;
217+
return eventContext != null &&
218+
eventContext.Properties.ContainsKey("redisVersion") &&
219+
eventContext.Properties["redisVersion"].ToString() == "7.0.15";
220+
});
221+
Assert.IsTrue(versionCapturedCorrectly, "The Redis version '7.0.15' was not captured correctly in the logs.");
222+
}
223+
}
224+
152225
private class TestRedisServerExecutor : RedisServerExecutor
153226
{
154227
public TestRedisServerExecutor(IServiceCollection services, IDictionary<string, IConvertible> parameters = null)

0 commit comments

Comments
 (0)