Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
externl committed Oct 30, 2024
1 parent 18941dc commit 5a8b206
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ jobs:
test_flags: "--all-cross"
- os: macos-15
config: "cross"
test_flags: "--all-cross"
# We want to test C++ and Swift only (in each direction)
test_flags: "--all-cross --filter cpp --filter swift"

runs-on: ${{ matrix.os }}
steps:
Expand Down
41 changes: 23 additions & 18 deletions cpp/test/Ice/ami/AllTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,26 +1258,31 @@ allTests(TestHelper* helper, bool collocated)

if (p->ice_getConnection())
{
cout << "testing back pressure... " << flush;
if (p->supportsBackPressureTests())
{
// Keep the 3 server thread pool threads busy.
auto sleep1Future = p->sleepAsync(1000);
auto sleep2Future = p->sleepAsync(1000);
auto sleep3Future = p->sleepAsync(1000);

auto onewayProxy = Ice::uncheckedCast<Test::TestIntfPrx>(p->ice_oneway());

// Sending should block because the TCP send/receive buffer size on the server is set to 50KB.
Ice::ByteSeq seq;
seq.resize(768 * 1024);
auto future = onewayProxy->opWithPayloadAsync(seq);

test(future.wait_for(200ms) == future_status::timeout && sleep1Future.wait_for(0s) != future_status::ready);
sleep1Future.wait();
sleep2Future.wait();
sleep3Future.wait();
cout << "testing back pressure... " << flush;
{
// Keep the 3 server thread pool threads busy.
auto sleep1Future = p->sleepAsync(1000);
auto sleep2Future = p->sleepAsync(1000);
auto sleep3Future = p->sleepAsync(1000);

auto onewayProxy = Ice::uncheckedCast<Test::TestIntfPrx>(p->ice_oneway());

// Sending should block because the TCP send/receive buffer size on the server is set to 50KB.
Ice::ByteSeq seq;
seq.resize(768 * 1024);
auto future = onewayProxy->opWithPayloadAsync(seq);

test(
future.wait_for(200ms) == future_status::timeout &&
sleep1Future.wait_for(0s) != future_status::ready);
sleep1Future.wait();
sleep2Future.wait();
sleep3Future.wait();
}
cout << "ok" << endl;
}
cout << "ok" << endl;

cout << "testing bi-dir... " << flush;
auto adapter = communicator->createObjectAdapter("");
Expand Down
1 change: 1 addition & 0 deletions cpp/test/Ice/ami/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface TestIntf

bool supportsAMD();
bool supportsFunctionalTests();
bool supportsBackPressureTests();

["amd"] void pingBiDir(PingReply* reply);
}
Expand Down
6 changes: 6 additions & 0 deletions cpp/test/Ice/ami/TestI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ TestIntfI::supportsFunctionalTests(const Ice::Current&)
return false;
}

bool
TestIntfI::supportsBackPressureTests(const Ice::Current&)
{
return true;
}

void
TestIntfI::pingBiDirAsync(
optional<Test::PingReplyPrx> reply,
Expand Down
1 change: 1 addition & 0 deletions cpp/test/Ice/ami/TestI.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class TestIntfI final : public Test::TestIntf

bool supportsAMD(const Ice::Current&) final;
bool supportsFunctionalTests(const Ice::Current&) final;
bool supportsBackPressureTests(const Ice::Current&) final;

void pingBiDirAsync(
std::optional<Test::PingReplyPrx>,
Expand Down
75 changes: 39 additions & 36 deletions csharp/test/Ice/ami/AllTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ private void
switch (_t)
{
case ThrowType.LocalException:
{
throw new Ice.ObjectNotExistException();
}
{
throw new Ice.ObjectNotExistException();
}
case ThrowType.UserException:
{
throw new Test.TestIntfException();
}
{
throw new Test.TestIntfException();
}
case ThrowType.OtherException:
{
throw new System.Exception();
}
{
throw new System.Exception();
}
default:
{
Debug.Assert(false);
break;
}
{
Debug.Assert(false);
break;
}
}
}

Expand Down Expand Up @@ -896,34 +896,37 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll
}
output.WriteLine("ok");

output.Write("testing back pressure... ");
output.Flush();
if (p.supportsBackPressureTests())
{
// Keep the 3 server thread pool threads busy.
Task sleep1Task = p.sleepAsync(1000);
Task sleep2Task = p.sleepAsync(1000);
Task sleep3Task = p.sleepAsync(1000);
bool canceled = false;
using var cts = new CancellationTokenSource(200);
try
output.Write("testing back pressure... ");
output.Flush();
{
var onewayProxy = (Test.TestIntfPrx)p.ice_oneway();
// Keep the 3 server thread pool threads busy.
Task sleep1Task = p.sleepAsync(1000);
Task sleep2Task = p.sleepAsync(1000);
Task sleep3Task = p.sleepAsync(1000);
bool canceled = false;
using var cts = new CancellationTokenSource(200);
try
{
var onewayProxy = (Test.TestIntfPrx)p.ice_oneway();

// Sending should be canceled because the TCP send/receive buffer size on the server is set
// to 50KB. Note: we don't use the cancel parameter of the operation here because the
// cancellation doesn't cancel the operation whose payload is being sent.
await onewayProxy.opWithPayloadAsync(new byte[768 * 1024]).WaitAsync(cts.Token);
}
catch (OperationCanceledException)
{
canceled = true;
// Sending should be canceled because the TCP send/receive buffer size on the server is set
// to 50KB. Note: we don't use the cancel parameter of the operation here because the
// cancellation doesn't cancel the operation whose payload is being sent.
await onewayProxy.opWithPayloadAsync(new byte[768 * 1024]).WaitAsync(cts.Token);
}
catch (OperationCanceledException)
{
canceled = true;
}
test(canceled && !sleep1Task.IsCompleted);
await sleep1Task;
await sleep2Task;
await sleep3Task;
}
test(canceled && !sleep1Task.IsCompleted);
await sleep1Task;
await sleep2Task;
await sleep3Task;
output.WriteLine("ok");
}
output.WriteLine("ok");

p.shutdown();
}
Expand Down
1 change: 1 addition & 0 deletions csharp/test/Ice/ami/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface TestIntf

bool supportsAMD();
bool supportsFunctionalTests();
bool supportsBackPressureTests();

["amd"] void opAsyncDispatch();
["amd"] int opWithResultAsyncDispatch();
Expand Down
6 changes: 6 additions & 0 deletions csharp/test/Ice/ami/TestI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ public override bool
return false;
}

public override bool
supportsBackPressureTests(Ice.Current current)
{
return true;
}

public override async Task
opAsyncDispatchAsync(Ice.Current current)
{
Expand Down
2 changes: 1 addition & 1 deletion java/test/src/main/java/test/Ice/ami/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ public static void allTests(test.TestHelper helper, boolean collocated) {
}
out.println("ok");

if (p.ice_getConnection() != null) {
if (p.ice_getConnection() != null && p.supportsBackPressureTests()) {
out.print("testing back pressure... ");
out.flush();
try {
Expand Down
2 changes: 2 additions & 0 deletions java/test/src/main/java/test/Ice/ami/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ interface TestIntf

bool supportsAMD();
bool supportsFunctionalTests();
bool supportsBackPressureTests();

bool opBool(bool b);
byte opByte(byte b);
short opShort(short s);
Expand Down
5 changes: 5 additions & 0 deletions java/test/src/main/java/test/Ice/ami/TestI.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public boolean supportsFunctionalTests(com.zeroc.Ice.Current current) {
return true;
}

@Override
public boolean supportsBackPressureTests(com.zeroc.Ice.Current current) {
return true;
}

@Override
public boolean opBool(boolean b, com.zeroc.Ice.Current current) {
return b;
Expand Down
1 change: 1 addition & 0 deletions python/test/Ice/ami/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface TestIntf

bool supportsAMD();
bool supportsFunctionalTests();
bool supportsBackPressureTests();

["amd"] void pingBiDir(PingReply* reply);
}
Expand Down
4 changes: 4 additions & 0 deletions python/test/Ice/ami/TestI.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def supportsAMD(self, current):
def supportsFunctionalTests(self, current):
return False

def supportsBackPressureTests(self, current):
return True

async def pingBiDir(self, reply, current):
expectSuccess = "ONE" not in current.ctx
try:
Expand All @@ -100,6 +103,7 @@ async def pingBiDir(self, reply, current):
if expectSuccess:
raise Test.TestIntfException()


class TestIntfII(Test.Outer.Inner.TestIntf):
def op(self, i, current):
return (i, i)
Expand Down
1 change: 1 addition & 0 deletions swift/test/Ice/ami/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface TestIntf

bool supportsAMD();
bool supportsFunctionalTests();
bool supportsBackPressureTests();

void pingBiDir(PingReply* reply);
}
Expand Down
4 changes: 4 additions & 0 deletions swift/test/Ice/ami/TestI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ class TestI: TestIntf {
func supportsFunctionalTests(current _: Current) async throws -> Bool {
return false
}

func supportsBackPressureTests(current _: Current) async throws -> Bool {
return false
}
}

class TestII: OuterInnerTestIntf {
Expand Down

0 comments on commit 5a8b206

Please sign in to comment.