private bool DoKeepAliveTest()
{
// follow tree from each starting node.
bool success = true;
Log("Starting KeepAliveTest. PipelineDepth = {0}, OutstandingRequests = {1}", m_publishPipelineDepth, m_outstandingPublishRequests);
double increment = MaxProgress/8;
double position = 0;
ReportProgress(position);
// create subscription.
Interlocked.Exchange(ref m_publishCount, 0);
Interlocked.Exchange(ref m_stopped, 0);
for (int ii = 1000; ii <= 10000; ii += 1000)
{
try
{
CreateSubscription(
ii,
(uint)(60000/ii),
2,
0,
true,
0);
}
catch (Exception e)
{
success = false;
Log(e, "KeepAliveTest Failed while creating subsciptions.");
}
}
position += increment;
ReportProgress(position);
Log("Created {0} subscriptions.", m_subscriptions.Count);
m_errorEvent.Reset();
bool publishingEnabled = true;
for (int ii = 0; ii < 6; ii++)
{
if (m_errorEvent.WaitOne(5000, false))
{
success = false;
Log("KeepAliveTest exiting because of an error during publishing.", null);
break;
}
Log("{0} publish responses received. Publishing Enabled = {1}", m_publishCount, publishingEnabled);
// toggle publishing enabled.
publishingEnabled = !publishingEnabled;
if (!SetPublishingEnabled(publishingEnabled))
{
success = false;
break;
}
position += increment;
ReportProgress(position);
}
// delete.
if (!DeleteSubscriptions())
{
success = false;
}
// stop publish threads.
Interlocked.CompareExchange(ref m_stopped, 1, 0);
Log("Deleted subscriptions.");
// verify test results.
lock (m_subscriptions)
{
if (success)
{
for (int ii = 0; ii < m_subscriptions.Count; ii++)
{
Subscription subscription = m_subscriptions[ii];
lock (subscription)
{
if (!VerifyKeepAliveTestResults(subscription))
{
success = false;
}
}
}
}
m_subscriptions.Clear();
}
position += increment;
ReportProgress(position);
return success;
}