diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-14 00:13:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-14 00:13:11 +0200 |
commit | 0836f0bf337ee23c5e66f420cfa54d49e4a2104e (patch) | |
tree | 403c361cd30043cc3de04483489cfa8e25fe0ff3 /messagebus_test/src/tests/speed | |
parent | 4537f2d1e36f41e74f348258aecf448b77ef1799 (diff) |
Revert "Aressem/move messagebus test tests to separate module"
Diffstat (limited to 'messagebus_test/src/tests/speed')
-rw-r--r-- | messagebus_test/src/tests/speed/.gitignore | 15 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/CMakeLists.txt | 21 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/DESC | 4 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/FILES | 8 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/JavaClient.java | 137 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/JavaServer.java | 54 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/cpp-client.cpp | 146 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/cpp-server.cpp | 77 | ||||
-rwxr-xr-x | messagebus_test/src/tests/speed/ctl.sh | 10 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/progdefs.sh | 3 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/routing-template.cfg | 11 | ||||
-rw-r--r-- | messagebus_test/src/tests/speed/speed.cpp | 56 | ||||
-rwxr-xr-x | messagebus_test/src/tests/speed/speed_test.sh | 13 |
13 files changed, 0 insertions, 555 deletions
diff --git a/messagebus_test/src/tests/speed/.gitignore b/messagebus_test/src/tests/speed/.gitignore deleted file mode 100644 index 326da75ebb6..00000000000 --- a/messagebus_test/src/tests/speed/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.class -.depend -Makefile -cpp-client -cpp-server -out.* -pid.* -routing.cfg -slobrok.cfg -speed_test -cpp-client-speed -cpp-server-speed -messagebus_test_speed_test_app -messagebus_test_cpp-client-speed_app -messagebus_test_cpp-server-speed_app diff --git a/messagebus_test/src/tests/speed/CMakeLists.txt b/messagebus_test/src/tests/speed/CMakeLists.txt deleted file mode 100644 index 5a5f9615c42..00000000000 --- a/messagebus_test/src/tests/speed/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(messagebus_test_speed_test_app - SOURCES - speed.cpp - DEPENDS - messagebus_messagebus-test -) -vespa_add_executable(messagebus_test_cpp-server-speed_app - SOURCES - cpp-server.cpp - DEPENDS - messagebus_messagebus-test -) -vespa_add_executable(messagebus_test_cpp-client-speed_app - SOURCES - cpp-client.cpp - DEPENDS - messagebus_messagebus-test -) -vespa_add_test(NAME messagebus_test_speed_test_app COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/speed_test.sh BENCHMARK - DEPENDS messagebus_test_speed_test_app messagebus_test_cpp-server-speed_app messagebus_test_cpp-client-speed_app ) diff --git a/messagebus_test/src/tests/speed/DESC b/messagebus_test/src/tests/speed/DESC deleted file mode 100644 index 10734957438..00000000000 --- a/messagebus_test/src/tests/speed/DESC +++ /dev/null @@ -1,4 +0,0 @@ -This is a simple test that gives a rough idea of the inherent overhead -in messagebus. It sends simple messages back and forth with the -simplest routing setup possible. This test also tests that messagebus -works across Java and C++. diff --git a/messagebus_test/src/tests/speed/FILES b/messagebus_test/src/tests/speed/FILES deleted file mode 100644 index 09f0a5ec1d3..00000000000 --- a/messagebus_test/src/tests/speed/FILES +++ /dev/null @@ -1,8 +0,0 @@ -speed.cpp -out.server.cpp -out.server.java -cpp-client.cpp -cpp-server.cpp -JavaClient.java -JavaServer.java -routing-template.cfg diff --git a/messagebus_test/src/tests/speed/JavaClient.java b/messagebus_test/src/tests/speed/JavaClient.java deleted file mode 100644 index b905ab07e91..00000000000 --- a/messagebus_test/src/tests/speed/JavaClient.java +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -import com.yahoo.messagebus.*; -import com.yahoo.messagebus.test.*; -import com.yahoo.config.*; -import com.yahoo.messagebus.routing.*; -import com.yahoo.messagebus.network.*; -import com.yahoo.messagebus.network.rpc.*; -import java.util.Arrays; -import java.util.logging.*; - -public class JavaClient implements ReplyHandler { - - private static Logger log = Logger.getLogger(JavaClient.class.getName()); - - private static class Counts { - public int okCnt = 0; - public int failCnt = 0; - Counts() {} - Counts(int okCnt, int failCnt) { - this.okCnt = okCnt; - this.failCnt = failCnt; - } - } - - private SourceSession session; - private Counts counts = new Counts(); - private static long mySeq = 100000; - - public JavaClient(RPCMessageBus mb) { - session = mb.getMessageBus().createSourceSession(this, new SourceSessionParams().setTimeout(30)); - } - - public synchronized Counts sample() { - return new Counts(counts.okCnt, counts.failCnt); - } - - public void send() { - send(++mySeq); - } - - public void send(long seq) { - session.send(new MyMessage(seq), "test"); - } - - public void handleReply(Reply reply) { - if ((reply.getProtocol() == SimpleProtocol.NAME) - && (reply.getType() == SimpleProtocol.REPLY) - && (((SimpleReply)reply).getValue().equals("OK"))) - { - synchronized (this) { - counts.okCnt++; - } - } else { - synchronized (this) { - counts.failCnt++; - } - } - try { - send(); - } catch (IllegalStateException ignore) {} // handle paranoia for shutdown source sessions - } - - public void shutdown() { - session.destroy(); - } - - public static void main(String[] args) { - try { - RPCMessageBus mb = new RPCMessageBus( - new MessageBusParams() - .setRetryPolicy(new RetryTransientErrorsPolicy().setBaseDelay(0.1)) - .addProtocol(new SimpleProtocol()), - new RPCNetworkParams() - .setIdentity(new Identity("server/java")) - .setSlobrokConfigId("file:slobrok.cfg"), - "file:routing.cfg"); - JavaClient client = new JavaClient(mb); - - // let the system 'warm up' - Thread.sleep(5000); - - // inject messages into the feedback loop - for (int i = 0; i < 1024; ++i) { - client.send(i); - } - - // let the system 'warm up' - Thread.sleep(5000); - - long start; - long stop; - Counts before; - Counts after; - - start = System.currentTimeMillis(); - before = client.sample(); - Thread.sleep(10000); // Benchmark time - stop = System.currentTimeMillis(); - after = client.sample(); - stop -= start; - double time = (double)stop; - double msgCnt = (double)(after.okCnt - before.okCnt); - double throughput = (msgCnt / time) * 1000.0; - System.out.printf("JAVA-CLIENT: %g msg/s\n", throughput); - client.shutdown(); - mb.destroy(); - if (after.failCnt > before.failCnt) { - System.err.printf("JAVA-CLIENT: FAILED (%d -> %d)\n", - before.failCnt, after.failCnt); - System.exit(1); - } - } catch (Exception e) { - log.log(Level.SEVERE, "JAVA-CLIENT: Failed", e); - System.exit(1); - } - } - - private static class MyMessage extends SimpleMessage { - - final long seqId; - - MyMessage(long seqId) { - super("message"); - this.seqId = seqId; - } - - @Override - public boolean hasSequenceId() { - return true; - } - - @Override - public long getSequenceId() { - return seqId; - } - } -} diff --git a/messagebus_test/src/tests/speed/JavaServer.java b/messagebus_test/src/tests/speed/JavaServer.java deleted file mode 100644 index afec6dcdba2..00000000000 --- a/messagebus_test/src/tests/speed/JavaServer.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -import com.yahoo.messagebus.*; -import com.yahoo.messagebus.test.*; -import com.yahoo.config.*; -import com.yahoo.messagebus.routing.*; -import com.yahoo.messagebus.network.*; -import com.yahoo.messagebus.network.rpc.*; -import java.util.Arrays; -import java.util.logging.*; - -public class JavaServer implements MessageHandler { - - private static Logger log = Logger.getLogger(JavaServer.class.getName()); - - private DestinationSession session; - - public JavaServer(RPCMessageBus mb) { - session = mb.getMessageBus().createDestinationSession("session", true, this); - } - - public void handleMessage(Message msg) { - if ((msg.getProtocol() == SimpleProtocol.NAME) - && (msg.getType() == SimpleProtocol.MESSAGE) - && (((SimpleMessage)msg).getValue().equals("message"))) - { - Reply reply = new SimpleReply("OK"); - msg.swapState(reply); - session.reply(reply); - } else { - Reply reply = new SimpleReply("FAIL"); - msg.swapState(reply); - session.reply(reply); - } - } - - public static void main(String[] args) { - try { - RPCMessageBus mb = new RPCMessageBus( - Arrays.asList((Protocol)new SimpleProtocol()), - new RPCNetworkParams() - .setIdentity(new Identity("server/java")) - .setSlobrokConfigId("file:slobrok.cfg"), - "file:routing.cfg"); - JavaServer server = new JavaServer(mb); - System.out.println("java server started"); - while (true) { - Thread.sleep(1000); - } - } catch (Exception e) { - log.log(Level.SEVERE, "JAVA-SERVER: Failed", e); - System.exit(1); - } - } -} diff --git a/messagebus_test/src/tests/speed/cpp-client.cpp b/messagebus_test/src/tests/speed/cpp-client.cpp deleted file mode 100644 index c0c9d621a20..00000000000 --- a/messagebus_test/src/tests/speed/cpp-client.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("cpp-client"); -#include <vespa/messagebus/messagebus.h> -#include <vespa/messagebus/routing/retrytransienterrorspolicy.h> -#include <vespa/messagebus/rpcmessagebus.h> -#include <vespa/messagebus/sourcesession.h> -#include <vespa/messagebus/sourcesessionparams.h> -#include <vespa/messagebus/testlib/simplemessage.h> -#include <vespa/messagebus/testlib/simpleprotocol.h> -#include <vespa/messagebus/testlib/simplereply.h> -#include <vespa/vespalib/util/sync.h> - -using namespace mbus; - -class Client : public IReplyHandler -{ -private: - vespalib::Lock _lock; - uint32_t _okCnt; - uint32_t _failCnt; - SourceSession::UP _session; - static uint64_t _seq; -public: - Client(MessageBus &bus, const SourceSessionParams ¶ms); - ~Client(); - void send(); - void send(uint64_t seq); - void sample(uint32_t &okCnt, uint32_t &failCnt); - void handleReply(Reply::UP reply); -}; -uint64_t Client::_seq = 100000; - -Client::Client(MessageBus &bus, const SourceSessionParams ¶ms) - : _lock(), - _okCnt(0), - _failCnt(0), - _session(bus.createSourceSession(*this, params)) -{ -} - -Client::~Client() -{ - _session->close(); -} - -void -Client::send() { - send(++_seq); -} - -void -Client::send(uint64_t seq) { - Message::UP msg(new SimpleMessage("message", true, seq)); - _session->send(std::move(msg), "test"); -} - -void -Client::sample(uint32_t &okCnt, uint32_t &failCnt) { - vespalib::LockGuard guard(_lock); - okCnt = _okCnt; - failCnt = _failCnt; -} - -void -Client::handleReply(Reply::UP reply) { - if ((reply->getProtocol() == SimpleProtocol::NAME) - && (reply->getType() == SimpleProtocol::REPLY) - && (static_cast<SimpleReply&>(*reply).getValue() == "OK")) - { - vespalib::LockGuard guard(_lock); - ++_okCnt; - } else { - fprintf(stderr, "BAD REPLY\n"); - for (uint32_t i = 0; i < reply->getNumErrors(); ++i) { - fprintf(stderr, "ERR[%d]: code=%d, msg=%s\n", i, - reply->getError(i).getCode(), - reply->getError(i).getMessage().c_str()); - } - vespalib::LockGuard guard(_lock); - ++_failCnt; - } - send(); -} - -class App : public FastOS_Application -{ -public: - int Main(); -}; - -int -App::Main() -{ - RetryTransientErrorsPolicy::SP retryPolicy(new RetryTransientErrorsPolicy()); - retryPolicy->setBaseDelay(0.1); - RPCMessageBus mb(MessageBusParams().setRetryPolicy(retryPolicy).addProtocol(IProtocol::SP(new SimpleProtocol())), - RPCNetworkParams().setIdentity(Identity("server/cpp")).setSlobrokConfig("file:slobrok.cfg"), - "file:routing.cfg"); - Client client(mb.getMessageBus(), SourceSessionParams().setTimeout(30)); - - // let the system 'warm up' - FastOS_Thread::Sleep(5000); - - // inject messages into the feedback loop - for (uint32_t i = 0; i < 1024; ++i) { - client.send(i); - } - - // let the system 'warm up' - FastOS_Thread::Sleep(5000); - - FastOS_Time start; - FastOS_Time stop; - uint32_t okBefore = 0; - uint32_t okAfter = 0; - uint32_t failBefore = 0; - uint32_t failAfter = 0; - - start.SetNow(); - client.sample(okBefore, failBefore); - FastOS_Thread::Sleep(10000); // Benchmark time - stop.SetNow(); - client.sample(okAfter, failAfter); - stop -= start; - double time = stop.MilliSecs(); - double msgCnt = (double)(okAfter - okBefore); - double throughput = (msgCnt / time) * 1000.0; - fprintf(stdout, "CPP-CLIENT: %g msg/s\n", throughput); - if (failAfter > failBefore) { - fprintf(stderr, "CPP-CLIENT: FAILED (%d -> %d)\n", failBefore, failAfter); - return 1; - } - return 0; -} - -int main(int argc, char **argv) { - fprintf(stderr, "started '%s'\n", argv[0]); - fflush(stderr); - App app; - int r = app.Entry(argc, argv); - fprintf(stderr, "stopping '%s'\n", argv[0]); - fflush(stderr); - return r; -} diff --git a/messagebus_test/src/tests/speed/cpp-server.cpp b/messagebus_test/src/tests/speed/cpp-server.cpp deleted file mode 100644 index c2cd9bf262a..00000000000 --- a/messagebus_test/src/tests/speed/cpp-server.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("cpp-server"); -#include <vespa/messagebus/messagebus.h> -#include <vespa/messagebus/destinationsession.h> -#include <vespa/messagebus/testlib/simplemessage.h> -#include <vespa/messagebus/testlib/simplereply.h> -#include <vespa/messagebus/testlib/simpleprotocol.h> -#include <vespa/messagebus/rpcmessagebus.h> -#include <vespa/messagebus/iprotocol.h> -#include <vespa/messagebus/protocolset.h> - -using namespace mbus; - -class Server : public IMessageHandler -{ -private: - DestinationSession::UP _session; -public: - Server(MessageBus &bus); - ~Server(); - void handleMessage(Message::UP msg); -}; - -Server::Server(MessageBus &bus) - : _session(bus.createDestinationSession("session", true, *this)) -{ - fprintf(stderr, "cpp server started\n"); -} - -Server::~Server() -{ - _session.reset(); -} - -void -Server::handleMessage(Message::UP msg) { - if ((msg->getProtocol() == SimpleProtocol::NAME) - && (msg->getType() == SimpleProtocol::MESSAGE) - && (static_cast<SimpleMessage&>(*msg).getValue() == "message")) - { - Reply::UP reply(new SimpleReply("OK")); - msg->swapState(*reply); - _session->reply(std::move(reply)); - } else { - Reply::UP reply(new SimpleReply("FAIL")); - msg->swapState(*reply); - _session->reply(std::move(reply)); - } -} - -class App : public FastOS_Application -{ -public: - int Main(); -}; - -int -App::Main() -{ - RPCMessageBus mb(ProtocolSet().add(IProtocol::SP(new SimpleProtocol())), - RPCNetworkParams() - .setIdentity(Identity("server/cpp")) - .setSlobrokConfig("file:slobrok.cfg"), - "file:routing.cfg"); - Server server(mb.getMessageBus()); - while (true) { - FastOS_Thread::Sleep(1000); - } - return 0; -} - -int main(int argc, char **argv) { - App app; - return app.Entry(argc, argv); -} diff --git a/messagebus_test/src/tests/speed/ctl.sh b/messagebus_test/src/tests/speed/ctl.sh deleted file mode 100755 index ca4fc7701e6..00000000000 --- a/messagebus_test/src/tests/speed/ctl.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -if [ -z "$SOURCE_DIRECTORY" ]; then - SOURCE_DIRECTORY="." -fi - -. ../../binref/env.sh - -exec $SOURCE_DIRECTORY/../../binref/progctl.sh $SOURCE_DIRECTORY/progdefs.sh "$@" diff --git a/messagebus_test/src/tests/speed/progdefs.sh b/messagebus_test/src/tests/speed/progdefs.sh deleted file mode 100644 index 0b2bd600db0..00000000000 --- a/messagebus_test/src/tests/speed/progdefs.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -prog server cpp "" "./messagebus_test_cpp-server-speed_app" -prog server java "" "$BINREF/runjava JavaServer" diff --git a/messagebus_test/src/tests/speed/routing-template.cfg b/messagebus_test/src/tests/speed/routing-template.cfg deleted file mode 100644 index 4b938c9cc82..00000000000 --- a/messagebus_test/src/tests/speed/routing-template.cfg +++ /dev/null @@ -1,11 +0,0 @@ -routingtable[1] -routingtable[0].protocol "Simple" -routingtable[0].hop[1] -routingtable[0].hop[0].name "server" -routingtable[0].hop[0].selector "server/session" -routingtable[0].hop[0].recipient[1] -routingtable[0].hop[0].recipient[0] "server/session" -routingtable[0].route[1] -routingtable[0].route[0].name "test" -routingtable[0].route[0].hop[1] -routingtable[0].route[0].hop[0] "server" diff --git a/messagebus_test/src/tests/speed/speed.cpp b/messagebus_test/src/tests/speed/speed.cpp deleted file mode 100644 index 1cfe1ff5704..00000000000 --- a/messagebus_test/src/tests/speed/speed.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("speed_test"); -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/messagebus/testlib/slobrok.h> -#include <vespa/vespalib/util/stringfmt.h> - -using namespace mbus; -using vespalib::make_string; - -TEST_SETUP(Test); - -int -Test::Main() -{ - TEST_INIT("speed_test"); - Slobrok slobrok; - - const std::string routing_template = TEST_PATH("routing-template.cfg"); - const std::string ctl_script = TEST_PATH("ctl.sh"); - - { // Make slobrok config - EXPECT_EQUAL(system("echo slobrok[1] > slobrok.cfg"), 0); - EXPECT_EQUAL(system(make_string("echo 'slobrok[0].connectionspec tcp/localhost:%d' " - ">> slobrok.cfg", slobrok.port()).c_str()), 0); - } - { // CPP SERVER - { // Make routing config - EXPECT_EQUAL(system(("cat " + routing_template + " | sed 's#session#cpp/session#' > routing.cfg").c_str()), 0); - } - fprintf(stderr, "STARTING CPP-SERVER\n"); - EXPECT_EQUAL(system((ctl_script + " start server cpp").c_str()), 0); - fprintf(stderr, "STARTING CPP-CLIENT\n"); - EXPECT_EQUAL(system("./messagebus_test_cpp-client-speed_app"), 0); - fprintf(stderr, "STARTING JAVA-CLIENT\n"); - EXPECT_EQUAL(system("../../binref/runjava JavaClient"), 0); - fprintf(stderr, "STOPPING\n"); - EXPECT_EQUAL(system((ctl_script + " stop server cpp").c_str()), 0); - } - { // JAVA SERVER - { // Make routing config - EXPECT_EQUAL(system(("cat " + routing_template + " | sed 's#session#java/session#' > routing.cfg").c_str()), 0); - } - fprintf(stderr, "STARTING JAVA-SERVER\n"); - EXPECT_EQUAL(system((ctl_script + " start server java").c_str()), 0); - fprintf(stderr, "STARTING CPP-CLIENT\n"); - EXPECT_EQUAL(system("./messagebus_test_cpp-client-speed_app"), 0); - fprintf(stderr, "STARTING JAVA-CLIENT\n"); - EXPECT_EQUAL(system("../../binref/runjava JavaClient"), 0); - fprintf(stderr, "STOPPING\n"); - EXPECT_EQUAL(system((ctl_script + " stop server java").c_str()), 0); - } - TEST_DONE(); -} diff --git a/messagebus_test/src/tests/speed/speed_test.sh b/messagebus_test/src/tests/speed/speed_test.sh deleted file mode 100755 index 1d9ba27f84e..00000000000 --- a/messagebus_test/src/tests/speed/speed_test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -e - -if [ -z "$SOURCE_DIRECTORY" ]; then - SOURCE_DIRECTORY="." -fi - -. ../../binref/env.sh - -$BINREF/compilejava $SOURCE_DIRECTORY/JavaServer.java -$BINREF/compilejava $SOURCE_DIRECTORY/JavaClient.java - -(ulimit -c; ulimit -H -c; ulimit -c unlimited; $VALGRIND ./messagebus_test_speed_test_app) |