aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/test/src/tests/errorcodes
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /messagebus/test/src/tests/errorcodes
Publish
Diffstat (limited to 'messagebus/test/src/tests/errorcodes')
-rw-r--r--messagebus/test/src/tests/errorcodes/.gitignore7
-rw-r--r--messagebus/test/src/tests/errorcodes/CMakeLists.txt7
-rw-r--r--messagebus/test/src/tests/errorcodes/DESC2
-rw-r--r--messagebus/test/src/tests/errorcodes/DumpCodes.java51
-rw-r--r--messagebus/test/src/tests/errorcodes/FILES5
-rw-r--r--messagebus/test/src/tests/errorcodes/dumpcodes.cpp70
-rw-r--r--messagebus/test/src/tests/errorcodes/errorcodes_test.sh9
-rw-r--r--messagebus/test/src/tests/errorcodes/ref-dump.txt34
8 files changed, 185 insertions, 0 deletions
diff --git a/messagebus/test/src/tests/errorcodes/.gitignore b/messagebus/test/src/tests/errorcodes/.gitignore
new file mode 100644
index 00000000000..13957172a38
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/.gitignore
@@ -0,0 +1,7 @@
+.depend
+DumpCodes.class
+Makefile
+cpp-dump.txt
+dumpcodes
+java-dump.txt
+messagebus_test_dumpcodes_app
diff --git a/messagebus/test/src/tests/errorcodes/CMakeLists.txt b/messagebus/test/src/tests/errorcodes/CMakeLists.txt
new file mode 100644
index 00000000000..3f08783b363
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/CMakeLists.txt
@@ -0,0 +1,7 @@
+# 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_dumpcodes_app
+ SOURCES
+ dumpcodes.cpp
+ DEPENDS
+)
+vespa_add_test(NAME messagebus_test_dumpcodes_app NO_VALGRIND COMMAND sh errorcodes_test.sh)
diff --git a/messagebus/test/src/tests/errorcodes/DESC b/messagebus/test/src/tests/errorcodes/DESC
new file mode 100644
index 00000000000..103ebb4698f
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/DESC
@@ -0,0 +1,2 @@
+A small test to check that error codes are equal in the Java and C++
+implementations.
diff --git a/messagebus/test/src/tests/errorcodes/DumpCodes.java b/messagebus/test/src/tests/errorcodes/DumpCodes.java
new file mode 100644
index 00000000000..8eb97813404
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/DumpCodes.java
@@ -0,0 +1,51 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+import com.yahoo.messagebus.ErrorCode;
+
+public class DumpCodes {
+
+ private static void dump(String desc, int value) {
+ String name = ErrorCode.getName(value);
+ System.out.printf("%s => %d => \"%s\"\n", desc, value,
+ name != null ? name : "");
+ }
+
+ public static void main(String[] args) {
+ dump("NONE", ErrorCode.NONE);
+
+ dump("SEND_QUEUE_FULL", ErrorCode.SEND_QUEUE_FULL);
+ dump("NO_ADDRESS_FOR_SERVICE", ErrorCode.NO_ADDRESS_FOR_SERVICE);
+ dump("CONNECTION_ERROR", ErrorCode.CONNECTION_ERROR);
+ dump("UNKNOWN_SESSION", ErrorCode.UNKNOWN_SESSION);
+ dump("SESSION_BUSY", ErrorCode.SESSION_BUSY);
+ dump("SEND_ABORTED", ErrorCode.SEND_ABORTED);
+ dump("HANDSHAKE_FAILED", ErrorCode.HANDSHAKE_FAILED);
+ dump("first unused TRANSIENT_ERROR", ErrorCode.TRANSIENT_ERROR + 8);
+
+ dump("SEND_QUEUE_CLOSED", ErrorCode.SEND_QUEUE_CLOSED);
+ dump("ILLEGAL_ROUTE", ErrorCode.ILLEGAL_ROUTE);
+ dump("NO_SERVICES_FOR_ROUTE", ErrorCode.NO_SERVICES_FOR_ROUTE);
+ dump("SERVICE_OOS", ErrorCode.SERVICE_OOS);
+ dump("ENCODE_ERROR", ErrorCode.ENCODE_ERROR);
+ dump("NETWORK_ERROR", ErrorCode.NETWORK_ERROR);
+ dump("UNKNOWN_PROTOCOL", ErrorCode.UNKNOWN_PROTOCOL);
+ dump("DECODE_ERROR", ErrorCode.DECODE_ERROR);
+ dump("TIMEOUT", ErrorCode.TIMEOUT);
+ dump("INCOMPATIBLE_VERSION", ErrorCode.INCOMPATIBLE_VERSION);
+ dump("UNKNOWN_POLICY", ErrorCode.UNKNOWN_POLICY);
+ dump("NETWORK_SHUTDOWN", ErrorCode.NETWORK_SHUTDOWN);
+ dump("POLICY_ERROR", ErrorCode.POLICY_ERROR);
+ dump("SEQUENCE_ERROR", ErrorCode.SEQUENCE_ERROR);
+ dump("first unused FATAL_ERROR", ErrorCode.FATAL_ERROR + 15);
+
+ dump("max UNKNOWN below", ErrorCode.TRANSIENT_ERROR - 1);
+ dump("min TRANSIENT_ERROR", ErrorCode.TRANSIENT_ERROR);
+ dump("max TRANSIENT_ERROR", ErrorCode.TRANSIENT_ERROR + 49999);
+ dump("min APP_TRANSIENT_ERROR", ErrorCode.APP_TRANSIENT_ERROR);
+ dump("max APP_TRANSIENT_ERROR", ErrorCode.APP_TRANSIENT_ERROR + 49999);
+ dump("min FATAL_ERROR", ErrorCode.FATAL_ERROR);
+ dump("max FATAL_ERROR", ErrorCode.FATAL_ERROR + 49999);
+ dump("min APP_FATAL_ERROR", ErrorCode.APP_FATAL_ERROR);
+ dump("max APP_FATAL_ERROR", ErrorCode.APP_FATAL_ERROR + 49999);
+ dump("min UNKNOWN above", ErrorCode.ERROR_LIMIT);
+ }
+}
diff --git a/messagebus/test/src/tests/errorcodes/FILES b/messagebus/test/src/tests/errorcodes/FILES
new file mode 100644
index 00000000000..766402133fb
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/FILES
@@ -0,0 +1,5 @@
+dumpcodes.cpp
+DumpCodes.java
+ref-dump.txt
+cpp-dump.txt
+java-dump.txt
diff --git a/messagebus/test/src/tests/errorcodes/dumpcodes.cpp b/messagebus/test/src/tests/errorcodes/dumpcodes.cpp
new file mode 100644
index 00000000000..121d8585726
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/dumpcodes.cpp
@@ -0,0 +1,70 @@
+// 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("dumpcodes");
+#include <vespa/messagebus/errorcode.h>
+#include <string>
+
+using namespace mbus;
+
+class App : public FastOS_Application
+{
+public:
+ void dump(const std::string &desc, uint32_t value);
+ int Main();
+};
+
+void
+App::dump(const std::string &desc, uint32_t value)
+{
+ fprintf(stdout, "%s => %u => \"%s\"\n", desc.c_str(), value,
+ ErrorCode::getName(value).c_str());
+}
+
+int
+App::Main()
+{
+ dump("NONE", ErrorCode::NONE);
+
+ dump("SEND_QUEUE_FULL", ErrorCode::SEND_QUEUE_FULL);
+ dump("NO_ADDRESS_FOR_SERVICE", ErrorCode::NO_ADDRESS_FOR_SERVICE);
+ dump("CONNECTION_ERROR", ErrorCode::CONNECTION_ERROR);
+ dump("UNKNOWN_SESSION", ErrorCode::UNKNOWN_SESSION);
+ dump("SESSION_BUSY", ErrorCode::SESSION_BUSY);
+ dump("SEND_ABORTED", ErrorCode::SEND_ABORTED);
+ dump("HANDSHAKE_FAILED", ErrorCode::HANDSHAKE_FAILED);
+ dump("first unused TRANSIENT_ERROR", ErrorCode::TRANSIENT_ERROR + 8);
+
+ dump("SEND_QUEUE_CLOSED", ErrorCode::SEND_QUEUE_CLOSED);
+ dump("ILLEGAL_ROUTE", ErrorCode::ILLEGAL_ROUTE);
+ dump("NO_SERVICES_FOR_ROUTE", ErrorCode::NO_SERVICES_FOR_ROUTE);
+ dump("SERVICE_OOS", ErrorCode::SERVICE_OOS);
+ dump("ENCODE_ERROR", ErrorCode::ENCODE_ERROR);
+ dump("NETWORK_ERROR", ErrorCode::NETWORK_ERROR);
+ dump("UNKNOWN_PROTOCOL", ErrorCode::UNKNOWN_PROTOCOL);
+ dump("DECODE_ERROR", ErrorCode::DECODE_ERROR);
+ dump("TIMEOUT", ErrorCode::TIMEOUT);
+ dump("INCOMPATIBLE_VERSION", ErrorCode::INCOMPATIBLE_VERSION);
+ dump("UNKNOWN_POLICY", ErrorCode::UNKNOWN_POLICY);
+ dump("NETWORK_SHUTDOWN", ErrorCode::NETWORK_SHUTDOWN);
+ dump("POLICY_ERROR", ErrorCode::POLICY_ERROR);
+ dump("SEQUENCE_ERROR", ErrorCode::SEQUENCE_ERROR);
+ dump("first unused FATAL_ERROR", ErrorCode::FATAL_ERROR + 15);
+
+ dump("max UNKNOWN below", ErrorCode::TRANSIENT_ERROR - 1);
+ dump("min TRANSIENT_ERROR", ErrorCode::TRANSIENT_ERROR);
+ dump("max TRANSIENT_ERROR", ErrorCode::TRANSIENT_ERROR + 49999);
+ dump("min APP_TRANSIENT_ERROR", ErrorCode::APP_TRANSIENT_ERROR);
+ dump("max APP_TRANSIENT_ERROR", ErrorCode::APP_TRANSIENT_ERROR + 49999);
+ dump("min FATAL_ERROR", ErrorCode::FATAL_ERROR);
+ dump("max FATAL_ERROR", ErrorCode::FATAL_ERROR + 49999);
+ dump("min APP_FATAL_ERROR", ErrorCode::APP_FATAL_ERROR);
+ dump("max APP_FATAL_ERROR", ErrorCode::APP_FATAL_ERROR + 49999);
+ dump("min UNKNOWN above", ErrorCode::ERROR_LIMIT);
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ App app;
+ return app.Entry(argc, argv);
+}
diff --git a/messagebus/test/src/tests/errorcodes/errorcodes_test.sh b/messagebus/test/src/tests/errorcodes/errorcodes_test.sh
new file mode 100644
index 00000000000..186de0a5033
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/errorcodes_test.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+. ../../binref/env.sh
+
+$BINREF/compilejava DumpCodes.java
+
+./messagebus_test_dumpcodes_app > cpp-dump.txt
+$BINREF/runjava DumpCodes > java-dump.txt
+diff -u ref-dump.txt cpp-dump.txt
+diff -u ref-dump.txt java-dump.txt
diff --git a/messagebus/test/src/tests/errorcodes/ref-dump.txt b/messagebus/test/src/tests/errorcodes/ref-dump.txt
new file mode 100644
index 00000000000..b8038816897
--- /dev/null
+++ b/messagebus/test/src/tests/errorcodes/ref-dump.txt
@@ -0,0 +1,34 @@
+NONE => 0 => "NONE"
+SEND_QUEUE_FULL => 100001 => "SEND_QUEUE_FULL"
+NO_ADDRESS_FOR_SERVICE => 100002 => "NO_ADDRESS_FOR_SERVICE"
+CONNECTION_ERROR => 100003 => "CONNECTION_ERROR"
+UNKNOWN_SESSION => 100004 => "UNKNOWN_SESSION"
+SESSION_BUSY => 100005 => "SESSION_BUSY"
+SEND_ABORTED => 100006 => "SEND_ABORTED"
+HANDSHAKE_FAILED => 100007 => "HANDSHAKE_FAILED"
+first unused TRANSIENT_ERROR => 100008 => "UNKNOWN(100008)"
+SEND_QUEUE_CLOSED => 200001 => "SEND_QUEUE_CLOSED"
+ILLEGAL_ROUTE => 200002 => "ILLEGAL_ROUTE"
+NO_SERVICES_FOR_ROUTE => 200003 => "NO_SERVICES_FOR_ROUTE"
+SERVICE_OOS => 200004 => "SERVICE_OOS"
+ENCODE_ERROR => 200005 => "ENCODE_ERROR"
+NETWORK_ERROR => 200006 => "NETWORK_ERROR"
+UNKNOWN_PROTOCOL => 200007 => "UNKNOWN_PROTOCOL"
+DECODE_ERROR => 200008 => "DECODE_ERROR"
+TIMEOUT => 200009 => "TIMEOUT"
+INCOMPATIBLE_VERSION => 200010 => "INCOMPATIBLE_VERSION"
+UNKNOWN_POLICY => 200011 => "UNKNOWN_POLICY"
+NETWORK_SHUTDOWN => 200012 => "NETWORK_SHUTDOWN"
+POLICY_ERROR => 200013 => "POLICY_ERROR"
+SEQUENCE_ERROR => 200014 => "SEQUENCE_ERROR"
+first unused FATAL_ERROR => 200015 => "UNKNOWN(200015)"
+max UNKNOWN below => 99999 => "UNKNOWN(99999)"
+min TRANSIENT_ERROR => 100000 => "TRANSIENT_ERROR"
+max TRANSIENT_ERROR => 149999 => "UNKNOWN(149999)"
+min APP_TRANSIENT_ERROR => 150000 => "APP_TRANSIENT_ERROR"
+max APP_TRANSIENT_ERROR => 199999 => "UNKNOWN(199999)"
+min FATAL_ERROR => 200000 => "FATAL_ERROR"
+max FATAL_ERROR => 249999 => "UNKNOWN(249999)"
+min APP_FATAL_ERROR => 250000 => "APP_FATAL_ERROR"
+max APP_FATAL_ERROR => 299999 => "UNKNOWN(299999)"
+min UNKNOWN above => 300000 => "UNKNOWN(300000)"