Skip to content

Commit

Permalink
Fix TestsManifestGeneration test again (#46928)
Browse files Browse the repository at this point in the history
* Add more sleeps after flush

* remove sleeps and add retry loop

* Fix build
  • Loading branch information
sywhang authored Jan 14, 2021
1 parent a1c4028 commit 3268d09
Showing 1 changed file with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,22 @@ public void Test_EventSource_EtwManifestGeneration()

tracesession.Flush();

// Sleep after requesting flush to ensure that the manifest payload generated
// is fully written to the etl file.
Thread.Sleep(TimeSpan.FromSeconds(5));

tracesession.DisableProvider("SimpleEventSource");
tracesession.Dispose();

Assert.True(VerifyManifestAndRemoveFile(etlFileName));
var manifestExists = false;
var max_retries = 50;

for (int i = 0; i < max_retries; i++)
{
if (VerifyManifestAndRemoveFile(etlFileName))
{
manifestExists = true;
break;
}
Thread.Sleep(1000);
}
Assert.True(manifestExists);
}
}).Dispose();
}
Expand All @@ -83,20 +91,17 @@ public void Test_EventSource_EtwManifestGenerationRollover()
}))
{
var initialFileName = @"initialFile.etl";
var rolloverFile = @"rolloverFile.etl";
var rolloverFileName = @"rolloverFile.etl";
var tracesession = new TraceEventSession("testname", initialFileName);
var max_retries = 50;

tracesession.EnableProvider("SimpleEventSource");

Thread.Sleep(TimeSpan.FromSeconds(5));

tracesession.Flush();

// Sleep after requesting flush to ensure that the manifest payload generated
// is fully written to the etl file.
Thread.Sleep(TimeSpan.FromSeconds(5));

tracesession.SetFileName(rolloverFile);
tracesession.SetFileName(rolloverFileName);

Thread.Sleep(TimeSpan.FromSeconds(5));

Expand All @@ -105,8 +110,29 @@ public void Test_EventSource_EtwManifestGenerationRollover()
tracesession.DisableProvider("SimpleEventSource");
tracesession.Dispose();

Assert.True(VerifyManifestAndRemoveFile(initialFileName));
Assert.True(VerifyManifestAndRemoveFile(rolloverFile));
bool initialFileHasManifest = false;
bool rollOverFileHasManifest = false;

for (int i = 0; i < max_retries; i++)
{
if (VerifyManifestAndRemoveFile(initialFileName))
{
initialFileHasManifest = true;
break;
}
Thread.Sleep(1000);
}
for (int i = 0; i < max_retries; i++)
{
if (VerifyManifestAndRemoveFile(rolloverFileName))
{
rollOverFileHasManifest = true;
break;
}
Thread.Sleep(1000);
}
Assert.True(initialFileHasManifest);
Assert.True(rollOverFileHasManifest);
}
}).Dispose();
}
Expand Down

0 comments on commit 3268d09

Please sign in to comment.