Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,102 @@ public void DiskSpdWorkloadProfileActionsWillNotBeExecutedIfTheWorkloadPackageDo
}
}

[Test]
[TestCase("PERF-IO-DISKSPD-PHYSICAL-DISK.json")]
public void DiskSpdRawDiskWorkloadProfileParametersAreInlinedCorrectly(string profile)
{
this.mockFixture.Setup(PlatformID.Win32NT);
using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
WorkloadAssert.ParameterReferencesInlined(executor.Profile);
}
}

[Test]
[TestCase("PERF-IO-DISKSPD-PHYSICAL-DISK.json")]
public async Task DiskSpdRawDiskWorkloadProfileInstallsTheExpectedDependenciesOnWindowsPlatform(string profile)
{
// Raw disk profiles do not require disk formatting — disks are accessed directly at the raw block level.
this.mockFixture.Setup(PlatformID.Win32NT);

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies, dependenciesOnly: true))
{
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None).ConfigureAwait(false);

// Workload dependency package expectations
// The workload dependency package should have been installed at this point.
WorkloadAssert.WorkloadPackageInstalled(this.mockFixture, "diskspd");
}
}

[Test]
[TestCase("PERF-IO-DISKSPD-PHYSICAL-DISK.json")]
public async Task DiskSpdRawDiskWorkloadProfileExecutesTheExpectedWorkloadsOnWindowsPlatform(string profile)
{
IEnumerable<string> expectedCommands = DiskSpdProfileTests.GetDiskSpdRawDiskProfileExpectedCommands();

// Setup the expectations for the workload
// - Workload package is installed and exists.
// - Workload binaries/executables exist on the file system.
// - Raw disk discovery returns 2 HDD disks (indices 6 and 7).
// - The workload generates valid results.
this.mockFixture.Setup(PlatformID.Win32NT);
this.mockFixture.SetupPackage("diskspd", expectedFiles: $@"win-x64\diskspd.exe");

this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
{
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
if (arguments.Contains("Get-PhysicalDisk", StringComparison.OrdinalIgnoreCase))
{
// Simulate discovery of 2 HDD raw disks (indices 6 and 7)
process.StandardOutput.Append("6\r\n7");
}
else if (arguments.Contains("diskspd", StringComparison.OrdinalIgnoreCase))
{
process.StandardOutput.Append(TestDependencies.GetResourceFileContents("Results_DiskSpd.txt"));
}

return process;
};

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None).ConfigureAwait(false);

WorkloadAssert.CommandsExecuted(this.mockFixture, expectedCommands.ToArray());
}
}

[Test]
[TestCase("PERF-IO-DISKSPD-PHYSICAL-DISK.json")]
public void DiskSpdRawDiskWorkloadProfileActionsWillNotBeExecutedIfWorkloadPackageDoesNotExist(string profile)
{
this.mockFixture.Setup(PlatformID.Win32NT);

// We ensure the workload package does not exist.
this.mockFixture.PackageManager.Clear();

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
executor.ExecuteDependencies = false;

DependencyException error = Assert.ThrowsAsync<DependencyException>(() => executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None));
Assert.AreEqual(ErrorReason.WorkloadDependencyMissing, error.Reason);
Assert.IsFalse(this.mockFixture.ProcessManager.Commands.Contains("diskspd.exe"));
}
}

private static IEnumerable<string> GetDiskSpdRawDiskProfileExpectedCommands()
{
return new List<string>
{
// ProcessModel=SingleProcessPerDisk: one diskspd process per discovered raw disk.
// Duration=00:01:00 -> 60 seconds; disks #6 and #7 discovered via Get-PhysicalDisk.
@"-b128K -d60 -o32 -t1 -r -w0 -Sh -L -Rtext #6",
@"-b128K -d60 -o32 -t1 -r -w0 -Sh -L -Rtext #7"
};
}

private static IEnumerable<string> GetDiskSpdStressProfileExpectedCommands()
{
return new List<string>
Expand Down
Loading