diff options
author | Marc Laukien <marc@zeroc.com> | 2006-04-03 20:54:32 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2006-04-03 20:54:32 +0000 |
commit | 345d6807f6ee83ba0d389de91723c1b23a753925 (patch) | |
tree | 9bd2879974b6db1d098fab1d66af1246117c6f6c /cpp | |
parent | fix (diff) | |
download | ice-345d6807f6ee83ba0d389de91723c1b23a753925.tar.bz2 ice-345d6807f6ee83ba0d389de91723c1b23a753925.tar.xz ice-345d6807f6ee83ba0d389de91723c1b23a753925.zip |
attack test
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/allTests.py | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.cpp | 28 | ||||
-rw-r--r-- | cpp/test/Glacier2/Makefile | 3 | ||||
-rw-r--r-- | cpp/test/Glacier2/attack/Client.cpp | 28 | ||||
-rwxr-xr-x | cpp/test/Glacier2/attack/run.py | 22 |
5 files changed, 56 insertions, 26 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py index 216929e7ce1..1a3522c411f 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -90,6 +90,7 @@ tests = [ \ "IceGrid/activation", \ "IceGrid/replication", \ "Glacier2/router", \ + "Glacier2/attack", \ ] # diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index 67f6c695ced..d758934f9cd 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -90,19 +90,31 @@ IceInternal::ProxyFactory::referenceToProxy(const ReferencePtr& ref) const void IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, const ReferencePtr& ref, int& cnt) const { - // - // We retry ObjectNotExistException if the reference is - // indirect. Otherwise, we don't retry other *NotExistException, - // which are all derived from RequestFailedException. - // if(dynamic_cast<const ObjectNotExistException*>(&ex)) { + // + // We retry ObjectNotExistException if the reference is + // indirect. Otherwise, we don't retry other + // *NotExistException, which are all derived from + // RequestFailedException. + // LocatorInfoPtr li = ref->getLocatorInfo(); - if(!li) + if(li) { - ex.ice_throw(); + li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref)); + } + else + { + // + // TODO: For now, we retry on ObjectNotExistException if + // we are using a router, to handle proxies evicted by the + // router. + // + if(!ref->getRouterInfo()) + { + ex.ice_throw(); + } } - li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref)); } else if(dynamic_cast<const RequestFailedException*>(&ex)) { diff --git a/cpp/test/Glacier2/Makefile b/cpp/test/Glacier2/Makefile index 5840e92f522..7128bf92700 100644 --- a/cpp/test/Glacier2/Makefile +++ b/cpp/test/Glacier2/Makefile @@ -11,7 +11,8 @@ top_srcdir = ../.. include $(top_srcdir)/config/Make.rules -SUBDIRS = router +SUBDIRS = router \ + attack $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/test/Glacier2/attack/Client.cpp b/cpp/test/Glacier2/attack/Client.cpp index bac661b4145..3b48c0f8494 100644 --- a/cpp/test/Glacier2/attack/Client.cpp +++ b/cpp/test/Glacier2/attack/Client.cpp @@ -12,12 +12,13 @@ #include <Glacier2/Router.h> #include <Backend.h> #include <TestCommon.h> +#include <set> using namespace std; using namespace Ice; using namespace Test; -class CallbackClient : public Application +class AttackClient : public Application { public: @@ -33,14 +34,14 @@ main(int argc, char* argv[]) // We want to check whether the client retries for evicted // proxies, even with regular retries disabled. // - properties->setProperty("Ice.RetryIntervals", "-1"); +// properties->setProperty("Ice.RetryIntervals", "-1"); - CallbackClient app; + AttackClient app; return app.main(argc, argv); } int -CallbackClient::run(int argc, char* argv[]) +AttackClient::run(int argc, char* argv[]) { cout << "getting router... " << flush; ObjectPrx routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347 -t 10000"); @@ -58,8 +59,10 @@ CallbackClient::run(int argc, char* argv[]) BackendPrx backend = BackendPrx::uncheckedCast(backendBase); backend->ice_ping(); + set<BackendPrx> backends; + string msg; - for(int i = 1; i <= 100000; ++i) + for(int i = 1; i <= 10000; ++i) { if(i % 100 == 0) { @@ -88,7 +91,20 @@ CallbackClient::run(int argc, char* argv[]) *p = static_cast<char>('a' + IceUtil::random() % 26); } - backend = BackendPrx::uncheckedCast(backendBase->ice_identity(ident)); + BackendPrx newBackend = BackendPrx::uncheckedCast(backendBase->ice_identity(ident)); + + set<BackendPrx>::const_iterator q = backends.find(newBackend); + + if(q == backends.end()) + { + backends.insert(newBackend); + backend = newBackend; + } + else + { + backend = *q; + } + backend->ice_ping(); } cout << string(msg.size(), '\b') << string(msg.size(), ' ') << string(msg.size(), '\b'); diff --git a/cpp/test/Glacier2/attack/run.py b/cpp/test/Glacier2/attack/run.py index 910fdeeddb4..a24d181907d 100755 --- a/cpp/test/Glacier2/attack/run.py +++ b/cpp/test/Glacier2/attack/run.py @@ -17,17 +17,17 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: else: raise "can't find toplevel directory!" -sys.stdout.write("Testing add proxy rules...") -testcase = file("./test.dat") -lines = testcase.readlines() -input = os.popen(r"ruletester 1>test.out 2>test.log", "w") -for l in lines: - input.write(l) - -if not input.close() == None: - print "There were errors, check test.log" -else: - print "ok" +#sys.stdout.write("Testing add proxy rules...") +#testcase = file("./test.dat") +#lines = testcase.readlines() +#input = os.popen(r"ruletester 1>test.out 2>test.log", "w") +#for l in lines: +# input.write(l) +# +#if not input.close() == None: +# print "There were errors, check test.log" +#else: +# print "ok" sys.path.append(os.path.join(toplevel, "config")) import TestUtil |