mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-29 15:11:53 +08:00
# Description Since the move to GitHub Actions, CI replays only the checked-in fuzz corpus. The full crash corpus used to be the Azure DevOps secure file `FuzzingArtifacts.zip`, which `.azurepipelines/test.yml` overlaid onto `Opc.Ua.Encoders.Fuzz.Tests`. The nightly `private-corpus` job that was meant to replace it depended on an Azure storage account, federated credentials and a protected environment. None of these were ever provisioned, so the job never ran. **The corpus now lives on the orphan branch [`fuzz-corpus`](https://github.com/OPCFoundation/UA-.NETStandard/tree/fuzz-corpus)** (commit `843ba944a7b144a7ae6429151846d9e5ab28d29f`, already pushed): - It contains 22,267 `crash-*`, 25 `slow-unit-*` and 1 `timeout-*` input under `Opc.Ua.Encoders.Fuzz.Tests/Assets/`. - The files are byte-identical to the secure file (SHA-256 `85198e46…fe1d61b`), recovered from the `drop` artifact of Azure build 18397. - The branch shares no history with `master`, so clones of `master` don't get 22k extra files in their checkout. **Why the corpus is no longer treated as private:** - The inputs date from April–June 2024. - The `drop` artifacts could be downloaded anonymously. - Every master build printed up to about 7k base64 reproducers into anonymously readable Azure logs. - Current `master` replays every input without a test failure. New, unfixed crashes still go through [SECURITY.md](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/SECURITY.md) and are added to the branch only after the fix ships. ## Changes - **`nightly.yml`:** `private-corpus` is replaced by `crash-corpus`. The new job: - checks out the commit pinned in `FUZZ_CORPUS_COMMIT` (no secrets, environment or OIDC); - verifies the SHA and copies each top-level folder over `fuzzing/<folder>`; - runs `Opc.Ua.Encoders.Fuzz.Tests` on the 12 non-macOS profiles through the shared `run-dotnet-tests` action and uploads `crash-corpus-results-*`. The `run_private_corpus` input and the INCOMPLETE label are removed. The job runs on every scheduled and manual run, and the nightly summary fails if it was skipped. - **`fuzzing/CrashCorpus.md` (new):** the Azure history, branch layout, how CI replays the corpus, local replay, and how to add inputs and move the pin. `Fuzzing.md` links to it. - **`docs/DeveloperGuide.md`:** the private-corpus section and its secrets table are replaced, and the migration to-do list is updated. - **`nightly.yml` AOT job (fix for a failure found by the first nightly run):** the Linux and macOS legs looked up the published binary by `BaseName`/`Extension`. A NativeAOT executable has no extension on those platforms, so PowerShell splits `Opc.Ua.Aot.Tests` into `Opc.Ua.Aot` + `.Tests`, and every leg reported *No NativeAOT executable was produced* even though publish succeeded ([run 36017168717](https://github.com/OPCFoundation/UA-.NETStandard/actions/runs/36017168717), `aot-ubuntu-latest`). The lookup now matches the exact file name. A failure now reports the publish errors, a missing publish directory, or which files were produced instead. - **`Opc.Ua.Redundancy.Samples.Tests` / `Opc.Ua.WotCon.Samples.Tests` (fix for failures found by the first nightly run):** the test runner's framework guard rejected both projects on the nightly net8.0, net9.0, net472 and netstandard2.1 profiles. Redundancy built a net48 placeholder for every target except net10.0, and WotCon was pinned to net10.0. Both now build the requested target on net8.0/9.0/10.0 and use `RestrictForLegacyTfm` to become explicit not-applicable shells on net48, net472, netstandard2.0 and netstandard2.1. The redundancy tests no longer hard-code `bin/<cfg>/net10.0` when locating the sample binaries, and `SampleAppProcess` falls back to an `object` lock below net9.0. The net48 placeholder remains for Azure's plain `dotnet test -f net48` leg. Checked locally by building Redundancy for `CustomTestTarget=net9.0` and WotCon for `netstandard2.1`. - **`DefaultServerRedundancyHandler` (fix for a failure found by the first nightly run):** `ResolveServerAsync` gave the resolver a token linked to the caller's, but waited on the caller's token directly. On cancellation the wait could finish, and its `using` could dispose the linked source, before the linked source's own callback had run. That unhooks it, so the in-flight peer lookup never saw the cancellation (`PeerDiscoveryPropagatesCallerCancellationAsync`, netstandard2.0 build on net48). The wait now uses the linked token. A timeout is still logged as a discovery failure, as before. A companion test fix makes `PeerTimeoutPreservesOtherEndpointsAndCoalescesPendingDiscoveryAsync(False)` deterministic. The timed-out lookup drains on the thread pool, so the test's retry could join it and then have its own time limit expire before it started a fresh lookup. The test now waits for the second resolver call before advancing the fake clock. - **`Session` keep-alive logging (found while investigating the net48 nightly failures):** `OnKeepAliveError` and the keep-alive read failure log used `Endpoint?.EndpointUrl`. `ClientBase.Endpoint` dereferences the transport channel, so once the channel was detached it threw a `NullReferenceException` on every keep-alive tick, and `BadNoCommunication` never reached the `KeepAlive` subscribers. Both now log the configured endpoint's URL. Three new `SessionKeepAliveTests` cover a detached channel. - **`ClientTestFramework` shared session (fix for 67 `Opc.Ua.Sessions.Tests` failures on the net48 nightly):** the fixture-wide shared session used the 10 s default session timeout. A test-host stall of about 11–18 s while other fixtures restarted their servers let the server expire it, and every later test in the `ClientTest("https")` and `ClientTest("opc.https")` fixtures failed with `BadSessionIdInvalid`. The shared session now requests `SharedSessionTimeout` = 120 s; per-test sessions keep 10 s. - **`run-dotnet-tests.ps1`:** `-QuietOutput` help text only; it no longer names the removed job. The Azure secure file stays in place, because `master378` and the 1.x release pipelines keep their own `test.yml` and still use it. ## Verification - `nightly.yml` parses as valid YAML, and no job, output or summary field still refers to the removed job. - I ran the job's overlay script against a clone of `fuzz-corpus` at the pinned commit. It overlaid all 22,293 files, left the tracked `Assets/Repo` untouched, removed the checkout folder and wrote the summary line. - **Not yet run:** the workflow itself. It is `schedule`/`workflow_dispatch` only, so it needs a manual `nightly.yml` run on this branch. On master the corpus has so far only been replayed on Windows (net48/net10.0 in Azure), so the Linux legs are new ground. ## Follow-ups (admin) - Add a ruleset for `fuzz-corpus`: require pull requests and block force pushes and deletion, so the pinned commit stays reachable. - The `fuzz-private-corpus` environment, if it was ever created, can be deleted. ## Related Issues - No issue exists yet; this is part of the Azure DevOps → GitHub Actions migration (#4513, #4524). ## Checklist - [ ] I have signed the [CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf) and read the [CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md) doc. - [ ] I have added tests that prove my fix is effective or that my feature works and increased code coverage. - [x] I have added all necessary documentation. - [ ] I have verified that my changes do not introduce (new) build or analyzer warnings. - [ ] I ran **all** tests locally using the **UA.slnx** solution against at least .net **framework** and .net **10**, and all passed. - [ ] I fixed **all** failing and flaky tests in the CI pipelines and **all** CodeQL warnings. - [ ] I have addressed **all** PR feedback received. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
436 lines
17 KiB
C#
436 lines
17 KiB
C#
/* ========================================================================
|
|
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
|
|
*
|
|
* OPC Foundation MIT License 1.00
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following
|
|
* conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* The complete license agreement can be found here:
|
|
* http://opcfoundation.org/License/MIT/1.00/
|
|
* ======================================================================*/
|
|
|
|
#nullable enable
|
|
|
|
using System;
|
|
using Microsoft.Extensions.Time.Testing;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using Opc.Ua.Tests;
|
|
|
|
#pragma warning disable CA2000, CA2007
|
|
|
|
namespace Opc.Ua.Client.Tests
|
|
{
|
|
/// <summary>
|
|
/// Tests for the keep alive liveness bookkeeping of <see cref="Session"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Regression coverage for
|
|
/// https://github.com/OPCFoundation/UA-.NETStandard/issues/4317:
|
|
/// <see cref="Session.RequestCompleted"/> defers the keep alive read on every
|
|
/// good service response, so under steady request traffic the read never
|
|
/// fires. The freshness timestamp <see cref="Session.KeepAliveStopped"/> is
|
|
/// judged against therefore has to be refreshed by those responses as well,
|
|
/// otherwise the first pause in traffic reports BadNoCommunication on a
|
|
/// perfectly healthy session.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
[Parallelizable]
|
|
[Category("Client")]
|
|
[Category("Session")]
|
|
[Category("KeepAlive")]
|
|
public sealed class SessionKeepAliveTests
|
|
{
|
|
private const int kKeepAliveInterval = 5_000;
|
|
|
|
/// <summary>
|
|
/// KeepAliveInterval * m_keepAliveIntervalFactor (1) + m_keepAliveGuardBand (1000).
|
|
/// </summary>
|
|
private static readonly TimeSpan s_pastKeepAliveThreshold =
|
|
TimeSpan.FromMilliseconds(kKeepAliveInterval + 1_000 + 1);
|
|
|
|
[Test]
|
|
public void KeepAliveStoppedTripsWhenNothingIsHeardFromTheServer()
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
|
|
Assert.That(session.KeepAliveStopped, Is.False);
|
|
|
|
timeProvider.Advance(s_pastKeepAliveThreshold);
|
|
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Steady traffic keeps the session alive even though the keep alive read
|
|
/// is deferred by every response and consequently never fires.
|
|
/// </summary>
|
|
[Test]
|
|
public void GoodResponsesKeepTheSessionAliveWhileTheKeepAliveReadIsDeferred()
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
|
|
long initialTimestamp = session.LastKeepAliveTimestamp;
|
|
|
|
// a request every 2 s for 20 s - each response defers the keep alive
|
|
// read by a full interval, so no keep alive read is ever sent.
|
|
for (int ii = 0; ii < 10; ii++)
|
|
{
|
|
timeProvider.Advance(TimeSpan.FromSeconds(2));
|
|
session.CompleteRequest(StatusCodes.Good);
|
|
|
|
Assert.That(
|
|
session.KeepAliveStopped,
|
|
Is.False,
|
|
$"the server answered 2000 ms ago (iteration {ii})");
|
|
}
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(session.KeepAliveStopped, Is.False);
|
|
Assert.That(session.LastKeepAliveTimestamp, Is.GreaterThan(initialTimestamp));
|
|
});
|
|
|
|
// once the traffic stops the session must still detect the silence.
|
|
timeProvider.Advance(s_pastKeepAliveThreshold);
|
|
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A good response also revives a timestamp that already went stale but
|
|
/// has not been reported as an error yet - the keep alive read is still
|
|
/// in flight, the worker is skipping while reconnecting, or its tick is
|
|
/// late. Without this no traffic could rescue the session from the
|
|
/// spurious BadNoCommunication the worker is about to raise.
|
|
/// </summary>
|
|
[Test]
|
|
public void GoodResponseRevivesAStaleTimestampWhenNoErrorIsLatched()
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
|
|
timeProvider.Advance(s_pastKeepAliveThreshold);
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
|
|
session.CompleteRequest(StatusCodes.Good);
|
|
|
|
Assert.That(
|
|
session.KeepAliveStopped,
|
|
Is.False,
|
|
"a good response must count as proof of liveness");
|
|
}
|
|
|
|
[Test]
|
|
public void BadResponsesDoNotRefreshTheKeepAliveTimestamp()
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
|
|
long initialTimestamp = session.LastKeepAliveTimestamp;
|
|
|
|
timeProvider.Advance(TimeSpan.FromMilliseconds(3_000));
|
|
session.CompleteRequest(StatusCodes.BadTimeout);
|
|
|
|
Assert.That(session.LastKeepAliveTimestamp, Is.EqualTo(initialTimestamp));
|
|
|
|
timeProvider.Advance(s_pastKeepAliveThreshold - TimeSpan.FromMilliseconds(3_000));
|
|
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A latched keep alive error is only cleared by an actual keep alive
|
|
/// response, never by unrelated traffic.
|
|
/// </summary>
|
|
[Test]
|
|
public void LatchedKeepAliveErrorIsNotClearedByAGoodResponse()
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
|
|
session.RaiseKeepAliveError(StatusCodes.BadTimeout);
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
|
|
session.CompleteRequest(StatusCodes.Good);
|
|
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
}
|
|
|
|
/// <summary>
|
|
/// After BadNoCommunication was reported the recovery branch of
|
|
/// OnKeepAlive must still run, i.e. good responses arriving before the
|
|
/// keep alive read completes must not silently mark the session as
|
|
/// healthy again.
|
|
/// </summary>
|
|
[Test]
|
|
public void RecoveryAfterBadNoCommunicationIsHandledByTheKeepAliveResponse()
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
|
|
timeProvider.Advance(s_pastKeepAliveThreshold);
|
|
session.RaiseKeepAliveError(StatusCodes.BadNoCommunication);
|
|
|
|
// the keep alive read itself completes as a good response first.
|
|
session.CompleteRequest(StatusCodes.Good);
|
|
Assert.That(
|
|
session.KeepAliveStopped,
|
|
Is.True,
|
|
"the keep alive error must survive until OnKeepAlive handled it");
|
|
|
|
session.RaiseKeepAlive();
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(
|
|
session.KeepAliveStoppedOnEnteringOnKeepAlive,
|
|
Is.True,
|
|
"OnKeepAlive must take the recovery branch");
|
|
Assert.That(session.KeepAliveStopped, Is.False);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// Once the transport channel is detached the keep alive read fails with
|
|
/// BadSecureChannelClosed, which the keep alive worker reports through
|
|
/// OnKeepAliveError, and the next tick reports BadNoCommunication.
|
|
/// Neither report may dereference the missing channel: the endpoint url
|
|
/// in the log comes from the configured endpoint, not from the channel.
|
|
/// </summary>
|
|
[Test]
|
|
public void KeepAliveReadFailureIsReportedAfterTheChannelIsDetached()
|
|
{
|
|
AssertKeepAliveErrorIsReportedAfterTheChannelIsDetached(
|
|
StatusCodes.BadSecureChannelClosed);
|
|
}
|
|
|
|
/// <summary>
|
|
/// See <see cref="KeepAliveReadFailureIsReportedAfterTheChannelIsDetached"/>;
|
|
/// BadNoCommunication additionally logs KEEP ALIVE LATE with the endpoint url.
|
|
/// </summary>
|
|
[Test]
|
|
public void KeepAliveLateIsReportedAfterTheChannelIsDetached()
|
|
{
|
|
AssertKeepAliveErrorIsReportedAfterTheChannelIsDetached(
|
|
StatusCodes.BadNoCommunication);
|
|
}
|
|
|
|
private static void AssertKeepAliveErrorIsReportedAfterTheChannelIsDetached(
|
|
StatusCode statusCode)
|
|
{
|
|
var timeProvider = new FakeTimeProvider();
|
|
using KeepAliveTestSession session = CreateSession(timeProvider);
|
|
StatusCode reported = StatusCodes.Good;
|
|
session.KeepAlive += (_, e) => reported = e.Status?.StatusCode ?? StatusCodes.Good;
|
|
|
|
#pragma warning disable CS0618 // DetachChannel is obsolete
|
|
session.DetachChannel();
|
|
#pragma warning restore CS0618
|
|
|
|
timeProvider.Advance(s_pastKeepAliveThreshold);
|
|
Assert.DoesNotThrow(() => session.RaiseKeepAliveError(statusCode));
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(reported, Is.EqualTo(statusCode));
|
|
Assert.That(session.KeepAliveStopped, Is.True);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// The keep alive read on a detached channel fails with a service error
|
|
/// the keep alive worker handles, not with an unexpected exception.
|
|
/// </summary>
|
|
[Test]
|
|
public void KeepAliveReadAfterTheChannelIsDetachedFailsWithBadSecureChannelClosed()
|
|
{
|
|
using KeepAliveTestSession session = CreateSession(new FakeTimeProvider());
|
|
|
|
#pragma warning disable CS0618 // DetachChannel is obsolete
|
|
session.DetachChannel();
|
|
#pragma warning restore CS0618
|
|
|
|
ServiceResultException sre = Assert.ThrowsAsync<ServiceResultException>(
|
|
async () => await session.ReadAsync(
|
|
new RequestHeader(),
|
|
0,
|
|
TimestampsToReturn.Neither,
|
|
new[]
|
|
{
|
|
new ReadValueId
|
|
{
|
|
NodeId = VariableIds.Server_ServerStatus_State,
|
|
AttributeId = Attributes.Value
|
|
}
|
|
}.ToArrayOf(),
|
|
default).ConfigureAwait(false));
|
|
|
|
Assert.That(sre.StatusCode, Is.EqualTo(StatusCodes.BadSecureChannelClosed));
|
|
}
|
|
|
|
private static KeepAliveTestSession CreateSession(TimeProvider timeProvider)
|
|
{
|
|
ITelemetryContext telemetry = NUnitTelemetryContext.Create();
|
|
ApplicationConfiguration configuration = CreateClientConfiguration(telemetry);
|
|
IServiceMessageContext messageContext = configuration.CreateMessageContext();
|
|
var channel = new Mock<ITransportChannel>();
|
|
channel.SetupGet(c => c.MessageContext).Returns(messageContext);
|
|
|
|
var session = new KeepAliveTestSession(
|
|
channel.Object,
|
|
configuration,
|
|
CreateEndpoint(),
|
|
timeProvider)
|
|
{
|
|
KeepAliveInterval = kKeepAliveInterval
|
|
};
|
|
|
|
// establish the initial liveness baseline the keep alive timer start
|
|
// would normally provide, then forget what that call observed.
|
|
session.RaiseKeepAlive();
|
|
session.ResetKeepAliveObservation();
|
|
|
|
return session;
|
|
}
|
|
|
|
private static ApplicationConfiguration CreateClientConfiguration(
|
|
ITelemetryContext telemetry)
|
|
{
|
|
return new ApplicationConfiguration(telemetry)
|
|
{
|
|
ApplicationName = "SessionKeepAliveTests",
|
|
ApplicationType = ApplicationType.Client,
|
|
ApplicationUri = "urn:localhost:SessionKeepAliveTests",
|
|
ProductUri = "urn:localhost:SessionKeepAliveTests",
|
|
ClientConfiguration = new ClientConfiguration
|
|
{
|
|
DefaultSessionTimeout = 60000,
|
|
MinSubscriptionLifetime = 10000
|
|
},
|
|
SecurityConfiguration = new SecurityConfiguration
|
|
{
|
|
ApplicationCertificate = new CertificateIdentifier()
|
|
},
|
|
TransportQuotas = new TransportQuotas { OperationTimeout = 6000 }
|
|
};
|
|
}
|
|
|
|
private static ConfiguredEndpoint CreateEndpoint()
|
|
{
|
|
var description = new EndpointDescription
|
|
{
|
|
EndpointUrl = "opc.tcp://localhost:4840",
|
|
SecurityMode = MessageSecurityMode.None,
|
|
SecurityPolicyUri = SecurityPolicies.None,
|
|
TransportProfileUri = Profiles.UaTcpTransport,
|
|
UserIdentityTokens =
|
|
[
|
|
new UserTokenPolicy
|
|
{
|
|
PolicyId = "anonymous",
|
|
TokenType = UserTokenType.Anonymous,
|
|
SecurityPolicyUri = SecurityPolicies.None
|
|
}
|
|
]
|
|
};
|
|
description.Server.ApplicationUri = description.EndpointUrl;
|
|
description.Server.ApplicationType = ApplicationType.Server;
|
|
|
|
return new ConfiguredEndpoint(
|
|
null,
|
|
description,
|
|
new EndpointConfiguration { OperationTimeout = 6000 })
|
|
{
|
|
UpdateBeforeConnect = false
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exposes the protected keep alive hooks so the handling of service
|
|
/// responses can be driven without a server.
|
|
/// </summary>
|
|
private sealed class KeepAliveTestSession : Session
|
|
{
|
|
public KeepAliveTestSession(
|
|
ITransportChannel channel,
|
|
ApplicationConfiguration configuration,
|
|
ConfiguredEndpoint endpoint,
|
|
TimeProvider timeProvider)
|
|
: base(channel, configuration, endpoint, timeProvider: timeProvider)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// The value of <see cref="Session.KeepAliveStopped"/> observed when
|
|
/// <see cref="OnKeepAlive"/> was entered the last time.
|
|
/// </summary>
|
|
public bool? KeepAliveStoppedOnEnteringOnKeepAlive { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Discards what <see cref="OnKeepAlive"/> observed so far.
|
|
/// </summary>
|
|
public void ResetKeepAliveObservation()
|
|
{
|
|
KeepAliveStoppedOnEnteringOnKeepAlive = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Simulates a completed service call with the given service result.
|
|
/// </summary>
|
|
public void CompleteRequest(StatusCode serviceResult)
|
|
{
|
|
RequestCompleted(
|
|
new ReadRequest { RequestHeader = new RequestHeader() },
|
|
new ReadResponse
|
|
{
|
|
ResponseHeader = new ResponseHeader { ServiceResult = serviceResult }
|
|
},
|
|
nameof(Read));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Simulates a successful keep alive read response.
|
|
/// </summary>
|
|
public void RaiseKeepAlive()
|
|
{
|
|
OnKeepAlive(ServerState.Running, DateTime.UtcNow);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Simulates a failed keep alive read.
|
|
/// </summary>
|
|
public void RaiseKeepAliveError(StatusCode statusCode)
|
|
{
|
|
OnKeepAliveError(new ServiceResult(statusCode));
|
|
}
|
|
|
|
protected override void OnKeepAlive(ServerState currentState, DateTime currentTime)
|
|
{
|
|
KeepAliveStoppedOnEnteringOnKeepAlive = KeepAliveStopped;
|
|
base.OnKeepAlive(currentState, currentTime);
|
|
}
|
|
}
|
|
}
|
|
}
|