diff options
author | Henning Baldersheim <balder@oath.com> | 2018-04-16 15:39:21 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-04-16 15:39:21 +0200 |
commit | 382951509d1f3b054d9241ef98d1c5a6eac3834c (patch) | |
tree | 41850ad8bb5c7251fd7a98ea6ba65ce9773d5cbd /documentapi/src/tests | |
parent | 49d2314efda87f61fd37665ebeac766b06a731fa (diff) |
Remove unused systemstate
Diffstat (limited to 'documentapi/src/tests')
-rw-r--r-- | documentapi/src/tests/policies/testframe.cpp | 7 | ||||
-rw-r--r-- | documentapi/src/tests/policies/testframe.h | 7 | ||||
-rw-r--r-- | documentapi/src/tests/systemstate/.gitignore | 4 | ||||
-rw-r--r-- | documentapi/src/tests/systemstate/CMakeLists.txt | 8 | ||||
-rw-r--r-- | documentapi/src/tests/systemstate/DESC | 3 | ||||
-rw-r--r-- | documentapi/src/tests/systemstate/FILES | 1 | ||||
-rw-r--r-- | documentapi/src/tests/systemstate/systemstate.cpp | 226 |
7 files changed, 0 insertions, 256 deletions
diff --git a/documentapi/src/tests/policies/testframe.cpp b/documentapi/src/tests/policies/testframe.cpp index 024a0c2fdaa..d99d99b9ec0 100644 --- a/documentapi/src/tests/policies/testframe.cpp +++ b/documentapi/src/tests/policies/testframe.cpp @@ -322,13 +322,6 @@ TestFrame::waitSlobrok(const string &pattern, uint32_t cnt) return false; } -SystemStateHandle -TestFrame::getSystemState() -{ - mbus::IProtocol * protocol = _mbus->getProtocol(DocumentProtocol::NAME); - return SystemStateHandle(static_cast<DocumentProtocol&>(*protocol).getSystemState()); -} - void TestFrame::handleReply(mbus::Reply::UP reply) { diff --git a/documentapi/src/tests/policies/testframe.h b/documentapi/src/tests/policies/testframe.h index 15ec61aff7b..cc5101905a1 100644 --- a/documentapi/src/tests/policies/testframe.h +++ b/documentapi/src/tests/policies/testframe.h @@ -2,7 +2,6 @@ #pragma once #include <vespa/documentapi/messagebus/documentprotocol.h> -#include <vespa/documentapi/messagebus/systemstate/systemstatehandle.h> #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/network/identity.h> #include <vespa/messagebus/network/inetwork.h> @@ -190,12 +189,6 @@ public: */ mbus::Receptor &getReceptor() { return _handler; } - /** - * Returns the system state from contained document protocol. - * - * @return Handle to the system state. - */ - documentapi::SystemStateHandle getSystemState(); void handleReply(mbus::Reply::UP reply) override; }; diff --git a/documentapi/src/tests/systemstate/.gitignore b/documentapi/src/tests/systemstate/.gitignore deleted file mode 100644 index 3f52bc38742..00000000000 --- a/documentapi/src/tests/systemstate/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -systemstate_test -documentapi_systemstate_test_app diff --git a/documentapi/src/tests/systemstate/CMakeLists.txt b/documentapi/src/tests/systemstate/CMakeLists.txt deleted file mode 100644 index b275f2b2fd0..00000000000 --- a/documentapi/src/tests/systemstate/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(documentapi_systemstate_test_app TEST - SOURCES - systemstate.cpp - DEPENDS - documentapi -) -vespa_add_test(NAME documentapi_systemstate_test_app COMMAND documentapi_systemstate_test_app) diff --git a/documentapi/src/tests/systemstate/DESC b/documentapi/src/tests/systemstate/DESC deleted file mode 100644 index 19dbc9195f1..00000000000 --- a/documentapi/src/tests/systemstate/DESC +++ /dev/null @@ -1,3 +0,0 @@ -This is a unit test for the system state parser and the corresponding NodeState class. It mirrors the -StateParserTestCase available in the java implementation of message bus. It consists of tests that verify that parsing -works, pathing works, encoding/decoding works, and finally that the NodeState class works as intended. diff --git a/documentapi/src/tests/systemstate/FILES b/documentapi/src/tests/systemstate/FILES deleted file mode 100644 index e1d0e026d31..00000000000 --- a/documentapi/src/tests/systemstate/FILES +++ /dev/null @@ -1 +0,0 @@ -systemstate.cpp diff --git a/documentapi/src/tests/systemstate/systemstate.cpp b/documentapi/src/tests/systemstate/systemstate.cpp deleted file mode 100644 index 3e42c94950a..00000000000 --- a/documentapi/src/tests/systemstate/systemstate.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/documentapi/messagebus/systemstate/systemstate.h> -#include <vespa/documentapi/messagebus/systemstate/nodestate.h> -#include <vespa/documentapi/messagebus/systemstate/systemstatehandle.h> -#include <vespa/vespalib/testkit/testapp.h> - -#include <vespa/log/log.h> -LOG_SETUP("systemstate_test"); - -using namespace documentapi; - -class Test : public vespalib::TestApp { -public: - int Main() override; - void testParser(); - void testPathing(); - void testState(); - void testEncoding(); - void testHandle(); - void testCompact(); - -private: - void assertParser(const string &state, const string &expected = ""); -}; - -TEST_APPHOOK(Test); - -int -Test::Main() -{ - TEST_INIT("systemstate_test"); - - testParser(); TEST_FLUSH(); - testPathing(); TEST_FLUSH(); - testState(); TEST_FLUSH(); - testEncoding(); TEST_FLUSH(); - testHandle(); TEST_FLUSH(); - testCompact(); TEST_FLUSH(); - - TEST_DONE(); - return 0; -} - -void -Test::testParser() -{ - assertParser("storage"); - assertParser("storage?", "ERROR"); - assertParser("storage?a", "ERROR"); - assertParser("storage?a=", "ERROR"); - assertParser("storage?a=1"); - assertParser("storage?a=1&", "ERROR"); - assertParser("storage?a=1&b", "ERROR"); - assertParser("storage?a=1&b=2"); - assertParser("storage?a=1&b=2 search"); - assertParser("storage?a=1&b=2 search?", "ERROR"); - assertParser("storage?a=1&b=2 search?a", "ERROR"); - assertParser("storage?a=1&b=2 search?a=", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1"); - assertParser("storage?a=1&b=2 search?a=1&", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1&b", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1&b=", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1&b=2"); - - assertParser("storage"); - assertParser("storage/"); - assertParser("storage/?", "ERROR"); - assertParser("storage/?a", "ERROR"); - assertParser("storage/?a=", "ERROR"); - assertParser("storage/?a=1"); - assertParser("storage/cluster.storage"); - assertParser("storage/cluster.storage/"); - - assertParser("storage?a=1"); - assertParser("storage/?a=1"); - assertParser("storage/.?a=1"); - assertParser("storage/./?a=1"); - assertParser("storage/./cluster.storage?a=1"); - assertParser("storage/./cluster.storage/?a=1"); - assertParser("storage/./cluster.storage/..?a=1"); - assertParser("storage/./cluster.storage/../?a=1"); - assertParser("storage/./cluster.storage/../storage?a=1"); - assertParser("storage/./cluster.storage/../storage/?a=1"); -} - -void -Test::testPathing() -{ - assertParser("storage?a=1", "storage?a=1"); - assertParser("storage/?a=1", "storage?a=1"); - assertParser("storage/.?a=1", "storage?a=1"); - assertParser("storage/./?a=1", "storage?a=1"); - assertParser("storage/./cluster.storage?a=1", "storage/cluster.storage?a=1"); - assertParser("storage/./cluster.storage/?a=1", "storage/cluster.storage?a=1"); - assertParser("storage/./cluster.storage/..?a=1", "storage?a=1"); - assertParser("storage/./cluster.storage/../?a=1", "storage?a=1"); - assertParser("storage/./cluster.storage/../storage?a=1", "storage/storage?a=1"); - assertParser("storage/./cluster.storage/../storage/?a=1", "storage/storage?a=1"); - - assertParser("a?p1=1 a/b?p2=2 a/b/c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a .?p1=1 ./b?p2=2 ./b/c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a .?p1=1 ./../a/b/ .?p2=2 c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a/./ .?p1=1 ../a/b/c/.. .?p2=2 ./c/../c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a/b/c/d/ ../../ ../ ../a .?p1=1 ./b?p2=2 ./ ../a/b/c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - - assertParser("a/b/c/d?p1=1 a?p2=2", "a?p2=2 a/b/c/d?p1=1"); - assertParser("a/b/c/d/?p1=1 /a?p2=2", "a?p2=2 a/b/c/d?p1=1"); - assertParser("/a/b/c/d/?p1=1 /a?p2=2", "a?p2=2 a/b/c/d?p1=1"); - - assertParser("a .?p1=1", "a?p1=1"); - assertParser("a/b .?p1=1", "a/b?p1=1"); - assertParser("a/b c?p1=1 d?p2=2", "a/b/c?p1=1 a/b/d?p2=2"); -} - -void -Test::testState() -{ - NodeState state; - state - .addChild("distributor", NodeState() - .setState("n", "27")) - .addChild("storage", NodeState() - .setState("n", "170") - .addChild("2", NodeState() - .setState("s", "d")) - .addChild("13", NodeState() - .setState("s", "r") - .setState("c", "0.0"))); - - EXPECT_EQUAL("27", state.getState("distributor/n")); - EXPECT_EQUAL("170", state.getState("storage/n")); - EXPECT_EQUAL("d", state.getState("storage/2/s")); - EXPECT_EQUAL("r", state.getState("storage/13/s")); - EXPECT_EQUAL("0.0", state.getState("storage/13/c")); - - EXPECT_EQUAL("27", state.getChild("distributor")->getState("n")); - EXPECT_EQUAL("170", state.getChild("storage")->getState("n")); - EXPECT_EQUAL("d", state.getChild("storage")->getChild("2")->getState("s")); - EXPECT_EQUAL("r", state.getChild("storage")->getChild("13")->getState("s")); - EXPECT_EQUAL("0.0", state.getChild("storage")->getChild("13")->getState("c")); -} - -void -Test::testEncoding() -{ - NodeState state; - state.setState("foo", "http://search.yahoo.com/?query=bar"); - LOG(info, "'%s'", state.toString().c_str()); - EXPECT_EQUAL(".?foo=http%3A%2F%2Fsearch.yahoo.com%2F%3Fquery%3Dbar", state.toString()); - assertParser(state.toString(), state.toString()); - - state = NodeState() - .addChild("foo:bar", NodeState() - .setState("foo", "http://search.yahoo.com/?query=bar")); - LOG(info, "'%s'", state.toString().c_str()); - EXPECT_EQUAL("foo%3Abar?foo=http%3A%2F%2Fsearch.yahoo.com%2F%3Fquery%3Dbar", state.toString()); - assertParser(state.toString(), state.toString()); - - state = NodeState() - .addChild("foo/bar", NodeState() - .setState("foo", "http://search.yahoo.com/?query=bar")); - LOG(info, "'%s'", state.toString().c_str()); - EXPECT_EQUAL("foo/bar?foo=http%3A%2F%2Fsearch.yahoo.com%2F%3Fquery%3Dbar", state.toString()); - assertParser(state.toString(), state.toString()); -} - -void -Test::testHandle() -{ - SystemState::UP state(SystemState::newInstance("")); - ASSERT_TRUE(state.get() != NULL); - - SystemStateHandle handle(*state); - ASSERT_TRUE(handle.isValid()); - - SystemStateHandle hoe(std::move(handle)); - ASSERT_TRUE(!handle.isValid()); - ASSERT_TRUE(hoe.isValid()); -} - -void -Test::testCompact() -{ - NodeState state; - state - .setState("a/b0/s", "d") - .setState("a/b0/c0/s", "d") - .setState("a/b0/c1/s", "d") - .setState("a/b1/s", "d") - .setState("a/b1/c0/s", "d") - .setState("a/b1/c1/s", "d"); - EXPECT_EQUAL("a/b0?s=d a/b0/c0?s=d a/b0/c1?s=d a/b1?s=d a/b1/c0?s=d a/b1/c1?s=d", state.toString()); - - state.removeChild("a/b0/c0"); - EXPECT_EQUAL("a/b0?s=d a/b0/c1?s=d a/b1?s=d a/b1/c0?s=d a/b1/c1?s=d", state.toString()); - - state.removeState("a/b0/c1/s"); - EXPECT_EQUAL("a/b0?s=d a/b1?s=d a/b1/c0?s=d a/b1/c1?s=d", state.toString()); - - state.setState("a/b1/c0/s", ""); - EXPECT_EQUAL("a/b0?s=d a/b1?s=d a/b1/c1?s=d", state.toString()); - - state.removeChild("a/b1"); - EXPECT_EQUAL("a/b0?s=d", state.toString()); - - state.removeChild("a"); - EXPECT_EQUAL("", state.toString()); -} - -void -Test::assertParser(const string &state, const string &expected) -{ - SystemState::UP obj = SystemState::newInstance(state); - if (obj.get() == NULL) { - EXPECT_EQUAL("ERROR", expected); - } - else { - SystemStateHandle handle(*obj); - LOG(info, "'%s' => '%s'", state.c_str(), handle.getRoot().toString().c_str()); - if (!expected.empty()) { - EXPECT_EQUAL(expected, handle.getRoot().toString()); - } - } -} - |