summaryrefslogtreecommitdiffstats
path: root/searchcore/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-01-31 14:14:11 +0100
committerHenning Baldersheim <balder@oath.com>2018-01-31 14:14:11 +0100
commit395627362aec1f0ee7dc6b5115789f96fbc86dce (patch)
tree335f37678dbddc0e4ca10c01c0da30bacf1a9754 /searchcore/src
parent0ac738014ccc2eea8bbddf67eee697b6503386c1 (diff)
Implement and test HwInfo equality.
Diffstat (limited to 'searchcore/src')
-rw-r--r--searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp15
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/hw_info.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.cpp3
3 files changed, 25 insertions, 1 deletions
diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
index 7db1fd001d4..96f742a172c 100644
--- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
+++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
@@ -377,4 +377,19 @@ TEST_FF("require that docstore config computes cachesize automatically if unset"
EXPECT_EQUAL(500000ul, config->getStoreConfig().getMaxCacheBytes());
}
+TEST("test HwInfo equality") {
+ EXPECT_TRUE(HwInfo::Cpu(1) == HwInfo::Cpu(1));
+ EXPECT_FALSE(HwInfo::Cpu(1) == HwInfo::Cpu(2));
+ EXPECT_TRUE(HwInfo::Memory(1) == HwInfo::Memory(1));
+ EXPECT_FALSE(HwInfo::Memory(1) == HwInfo::Memory(2));
+ EXPECT_TRUE(HwInfo::Disk(1, false, false) == HwInfo::Disk(1, false,false));
+ EXPECT_FALSE(HwInfo::Disk(1, false, false) == HwInfo::Disk(1, false,true));
+ EXPECT_FALSE(HwInfo::Disk(1, false, false) == HwInfo::Disk(1, true,false));
+ EXPECT_FALSE(HwInfo::Disk(1, false, false) == HwInfo::Disk(2, false,false));
+ EXPECT_TRUE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(1, false,false), 1ul, 1ul));
+ EXPECT_FALSE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(1, false,false), 1ul, 2ul));
+ EXPECT_FALSE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(1, false,false), 2ul, 1ul));
+ EXPECT_FALSE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(2, false,false), 1ul, 1ul));
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchcore/src/vespa/searchcore/proton/common/hw_info.h b/searchcore/src/vespa/searchcore/proton/common/hw_info.h
index cd0ef2817d7..9129aa43483 100644
--- a/searchcore/src/vespa/searchcore/proton/common/hw_info.h
+++ b/searchcore/src/vespa/searchcore/proton/common/hw_info.h
@@ -23,6 +23,9 @@ public:
uint64_t sizeBytes() const { return _sizeBytes; }
bool slow() const { return _slow; }
bool shared() const { return _shared; }
+ bool operator == (const Disk & rhs) const {
+ return (_sizeBytes == rhs._sizeBytes) && (_slow == rhs._slow) && (_shared == rhs._shared);
+ }
};
class Memory {
@@ -31,6 +34,7 @@ public:
public:
Memory(uint64_t sizeBytes_) : _sizeBytes(sizeBytes_) {}
uint64_t sizeBytes() const { return _sizeBytes; }
+ bool operator == (const Memory & rhs) const { return _sizeBytes == rhs._sizeBytes; }
};
class Cpu {
@@ -39,6 +43,7 @@ public:
public:
Cpu(uint32_t cores_) : _cores(cores_) {}
uint32_t cores() const { return _cores; }
+ bool operator == (const Cpu & rhs) const { return _cores == rhs._cores; }
};
private:
@@ -66,6 +71,9 @@ public:
const Disk &disk() const { return _disk; }
const Memory &memory() const { return _memory; }
const Cpu &cpu() const { return _cpu; }
+ bool operator == (const HwInfo & rhs) const {
+ return (_cpu == rhs._cpu) && (_disk == rhs._disk) && (_memory == rhs._memory);
+ }
};
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.cpp
index 7838c4810e8..1bc5cf00ad0 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.cpp
@@ -51,7 +51,8 @@ BootstrapConfig::operator==(const BootstrapConfig &rhs) const
equals<ProtonConfig>(_proton.get(), rhs._proton.get()) &&
equals<FiledistributorrpcConfig>(_fileDistributorRpc.get(), rhs._fileDistributorRpc.get()) &&
equals<BucketspacesConfig>(_bucketspaces.get(), rhs._bucketspaces.get()) &&
- equals<TuneFileDocumentDB>(_tuneFileDocumentDB.get(), rhs._tuneFileDocumentDB.get());
+ equals<TuneFileDocumentDB>(_tuneFileDocumentDB.get(), rhs._tuneFileDocumentDB.get()) &&
+ (_hwInfo == rhs._hwInfo);
}