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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/build_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
# The measurement: ProcessAsync must scale from 1 to 4 workers. A process-wide serialization point holds the ratio
# near 1.3 on any core count. Diagnostic on the shared runner (its core count and isolation are not promised, so
# this job is not required and continues on error); the release gate is `--scale 3 16 4.0` on the reference machine.
# The per-serializer diagnostics after the gate (one run per cell, never part of the exit code) go to their own summary section.
scaling:
runs-on: ubuntu-latest
continue-on-error: true
Expand All @@ -67,8 +68,14 @@ jobs:
{
echo "## ProcessAsync scaling (diagnostic, not required)"
echo
grep -E '^\|' scale.txt
sed '/^Diagnostics/,$d' scale.txt | grep -E '^\|'
echo
[ "$status" -eq 0 ] && echo "pass: 4/1 at least 2.0" || echo "**flag: 4/1 below 2.0 on this runner; reproduce with --scale 3 16 4.0 on the reference machine before reading it as a regression**"
echo
echo "### Per-serializer diagnostics (one run per cell, not gated)"
echo
sed -n '/^Diagnostics/,$p' scale.txt | grep -E '^\|'
echo
grep -E '^Diagnostics stopped' scale.txt
} >> "$GITHUB_STEP_SUMMARY"
exit $status
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches: [ master ]
paths:
- "README.md"
- "CHANGELOG.md"
- "docs/**"
- "site/**"
- "AustinHarris.JsonRpc.AspNetCore/README.md"
Expand Down
20 changes: 19 additions & 1 deletion AustinHarris.JsonRpcTestN/AspNetCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public async Task StartHost()

_app = builder.Build();
_app.MapJsonRpc("/rpc");
_app.MapJsonRpc("/raised-limit", new JsonRpcOptions { MaxRequestBytes = 6 * 1024 * 1024 });
await _app.StartAsync();

var addresses = _app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses;
Expand Down Expand Up @@ -157,11 +158,28 @@ public async Task Http_DiService_IsBoundAndSeesHttpContext()
[Test]
public async Task Http_LargeBody_Is413()
{
var big = "{\"jsonrpc\":\"2.0\",\"method\":\"internal.echo\",\"params\":[\"" + new string('x', 5 * 1024 * 1024) + "\"],\"id\":1}";
var big = SizedDocument(4 * 1024 * 1024 + 1);
var response = await PostAsync(big);
Assert.AreEqual(HttpStatusCode.RequestEntityTooLarge, response.StatusCode);
}

[Test]
public async Task Http_RaisedTransportLimit_UsesCoreDocumentLimit()
{
var response = await _http.PostAsync("/raised-limit",
new StringContent(SizedDocument(4 * 1024 * 1024 + 1), Encoding.UTF8, "application/json"));
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"Invalid Request\",\"data\":{\"limit\":\"maxDocumentBytes\",\"maximum\":4194304}},\"id\":null}",
await response.Content.ReadAsStringAsync());
}

private static string SizedDocument(int bytes)
{
const string prefix = "{\"method\":\"IntToInt\",\"params\":[\"";
const string suffix = "\"],\"id\":1}";
return prefix + new string('x', bytes - prefix.Length - suffix.Length) + suffix;
}

[Test]
public async Task Tcp_TwoDocumentsInOneWrite_AreAnsweredInOrder()
{
Expand Down
8 changes: 4 additions & 4 deletions AustinHarris.JsonRpcTestN/AsyncInvocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public async Task CompatibilityRegistrationSurfaces_SupportAsyncMethods(int surf
var method = new Func<Task<int>>(() => Task.FromResult(7));
var handler = Handler.GetSessionHandler(_session);
if (surface == 0) handler.MetaData.Services["run"] = new SMDService("POST", "JSON-RPC-2.0", types, new Dictionary<string, object>(), method);
#pragma warning disable CS0618
#pragma warning disable CS0618, JSONRPC0002
else if (surface == 1) handler.RegisterFuction("run", types, null, method);
#pragma warning restore CS0618
#pragma warning restore CS0618, JSONRPC0002
else _ = new AutoAsyncService(_session);
Assert.AreEqual(7, (int)JObject.Parse(await Run(Request("run")))["result"]);
Assert.AreEqual(typeof(int), handler.MetaData.Services["run"].Method.ResultType);
Expand Down Expand Up @@ -180,9 +180,9 @@ public void AsyncVoid_IsRejectedOnEverySurface(int surface)
3 => () => Bind("invalid", invalid),
4 => () => new InvalidAutoService(_session),
5 => () => new SMDService("POST", "JSON-RPC-2.0", types, new Dictionary<string, object>(), invalid),
#pragma warning disable CS0618
#pragma warning disable CS0618, JSONRPC0002
_ => () => Handler.GetSessionHandler(_session).RegisterFuction("invalid", types, null, invalid)
#pragma warning restore CS0618
#pragma warning restore CS0618, JSONRPC0002
};
StringAssert.Contains("async void", Assert.Throws<NotSupportedException>(registration).Message);
}
Expand Down
4 changes: 2 additions & 2 deletions AustinHarris.JsonRpcTestN/DelegateBindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public void Names_MustBeFree_AndUnbindFreesThem()
Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"result\":2,\"id\":1}", Run("{\"method\":\"m\",\"id\":1}"));

// the legacy surface keeps replacing silently
#pragma warning disable CS0618
#pragma warning disable CS0618, JSONRPC0002
Handler.GetSessionHandler(Session).RegisterFuction("m", new Dictionary<string, Type> { ["returns"] = typeof(int) }, null, new Func<int>(() => 3));
#pragma warning restore CS0618
#pragma warning restore CS0618, JSONRPC0002
Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"result\":3,\"id\":1}", Run("{\"method\":\"m\",\"id\":1}"));
}

Expand Down
4 changes: 2 additions & 2 deletions AustinHarris.JsonRpcTestN/DispatchHardeningTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ public void BindServices()
public void DestroySessions()
{
Handler.DestroySession(Session);
#pragma warning disable CS0618
#pragma warning disable CS0618, JSONRPC0003
Handler.DefaultHandler.UnRegisterFunction("dh.whichSession");
#pragma warning restore CS0618
#pragma warning restore CS0618, JSONRPC0003
}

private static string Run(string json, object context = null, JsonRpcSerializer serializer = null, string session = Session)
Expand Down
Loading
Loading