aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/tests
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2018-02-22 12:48:47 +0000
committerTor Egge <Tor.Egge@oath.com>2018-02-22 12:48:47 +0000
commit6cc9ca39379fbd9baf3cb01ef1f2b2cd85a51ed9 (patch)
treee60ef6799946586e1fbe0abe4b3f5d3e59caa00f /storage/src/tests
parent1e7d98b23ae6b97734e1248c6028075f9b3f5d2e (diff)
Add cluster state bundle which contains a baseline cluster state and
(later) a derived cluster state for each bucket space.
Diffstat (limited to 'storage/src/tests')
-rw-r--r--storage/src/tests/common/testnodestateupdater.cpp22
-rw-r--r--storage/src/tests/common/testnodestateupdater.h11
-rw-r--r--storage/src/tests/persistence/filestorage/filestormanagertest.cpp5
-rw-r--r--storage/src/tests/storageserver/statemanagertest.cpp7
4 files changed, 31 insertions, 14 deletions
diff --git a/storage/src/tests/common/testnodestateupdater.cpp b/storage/src/tests/common/testnodestateupdater.cpp
index 58e8c2ea73d..18f296e5583 100644
--- a/storage/src/tests/common/testnodestateupdater.cpp
+++ b/storage/src/tests/common/testnodestateupdater.cpp
@@ -1,14 +1,32 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "testnodestateupdater.h"
+#include <vespa/storage/common/cluster_state_bundle.h>
namespace storage {
TestNodeStateUpdater::TestNodeStateUpdater(const lib::NodeType& type)
: _reported(new lib::NodeState(type, lib::State::UP)),
- _current(new lib::NodeState(type, lib::State::UP))
+ _current(new lib::NodeState(type, lib::State::UP)),
+ _clusterStateBundle(),
+ _listeners()
{ }
-TestNodeStateUpdater::~TestNodeStateUpdater() { }
+TestNodeStateUpdater::~TestNodeStateUpdater() = default;
+
+std::shared_ptr<const ClusterStateBundle>
+TestNodeStateUpdater::getClusterStateBundle() const
+{
+ return _clusterStateBundle;
+}
+
+void
+TestNodeStateUpdater::setClusterState(lib::ClusterState::CSP c)
+{
+ _clusterStateBundle = std::make_shared<const ClusterStateBundle>(*c);
+ for (uint32_t i = 0; i < _listeners.size(); ++i) {
+ _listeners[i]->handleNewState();
+ }
+}
}
diff --git a/storage/src/tests/common/testnodestateupdater.h b/storage/src/tests/common/testnodestateupdater.h
index 3e5dfed560d..daecb45ece4 100644
--- a/storage/src/tests/common/testnodestateupdater.h
+++ b/storage/src/tests/common/testnodestateupdater.h
@@ -16,7 +16,7 @@ struct TestNodeStateUpdater : public NodeStateUpdater
{
lib::NodeState::CSP _reported;
lib::NodeState::CSP _current;
- lib::ClusterState::CSP _cluster;
+ std::shared_ptr<const ClusterStateBundle> _clusterStateBundle;
std::vector<StateListener*> _listeners;
public:
@@ -25,7 +25,7 @@ public:
lib::NodeState::CSP getReportedNodeState() const override { return _reported; }
lib::NodeState::CSP getCurrentNodeState() const override { return _current; }
- lib::ClusterState::CSP getSystemState() const override { return _cluster; }
+ std::shared_ptr<const ClusterStateBundle> getClusterStateBundle() const override;
void addStateListener(StateListener& s) override { _listeners.push_back(&s); }
void removeStateListener(StateListener&) override {}
Lock::SP grabStateChangeLock() override { return Lock::SP(new Lock); }
@@ -33,12 +33,7 @@ public:
void setCurrentNodeState(const lib::NodeState& state) { _current.reset(new lib::NodeState(state)); }
- void setClusterState(lib::ClusterState::CSP c) {
- _cluster = c;
- for (uint32_t i = 0; i < _listeners.size(); ++i) {
- _listeners[i]->handleNewState();
- }
- }
+ void setClusterState(lib::ClusterState::CSP c);
};
} // storage
diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
index af0082fa788..2192ae4d634 100644
--- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
+++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
@@ -7,6 +7,7 @@
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/storage/storageserver/statemanager.h>
#include <vespa/storage/bucketdb/bucketmanager.h>
+#include <vespa/storage/common/cluster_state_bundle.h>
#include <vespa/storage/persistence/persistencethread.h>
#include <vespa/storage/persistence/filestorage/filestormanager.h>
#include <vespa/storage/persistence/filestorage/modifiedbucketchecker.h>
@@ -177,9 +178,11 @@ struct FileStorManagerTest : public CppUnit::TestFixture {
bool ownsBucket(uint16_t distributorIndex,
const document::BucketId& bucket) const
{
+ auto clusterStateBundle = _node->getStateUpdater().getClusterStateBundle();
+ const auto &clusterState = *clusterStateBundle->getBaselineClusterState();
uint16_t distributor(
_node->getDistribution()->getIdealDistributorNode(
- *_node->getStateUpdater().getSystemState(), bucket));
+ clusterState, bucket));
return distributor == distributorIndex;
}
diff --git a/storage/src/tests/storageserver/statemanagertest.cpp b/storage/src/tests/storageserver/statemanagertest.cpp
index c07c150a520..0676d3684ff 100644
--- a/storage/src/tests/storageserver/statemanagertest.cpp
+++ b/storage/src/tests/storageserver/statemanagertest.cpp
@@ -4,6 +4,7 @@
#include <vespa/metrics/metricmanager.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storageapi/message/state.h>
+#include <vespa/storage/common/cluster_state_bundle.h>
#include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h>
#include <vespa/storage/storageserver/statemanager.h>
#include <tests/common/teststorageapp.h>
@@ -105,7 +106,7 @@ StateManagerTest::testSystemState()
{
std::shared_ptr<api::StorageReply> reply;
// Verify initial state on startup
- ClusterState::CSP currentState = _manager->getSystemState();
+ ClusterState::CSP currentState = _manager->getClusterStateBundle()->getBaselineClusterState();
CPPUNIT_ASSERT_EQUAL(std::string("cluster:d"),
currentState->toString(false));
@@ -118,7 +119,7 @@ StateManagerTest::testSystemState()
_upper->sendDown(cmd);
GET_ONLY_OK_REPLY(reply);
- currentState = _manager->getSystemState();
+ currentState = _manager->getClusterStateBundle()->getBaselineClusterState();
CPPUNIT_ASSERT_EQUAL(sendState, *currentState);
currentNodeState = _manager->getCurrentNodeState();
@@ -225,7 +226,7 @@ StateManagerTest::testReportedNodeState()
void
StateManagerTest::testClusterStateVersion()
{
- ClusterState state(*_manager->getSystemState());
+ ClusterState state(*_manager->getClusterStateBundle()->getBaselineClusterState());
state.setVersion(123);
_manager->setClusterState(state);