From 2a489bd7a63baa590fdef5f683daf00c2602862d Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Fri, 11 Oct 2024 17:49:38 -0400 Subject: [PATCH] Fix test scripts and inactivity timeout test --- cpp/test/Ice/inactivityTimeout/Test.ice | 1 + cpp/test/Ice/inactivityTimeout/TestI.cpp | 10 ++++++++-- cpp/test/Ice/inactivityTimeout/TestI.h | 10 +++++++++- csharp/test/Ice/inactivityTimeout/Test.ice | 2 ++ csharp/test/Ice/inactivityTimeout/TestI.cs | 2 +- .../main/java/test/Ice/inactivityTimeout/Test.ice | 2 ++ .../test/Ice/inactivityTimeout/TestIntfI.java | 15 +++++++++------ scripts/tests/Ice/inactivityTimeout.py | 11 ----------- scripts/tests/Ice/maxConnections.py | 2 +- 9 files changed, 33 insertions(+), 22 deletions(-) delete mode 100644 scripts/tests/Ice/inactivityTimeout.py diff --git a/cpp/test/Ice/inactivityTimeout/Test.ice b/cpp/test/Ice/inactivityTimeout/Test.ice index 1ed1d3e75f4..e0b4dd3c647 100644 --- a/cpp/test/Ice/inactivityTimeout/Test.ice +++ b/cpp/test/Ice/inactivityTimeout/Test.ice @@ -8,6 +8,7 @@ module Test { interface TestIntf { + ["amd"] void sleep(int ms); void shutdown(); diff --git a/cpp/test/Ice/inactivityTimeout/TestI.cpp b/cpp/test/Ice/inactivityTimeout/TestI.cpp index d5e76118590..c301e098edf 100644 --- a/cpp/test/Ice/inactivityTimeout/TestI.cpp +++ b/cpp/test/Ice/inactivityTimeout/TestI.cpp @@ -9,9 +9,15 @@ using namespace std; void -TestIntfI::sleep(int32_t ms, const Ice::Current&) +TestIntfI::sleepAsync(int32_t ms, function response, function, const Ice::Current&) { - this_thread::sleep_for(chrono::milliseconds(ms)); + _sleepFuture = std::async( + std::launch::async, + [ms, response] + { + this_thread::sleep_for(chrono::milliseconds(ms)); + response(); + }); } void diff --git a/cpp/test/Ice/inactivityTimeout/TestI.h b/cpp/test/Ice/inactivityTimeout/TestI.h index 6e227ae5601..5284fff69a2 100644 --- a/cpp/test/Ice/inactivityTimeout/TestI.h +++ b/cpp/test/Ice/inactivityTimeout/TestI.h @@ -10,8 +10,16 @@ class TestIntfI final : public Test::TestIntf { public: - void sleep(std::int32_t, const Ice::Current&) final; + void sleepAsync( + std::int32_t ms, + std::function response, + std::function exception, + const Ice::Current& current) final; void shutdown(const Ice::Current&) final; + +private: + // has a blocking destructor + std::future _sleepFuture; }; #endif diff --git a/csharp/test/Ice/inactivityTimeout/Test.ice b/csharp/test/Ice/inactivityTimeout/Test.ice index f5a2dc3a098..545fac3e1d0 100644 --- a/csharp/test/Ice/inactivityTimeout/Test.ice +++ b/csharp/test/Ice/inactivityTimeout/Test.ice @@ -9,7 +9,9 @@ module Test { interface TestIntf { + ["amd"] void sleep(int ms); + void shutdown(); } } diff --git a/csharp/test/Ice/inactivityTimeout/TestI.cs b/csharp/test/Ice/inactivityTimeout/TestI.cs index 40306b9f951..6d6ff1f2d4b 100644 --- a/csharp/test/Ice/inactivityTimeout/TestI.cs +++ b/csharp/test/Ice/inactivityTimeout/TestI.cs @@ -4,7 +4,7 @@ namespace Ice.inactivityTimeout; internal sealed class TestIntfI : Test.TestIntfDisp_ { - public override void sleep(int ms, Current current) => Thread.Sleep(ms); + public override Task sleepAsync(int ms, Current current) => Task.Delay(ms); public override void shutdown(Current current) => current.adapter.getCommunicator().shutdown(); } diff --git a/java/test/src/main/java/test/Ice/inactivityTimeout/Test.ice b/java/test/src/main/java/test/Ice/inactivityTimeout/Test.ice index 124e39e6ecb..72a2ccefb22 100644 --- a/java/test/src/main/java/test/Ice/inactivityTimeout/Test.ice +++ b/java/test/src/main/java/test/Ice/inactivityTimeout/Test.ice @@ -8,7 +8,9 @@ module Test { interface TestIntf { + ["amd"] void sleep(int ms); + void shutdown(); } } diff --git a/java/test/src/main/java/test/Ice/inactivityTimeout/TestIntfI.java b/java/test/src/main/java/test/Ice/inactivityTimeout/TestIntfI.java index 8654b0361ad..362dd4d2e48 100644 --- a/java/test/src/main/java/test/Ice/inactivityTimeout/TestIntfI.java +++ b/java/test/src/main/java/test/Ice/inactivityTimeout/TestIntfI.java @@ -7,12 +7,15 @@ class TestIntfI implements TestIntf { @Override - public void sleep(int ms, Current current) { - try { - Thread.sleep(ms); - } catch (InterruptedException ex) { - // ignored - } + public java.util.concurrent.CompletionStage sleepAsync(int ms, Current current) { + return java.util.concurrent.CompletableFuture.runAsync( + () -> { + try { + Thread.sleep(ms); + } catch (InterruptedException ex) { + // ignored + } + }); } @Override diff --git a/scripts/tests/Ice/inactivityTimeout.py b/scripts/tests/Ice/inactivityTimeout.py deleted file mode 100644 index 83976f10d4b..00000000000 --- a/scripts/tests/Ice/inactivityTimeout.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# - -from Util import TestSuite - -# TODO: temporary work-around for C#. serialize turns on flow-control -# and makes the test fail - -TestSuite(__name__, options={"serialize": [False]}) diff --git a/scripts/tests/Ice/maxConnections.py b/scripts/tests/Ice/maxConnections.py index c5fcd55e7e5..5038dcdc036 100644 --- a/scripts/tests/Ice/maxConnections.py +++ b/scripts/tests/Ice/maxConnections.py @@ -14,6 +14,6 @@ TestSuite( __name__, testcases, - options={"compress": [False], "protocol": ["ssl", "ws", "tcp"]}, + options={"compress": [False]}, multihost=False, )