mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
Merge branch 'branch-0.4.0' into 'branch-0.4.0'
MS-345 Add Node Test See merge request megasearch/milvus!338 Former-commit-id: d13ce00f0b0ca8f59b01034e447c1a0419d65bc0
This commit is contained in:
commit
09801053e9
@ -19,5 +19,3 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||
- MS-202 - Add Milvus Jenkins project email notification
|
||||
- MS-215 - Add Milvus cluster CI/CD groovy file
|
||||
- MS-277 - Update CUDA Version to V10.1
|
||||
- MS-336 - Scheduler interface
|
||||
- MS-344 - Add TaskTable Test
|
||||
|
@ -3,6 +3,9 @@
|
||||
Please mark all change in change log and use the ticket from JIRA.
|
||||
|
||||
# Milvus 0.4.0 (2019-07-28)
|
||||
- MS-336 - Scheduler interface
|
||||
- MS-344 - Add TaskTable Test
|
||||
- MS-345 - Add Node Test
|
||||
|
||||
## Bug
|
||||
|
||||
|
@ -21,6 +21,9 @@ class Node;
|
||||
using NeighbourNodePtr = std::weak_ptr<Node>;
|
||||
|
||||
struct Neighbour {
|
||||
Neighbour(NeighbourNodePtr nei, Connection conn)
|
||||
: neighbour_node(nei), connection(conn) {}
|
||||
|
||||
NeighbourNodePtr neighbour_node;
|
||||
Connection connection;
|
||||
};
|
||||
@ -29,18 +32,18 @@ class Node {
|
||||
public:
|
||||
void
|
||||
AddNeighbour(const NeighbourNodePtr &neighbour_node, Connection &connection) {
|
||||
Neighbour neighbour{.neighbour_node = neighbour_node, .connection = connection};
|
||||
neighbours_.push_back(neighbour);
|
||||
Neighbour neighbour(neighbour_node, connection);
|
||||
neighbours_.emplace_back(neighbour);
|
||||
}
|
||||
|
||||
void
|
||||
DelNeighbour(NeighbourNodePtr &neighbour_ptr);
|
||||
DelNeighbour(NeighbourNodePtr neighbour_ptr) {}
|
||||
|
||||
bool
|
||||
IsNeighbour(NeighbourNodePtr &neighbour_ptr);
|
||||
IsNeighbour(NeighbourNodePtr neighbour_ptr) {}
|
||||
|
||||
std::vector<NeighbourNodePtr>
|
||||
GetNeighbours();
|
||||
const std::vector<Neighbour> &
|
||||
GetNeighbours() {}
|
||||
|
||||
public:
|
||||
std::string
|
||||
@ -50,6 +53,9 @@ private:
|
||||
std::vector<Neighbour> neighbours_;
|
||||
};
|
||||
|
||||
using NodePtr = std::shared_ptr<Node>;
|
||||
using NodeWPtr = std::weak_ptr<Node>;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ include_directories(/usr/include/mysql)
|
||||
#add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
|
||||
|
||||
set(scheduler_test_src
|
||||
${unittest_srcs}
|
||||
${scheduler_resource_srcs}
|
||||
${scheduler_srcs}
|
||||
${test_srcs}
|
||||
|
66
cpp/unittest/scheduler/node_test.cpp
Normal file
66
cpp/unittest/scheduler/node_test.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "scheduler/resource/Node.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
using namespace zilliz::milvus::engine;
|
||||
|
||||
class NodeTest : public ::testing::Test {
|
||||
protected:
|
||||
void
|
||||
SetUp() override {
|
||||
node1_ = std::make_shared<Node>();
|
||||
node2_ = std::make_shared<Node>();
|
||||
|
||||
auto pcie = Connection("PCIe", 11.0);
|
||||
|
||||
node1_->AddNeighbour(node2_, pcie);
|
||||
node2_->AddNeighbour(node1_, pcie);
|
||||
}
|
||||
|
||||
NodePtr node1_;
|
||||
NodePtr node2_;
|
||||
NodePtr node3_;
|
||||
NodePtr node4_;
|
||||
};
|
||||
|
||||
TEST_F(NodeTest, add_neighbour) {
|
||||
ASSERT_EQ(node3_->GetNeighbours().size(), 0);
|
||||
ASSERT_EQ(node4_->GetNeighbours().size(), 0);
|
||||
auto pcie = Connection("PCIe", 11.0);
|
||||
node3_->AddNeighbour(node4_, pcie);
|
||||
node4_->AddNeighbour(node3_, pcie);
|
||||
ASSERT_EQ(node3_->GetNeighbours().size(), 1);
|
||||
ASSERT_EQ(node4_->GetNeighbours().size(), 1);
|
||||
}
|
||||
|
||||
TEST_F(NodeTest, del_neighbour) {
|
||||
ASSERT_EQ(node1_->GetNeighbours().size(), 1);
|
||||
ASSERT_EQ(node2_->GetNeighbours().size(), 1);
|
||||
ASSERT_EQ(node3_->GetNeighbours().size(), 0);
|
||||
node1_->DelNeighbour(node2_);
|
||||
node2_->DelNeighbour(node2_);
|
||||
node3_->DelNeighbour(node2_);
|
||||
ASSERT_EQ(node1_->GetNeighbours().size(), 0);
|
||||
ASSERT_EQ(node2_->GetNeighbours().size(), 1);
|
||||
ASSERT_EQ(node3_->GetNeighbours().size(), 0);
|
||||
}
|
||||
|
||||
TEST_F(NodeTest, is_neighbour) {
|
||||
ASSERT_TRUE(node1_->IsNeighbour(node2_));
|
||||
ASSERT_TRUE(node2_->IsNeighbour(node1_));
|
||||
|
||||
ASSERT_FALSE(node1_->IsNeighbour(node3_));
|
||||
ASSERT_FALSE(node2_->IsNeighbour(node3_));
|
||||
ASSERT_FALSE(node3_->IsNeighbour(node1_));
|
||||
ASSERT_FALSE(node3_->IsNeighbour(node2_));
|
||||
}
|
||||
|
||||
TEST_F(NodeTest, get_neighbours) {
|
||||
auto node1_neighbours = node1_->GetNeighbours();
|
||||
ASSERT_EQ(node1_neighbours.size(), 1);
|
||||
ASSERT_EQ(node1_neighbours[0].neighbour_node.lock(), node2_);
|
||||
|
||||
auto node2_neighbours = node2_->GetNeighbours();
|
||||
ASSERT_EQ(node2_neighbours.size(), 1);
|
||||
ASSERT_EQ(node2_neighbours[0].neighbour_node.lock(), node1_);
|
||||
}
|
Loading…
Reference in New Issue
Block a user