Skip to content

Commit

Permalink
Improve unit test sibhatia (#187)
Browse files Browse the repository at this point in the history
* FH v1.2.14 and FHProxy v1.0.5 (#177)

* make inmemory events accesible to the plugins

* sample is consuming 1.2.13 version. so cant access the list yet

* Updated Guan package

* Guan version update in two more files (#175)

Co-authored-by: Sidhant Bhatia <[email protected]>

* New FH and FHProxy version and release notes (#176)

* FH v1.2.14

* FHProxy v1.0.5

* FH release notes

* Reverting sampleHealerPlugin FH version for codeQL

---------

Co-authored-by: Sidhant Bhatia <[email protected]>

---------

Co-authored-by: Naresh Kumar <[email protected]>
Co-authored-by: Sidhant Bhatia <[email protected]>

* improving flaky unit test

* nit

---------

Co-authored-by: Charles Torre <[email protected]>
Co-authored-by: Naresh Kumar <[email protected]>
Co-authored-by: Sidhant Bhatia <[email protected]>
  • Loading branch information
4 people authored Oct 30, 2024
1 parent 293b5e0 commit a80f202
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit a80f202

Please sign in to comment.