From a4fb9c391caabef6de9cfbd126f4fe10755ece49 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Fri, 15 Sep 2017 12:18:41 +0200 Subject: Fixed timeout tests to be less time sensitive The tests now use a controller to hold/activate the adapter instead of relying on a timer. Fixes ICE-8312. --- cpp/test/Ice/timeout/TestI.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'cpp/test/Ice/timeout/TestI.cpp') diff --git a/cpp/test/Ice/timeout/TestI.cpp b/cpp/test/Ice/timeout/TestI.cpp index 01e95bea34c..e97be228af9 100644 --- a/cpp/test/Ice/timeout/TestI.cpp +++ b/cpp/test/Ice/timeout/TestI.cpp @@ -26,7 +26,9 @@ public: virtual void run() { + cerr << "holdx start: " << IceUtil::Time::now().toDateTime() << endl; IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(_timeout)); + cerr << "holdx finished: " << IceUtil::Time::now().toDateTime() << endl; _adapter->activate(); } @@ -52,17 +54,31 @@ TimeoutI::sleep(Ice::Int to, const Ice::Current& c) IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(to)); } +ControllerI::ControllerI(const Ice::ObjectAdapterPtr& adapter) : _adapter(adapter) +{ +} + +void +ControllerI::holdAdapter(Ice::Int to, const Ice::Current&) +{ + _adapter->hold(); + + if(to >= 0) + { + IceUtil::ThreadPtr thread = new ActivateAdapterThread(_adapter, to); + IceUtil::ThreadControl threadControl = thread->start(); + threadControl.detach(); + } +} + void -TimeoutI::holdAdapter(Ice::Int to, const Ice::Current& current) +ControllerI::resumeAdapter(const Ice::Current&) { - current.adapter->hold(); - IceUtil::ThreadPtr thread = new ActivateAdapterThread(current.adapter, to); - IceUtil::ThreadControl threadControl = thread->start(); - threadControl.detach(); + _adapter->activate(); } void -TimeoutI::shutdown(const Ice::Current& current) +ControllerI::shutdown(const Ice::Current&) { - current.adapter->getCommunicator()->shutdown(); + _adapter->getCommunicator()->shutdown(); } -- cgit v1.2.3