Skip to content
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

Improve unit test sibhatia #187

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions FHTest/FHUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ public async Task DiskRules_DiskSpace_Percentage_Repair_Successful_Validate_Rule
{
// Create temp files.
// You can use whatever path you want, but you need to make sure that is also specified in the related test logic rule (service-fabric-healer\FHTest\PackageRoot\Config\LogicRules\DiskRules.guan).
byte[] bytes = Encoding.ASCII.GetBytes("foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz");
long targetSize = 2L * 1024 * 1024 * 1024; // 2GB in bytes
byte[] buffer = Encoding.UTF8.GetBytes("This is a line of text to be repeated in the file.\n");
long currentSize = 0;
string path = @"C:\FHTest\cluster_observer_logs";

if (!Directory.Exists(path))
Expand All @@ -562,11 +564,13 @@ public async Task DiskRules_DiskSpace_Percentage_Repair_Successful_Validate_Rule
// Create two 2GB files in target directory (path).
for (int i = 0; i < 2; i++)
{
using var f = File.Create(Path.Combine(path, $"foo{i}.txt"), 500000, FileOptions.WriteThrough);

for (int j = 0; j < 25000000; ++j)
using (FileStream fs = new(Path.Combine(path, $"foo{i}.txt"), FileMode.Create, FileAccess.Write, FileShare.None))
{
f.Write(bytes);
while (currentSize < targetSize)
{
fs.Write(buffer, 0, buffer.Length);
currentSize += buffer.Length;
}
}
}

Expand Down