Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Repeat race exploration corpus
run: |
for iteration in 1 2 3; do
dotnet run --project tests/Clockwork.Runtime.Tests/Clockwork.Runtime.Tests.csproj --configuration Release --no-build -- --timeout 60s --filter-namespace Clockwork.Runtime.Tests.Racing
dotnet run --project tests/Clockwork.Runtime.Tests/Clockwork.Runtime.Tests.csproj --configuration Release --no-build -- --timeout 120s --filter-namespace Orleans.Testing.Simulation.Runtime.Tests.Racing
done
- name: Test Instrumentation
run: dotnet run --project tests/Clockwork.Instrumentation.Tests/Clockwork.Instrumentation.Tests.csproj --configuration Release --no-build -- --timeout 180s
Expand All @@ -49,7 +49,7 @@ jobs:
env:
DOTNET_TieredCompilation: '0'
DOTNET_ReadyToRun: '0'
run: dotnet run --project tests/Clockwork.Conformance.Tests/Clockwork.Conformance.Tests.csproj --configuration Debug --no-build -- --timeout 300s --filter-class Clockwork.Conformance.Tests.ChannelConformanceTests
run: dotnet run --project tests/Clockwork.Conformance.Tests/Clockwork.Conformance.Tests.csproj --configuration Debug --no-build -- --timeout 300s --filter-class Orleans.Testing.Simulation.Conformance.Tests.ChannelConformanceTests
- name: Package smoke tests
# Exercises all six real packed NuGet artifacts end-to-end in an isolated feed,
# consumes the build package through the real MSBuild
Expand All @@ -58,7 +58,7 @@ jobs:
# known path so they can be retained on failure.
env:
CLOCKWORK_SMOKE_TESTS: "1"
run: dotnet run --project tests/Clockwork.Instrumentation.Tests/Clockwork.Instrumentation.Tests.csproj --configuration Release --no-build -- --timeout 600s --filter-namespace Clockwork.Instrumentation.Tests.Packaging
run: dotnet run --project tests/Clockwork.Instrumentation.Tests/Clockwork.Instrumentation.Tests.csproj --configuration Release --no-build -- --timeout 600s --filter-namespace Orleans.Testing.Simulation.Instrumentation.Tests.Packaging
- name: Upload instrumentation artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Clockwork is a deterministic simulation testing framework for distributed system
- Fixed and adaptive `RunUntil`/`RunUntilIdle` execution budgets
- Stable, cross-process-safe seed derivation from strings (`SimulationSeed`)
- Reusable rendezvous primitives (`SimulationGate`, `SimulationLatch`, `SimulationBarrier`)
- In-memory logging for simulation diagnostics in the `Clockwork.Testing` project and namespace
- In-memory logging for simulation diagnostics in the `Orleans.Testing.Simulation.Testing` project and namespace

Consumers should attach node identity and other context using standard structured `ILogger` scopes or
properties; Clockwork does not wrap loggers or prefix rendered messages.
Expand Down Expand Up @@ -59,6 +59,18 @@ The core NuGet package ID is `Microsoft.Orleans.Testing.Simulation`; test-runner
replay helpers are in `Microsoft.Orleans.Testing.Simulation.Testing`. Until packages are published,
clone the repository or add it as a Git submodule and reference the corresponding project under `src`.

### Public namespace migration

| Previous namespace family | Current namespace family |
|---|---|
| `Clockwork` | `Orleans.Testing.Simulation` |
| `Clockwork.Runtime.*` | `Orleans.Testing.Simulation.Runtime.*` |
| `Clockwork.Shims.*` | `Orleans.Testing.Simulation.Shims.*` |
| `Clockwork.Instrumentation.*` | `Orleans.Testing.Simulation.Instrumentation.*` |
| `Clockwork.Analyzers` | `Orleans.Testing.Simulation.Analyzers` |
| `Clockwork.Testing` | `Orleans.Testing.Simulation.Testing` |
| `Clockwork.Tool` | `Orleans.Testing.Simulation.Tool` |

## Instrumented simulation test projects

Keep ordinary and simulation tests in separate projects. Only simulation test projects reference
Expand Down Expand Up @@ -174,7 +186,7 @@ Construct `SimulationCluster` directly. It owns the runtime, scheduler and virtu
and nodes. Nodes are fully attached and usable as soon as `AddNode` returns:

```csharp
using Clockwork;
using Orleans.Testing.Simulation;

await using var cluster = new SimulationCluster(
seed: 12345,
Expand Down Expand Up @@ -466,8 +478,8 @@ NativeAOT, signed assemblies, and profiler conflicts).
The built-in simulation rule set **`clockwork.bcl.deterministic`** (version `3.0.0`),
makes ordinary source that calls the direct **static** time / identity / random BCL surface
deterministic - with no dependency injection, no `TimeProvider` threading, and no manual shim
wiring. Enabling it rewrites those call sites to runtime shims in the `Clockwork` assembly,
under namespaces matching `Clockwork.Shims.<framework namespace>`.
wiring. Enabling it rewrites those call sites to runtime shims in the `Orleans.Testing.Simulation` assembly,
under namespaces matching `Orleans.Testing.Simulation.Shims.<framework namespace>`.
The complete, exhaustive list of controlled and rejected signatures is generated into
[`docs/rule-inventory.md`](docs/rule-inventory.md) and verified against the shipped rules by a
test, so the documentation cannot drift from the code. The inventory also lists every other public
Expand Down Expand Up @@ -582,7 +594,7 @@ Alongside it, call-site redirects route the `Task.WhenAll`/`Task.WhenAny`/`Task.
blocking generic `Task<T>.Result` accessor, the `TaskExtensions.Unwrap` extension methods, every
`Task.ContinueWith`/`Task<T>.ContinueWith` and `TaskFactory`/`TaskFactory<T>` `ContinueWhenAll`/`ContinueWhenAny`
overload, and the `ValueTask`/`ValueTask<T>` `AsTask` and `Preserve` conversions to controlled shims in
`Clockwork.Shims.System.Threading.Tasks`; `TaskFactory.FromAsync`, whose `IAsyncResult` completes outside
`Orleans.Testing.Simulation.Shims.System.Threading.Tasks`; `TaskFactory.FromAsync`, whose `IAsyncResult` completes outside
Clockwork's control, is rejected. Synchronous waits and blocking `Task<T>.Result` reads
**pump the coordinator loop until completion instead of blocking a physical thread**, so they never
deadlock the scheduler, then delegate to the real API for its exact `AggregateException` semantics.
Expand Down
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Mono.Cecil license:
## General policy

- Clockwork uses the `Mono.Cecil` (0.11.6, MIT) package dependency in
`Clockwork.Instrumentation`, and the `Microsoft.CodeAnalysis.CSharp` (Roslyn, MIT)
`Orleans.Testing.Simulation.Instrumentation`, and the `Microsoft.CodeAnalysis.CSharp` (Roslyn, MIT)
package to `Clockwork.Instrumentation.Tests` (used only to compile fixture
assemblies at test time). It also adapts two Coyote source files as recorded above.
The runtime and simulation projects remain free of any IL-rewriting dependency.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BenchmarkDotNet.Attributes;
namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class DeterministicSchedulerBenchmarks
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Clockwork.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BenchmarkDotNet.Running;
using Clockwork.Benchmarks;
using Orleans.Testing.Simulation.Benchmarks;

if (args is ["--trace", var iterationCount]
&& int.TryParse(iterationCount, out var iterations)
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/Clockwork.Benchmarks/RaceTrackerBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using BenchmarkDotNet.Attributes;
using System.Diagnostics.CodeAnalysis;
using Clockwork.Runtime.Execution;
using Clockwork.Runtime.Racing;
using Clockwork.Runtime.Scheduling;
using Orleans.Testing.Simulation.Runtime.Execution;
using Orleans.Testing.Simulation.Runtime.Racing;
using Orleans.Testing.Simulation.Runtime.Scheduling;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
[SuppressMessage(
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Clockwork.Benchmarks/ReplayRunnerBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using BenchmarkDotNet.Attributes;
using Clockwork.Runtime.Replay;
using Clockwork.Runtime.Scheduling;
using Orleans.Testing.Simulation.Runtime.Replay;
using Orleans.Testing.Simulation.Runtime.Scheduling;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class ReplayRunnerBenchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BenchmarkDotNet.Attributes;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class SchedulerAllocationBenchmarks
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/Clockwork.Benchmarks/SchedulerBenchmarkWorkload.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Clockwork.Runtime.Execution;
using Clockwork.Runtime.Decisions;
using Clockwork.Runtime.Scheduling;
using Orleans.Testing.Simulation.Runtime.Execution;
using Orleans.Testing.Simulation.Runtime.Decisions;
using Orleans.Testing.Simulation.Runtime.Scheduling;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

internal static class SchedulerBenchmarkWorkload
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BenchmarkDotNet.Attributes;
using Clockwork.Runtime.Decisions;
using Orleans.Testing.Simulation.Runtime.Decisions;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class SchedulerDecisionLogBenchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BenchmarkDotNet.Attributes;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class SchedulerReadinessBenchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BenchmarkDotNet.Attributes;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class SchedulerScalingBenchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BenchmarkDotNet.Attributes;
using Clockwork.Runtime.Scheduling.Resources;
using Orleans.Testing.Simulation.Runtime.Scheduling.Resources;

namespace Clockwork.Benchmarks;
namespace Orleans.Testing.Simulation.Benchmarks;

[MemoryDiagnoser]
public class SimulationTimerQueueBenchmarks
Expand Down
12 changes: 6 additions & 6 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ recovered to a rewriteable managed closure.

The built-in simulation rule set `clockwork.bcl.deterministic` (version `3.0.0`),
redirects the direct **static** time / identity / random BCL surface to Cecil-free runtime
shims in the `Clockwork` assembly, under namespaces matching
`Clockwork.Shims.<framework namespace>`. The complete, exhaustive
shims in the `Orleans.Testing.Simulation` assembly, under namespaces matching
`Orleans.Testing.Simulation.Shims.<framework namespace>`. The complete, exhaustive
list of controlled and rejected signatures is generated into
[`rule-inventory.md`](rule-inventory.md) and verified against the shipped rules by a test, so
the published inventory can never drift from the code.
Expand Down Expand Up @@ -516,7 +516,7 @@ verified against the shipped rules by a test.

The rule set has two halves. A **member-aware type substitution** pass retargets the
compiler-generated builder and awaiter types of an `async` state machine onto controlled
value-type equivalents in `Clockwork.Shims.System.Runtime.CompilerServices`
value-type equivalents in `Orleans.Testing.Simulation.Shims.System.Runtime.CompilerServices`
(`AsyncTaskMethodBuilder`(`<T>`) → `ControlledAsyncTaskMethodBuilder`(`<T>`); `TaskAwaiter`(`<T>`),
`ConfiguredTaskAwaitable`(`<T>`)`/ConfiguredTaskAwaiter`, and `YieldAwaitable`/`YieldAwaiter` →
their `Controlled…` counterparts), rewriting field, local, method- and field-reference, and
Expand Down Expand Up @@ -562,7 +562,7 @@ generic `Task<T>` overloads** (array, span, enumerable, and the `WhenAny<T>` pai
`Task.ContinueWith`/`Task<T>.ContinueWith` overloads, all 48 `TaskFactory`/`TaskFactory<T>`
`ContinueWhenAll`/`ContinueWhenAny` overloads, the `ValueTask`/`ValueTask<T>` `AsTask` and `Preserve`
conversions, and the completion members of `TaskCompletionSource`/`TaskCompletionSource<T>` to shims in
`Clockwork.Shims.System.Threading.Tasks`, and rejects every `TaskFactory`/`TaskFactory<T>` `FromAsync` overload at
`Orleans.Testing.Simulation.Shims.System.Threading.Tasks`, and rejects every `TaskFactory`/`TaskFactory<T>` `FromAsync` overload at
the call site. Synchronous waits **pump the
coordinator loop until completion instead of blocking a physical thread**, then delegate to the
real API to reproduce its exact `AggregateException` semantics, so a synchronous wait or a blocking
Expand Down Expand Up @@ -720,7 +720,7 @@ inside a task which hides it, run inline on the logical thread. That covers the
`ManualResetValueTaskSourceCore<T>` completion shims, `CancellationTokenSource.Cancel` and the cancellations its
virtual timer and `CancelAsync` make, the controlled synchronization primitives' waiters, rendezvous, and timers, and the
promises of the controlled combinators and continuations. A bare continuation of the task then runs inline, on the
logical thread, as the BCL runs it on a thread-pool thread. Inside the Clockwork assembly, analyzer rule `CW1004` rejects
logical thread, as the BCL runs it on a thread-pool thread. Inside the `Orleans.Testing.Simulation` assembly, analyzer rule `CW1004` rejects
any call to these completion members outside that one path.

Around the completion the BCL's behavior is kept where it differs:
Expand Down Expand Up @@ -1337,7 +1337,7 @@ The implemented package boundaries under `src/` map to the modes above:
| `Orleans.Testing.Simulation.Testing` | `Orleans.Testing.Simulation` | Reusable test helpers, scenario builders, and in-memory log capture for consumers. |

`Orleans.Testing.Simulation.Testing` remains a separate helper project while retaining the
`Clockwork.Testing` namespace boundary. Application hosting and transport models are
`Orleans.Testing.Simulation.Testing` namespace boundary. Application hosting and transport models are
consumer-owned and outside the Clockwork core; consumers compose them over `SimulationNetwork` and
the generic application-composition APIs, and no dedicated hosting or HTTP packages ship. Exact
shipped interception behavior is defined by [`rule-inventory.md`](rule-inventory.md).
2 changes: 1 addition & 1 deletion docs/coyote-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Coyote wraps TCS so the produced task is a controlled task. Clockwork keeps the
`TaskCompletionSource` and `TaskCompletionSource<TResult>`, with their real `TaskCreationOptions`: the controlled
awaiters, combinators, and continuations observe the produced task through the coordinator and register no BCL
continuation on it, so `RunContinuationsAsynchronously` sends none of them to the thread pool. Only the completion
members redirect, to `Clockwork.Shims.System.Threading.Tasks.ControlledTaskCompletionSource`, which completes the
members redirect, to `Orleans.Testing.Simulation.Shims.System.Threading.Tasks.ControlledTaskCompletionSource`, which completes the
source through the same member and publishes the race-detection release edge.

| Coyote surface | Clockwork status | Notes |
Expand Down
2 changes: 1 addition & 1 deletion docs/replay.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ by attempt count and optional wall-clock time.

## Test integration

`Clockwork.Testing.ReplayTestFixture` derives its default simulation seed with
`Orleans.Testing.Simulation.Testing.ReplayTestFixture` derives its default simulation seed with
`SimulationSeed.FromStrings(testClass, testMethod)`. Failed runs write an artifact and expose its path
through `ReplayTestResult.ArtifactPath`, `ToFailureMessage()`, and `GetReplayCommand(...)`.

Expand Down
Loading
Loading