Skip to content
Closed
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
36 changes: 34 additions & 2 deletions sdks/csharp/examples~/regression-tests/client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
DbConnection db = null!;
uint waiting = 0;
var runComplete = false;
var mainPhaseScheduled = false;
var mainUnsubscribeStarted = false;
SubscriptionHandle? mainHandle = null;
uint testEventInsertCount = 0;
long viewPkIdCounter = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 10;
Expand Down Expand Up @@ -1621,10 +1623,28 @@ ProcedureCallbackResult<Result<ReturnStruct, string>> result
}
);

// The unsubscribe phase clears the subscribed cache.
// Start it only after the reducer and procedure callbacks above
// have finished validating rows in that cache.
mainPhaseScheduled = true;
}

void StartMainUnsubscribe()
{
if (mainUnsubscribeStarted)
{
return;
}
mainUnsubscribeStarted = true;

var handle =
mainHandle
?? throw new InvalidOperationException("Main subscription handle was not initialised.");

// Now unsubscribe and check that the unsubscribing is actually applied.
Log.Debug("Calling Unsubscribe");
waiting++;
mainHandle?.UnsubscribeThen(
handle.UnsubscribeThen(
(ctx) =>
{
Log.Debug("Received Unsubscribe");
Expand All @@ -1638,6 +1658,18 @@ ProcedureCallbackResult<Result<ReturnStruct, string>> result
RegressionTestHarness.RegisterUnhandledExceptionExitHandler();
db = RegressionTestHarness.ConnectToDatabase(HOST, DBNAME, OnConnected);
const int TIMEOUT = 20; // seconds;
RegressionTestHarness.FrameTickUntilComplete(db, () => runComplete && waiting == 0, TIMEOUT);
RegressionTestHarness.FrameTickUntilComplete(
db,
() =>
{
if (mainPhaseScheduled && !mainUnsubscribeStarted && waiting == 0)
{
StartMainUnsubscribe();
}

return runComplete && waiting == 0;
},
TIMEOUT
);
Log.Info("Success");
Environment.Exit(0);
Loading