# Description
`test-macOS-latest-Redundancy.Samples` was failing because the PubSub
demo process exited before emitting the expected failover marker,
causing both short-haul demo assertions to time out. This PR hardens the
test harness by isolating demo traffic from the default 4840 discovery
behavior in constrained CI networking.
- **Root-cause containment**
- Set `PUBSUB_ENDPOINT=opc.udp://127.0.0.1:4841` in
`SampleTestEnvironment.FastDemo` so short-haul demo tests run on a
dedicated loopback endpoint.
- Keep `HA_INSECURE=true` in the same preset to preserve demo startup
behavior.
- **Regression guard**
- Added
`SampleTestEnvironmentTests.FastDemoUsesLoopbackEndpointAndInsecureDemoKey`
to lock the test contract for both `PUBSUB_ENDPOINT` and `HA_INSECURE`.
- **Code snippet**
```csharp
public static IReadOnlyDictionary<string, string> FastDemo { get; } =
new Dictionary<string, string>(StringComparer.Ordinal)
{
["DEMO_FIRST_SECONDS"] = "1",
["DEMO_SECOND_SECONDS"] = "1",
["PUBSUB_ENDPOINT"] = "opc.udp://127.0.0.1:4841",
["HA_INSECURE"] = "true"
};
```
## Related Issues
CI check-run remediation for failing job
`test-macOS-latest-Redundancy.Samples` (job `96263875760`).
## Checklist
_Put an `x` in the boxes that apply. You can complete these step by step
after opening the PR._
- [ ] 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.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [ ] I have added all necessary documentation.
- [x] 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.
- [x] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
`PubSubDemoHotShowsFailoverContinuityAsync` and
`PubSubDemoColdShowsDataLossAsync` were timing out because the demo
process exited immediately — before printing the `FAILOVER:` line the
tests wait for.
**Root cause**: `SampleTestEnvironment.FastDemo` did not set
`HA_INSECURE=true`. Without it, `CreateRecordProtector` in
`RedundantPubSub/Program.cs` throws `InvalidOperationException` (neither
`HA_RECORD_KEY` nor `HA_INSECURE=true` was present in the child process
environment), terminating the process before any HA narrative output.
**Fix**:
- Added `["HA_INSECURE"] = "true"` to `SampleTestEnvironment.FastDemo`,
matching the same pattern already used in `RedundantServerCluster.cs`.
```csharp
public static IReadOnlyDictionary<string, string> FastDemo { get; } =
new Dictionary<string, string>(StringComparer.Ordinal)
{
["DEMO_FIRST_SECONDS"] = "1",
["DEMO_SECOND_SECONDS"] = "1",
["HA_INSECURE"] = "true" // ← added: prevents immediate InvalidOperationException
};
```
## Related Issues
## 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.
- [ ] 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.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>