Merge branch 'branch-0.4.0' into 'branch-0.4.0'

add unittest for dump function

See merge request megasearch/milvus!513

Former-commit-id: b39c951bfd57296aa334303027344bcc5ad7963e
pull/191/head
peng.xu 2019-09-09 10:04:12 +08:00
commit 4a3edc298b
3 changed files with 70 additions and 0 deletions

View File

@ -101,6 +101,8 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-511 - Update resource_test in scheduler
- MS-517 - Update resource_mgr_test in scheduler
- MS-518 - Add schedinst_test in scheduler
- MS-519 - Add event_test in scheduler
- MS-520 - Update resource_test in scheduler
## New Feature
- MS-343 - Implement ResourceMgr

View File

@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include <gtest/gtest.h>
#include "scheduler/resource/Resource.h"
#include "scheduler/event/Event.h"
#include "scheduler/event/StartUpEvent.h"
namespace zilliz {
namespace milvus {
namespace engine {
TEST(EventTest, start_up_event) {
ResourceWPtr res(ResourcePtr(nullptr));
auto event = std::make_shared<StartUpEvent>(res);
ASSERT_FALSE(event->Dump().empty());
std::stringstream ss;
ss << event;
ASSERT_FALSE(ss.str().empty());
}
TEST(EventTest, load_completed_event) {
ResourceWPtr res(ResourcePtr(nullptr));
auto event = std::make_shared<LoadCompletedEvent>(res, nullptr);
ASSERT_FALSE(event->Dump().empty());
std::stringstream ss;
ss << event;
ASSERT_FALSE(ss.str().empty());
}
TEST(EventTest, finish_task_event) {
ResourceWPtr res(ResourcePtr(nullptr));
auto event = std::make_shared<FinishTaskEvent>(res, nullptr);
ASSERT_FALSE(event->Dump().empty());
std::stringstream ss;
ss << event;
ASSERT_FALSE(ss.str().empty());
}
TEST(EventTest, tasktable_updated_event) {
ResourceWPtr res(ResourcePtr(nullptr));
auto event = std::make_shared<TaskTableUpdatedEvent>(res);
ASSERT_FALSE(event->Dump().empty());
std::stringstream ss;
ss << event;
ASSERT_FALSE(ss.str().empty());
}
}
}
}

View File

@ -81,6 +81,16 @@ TEST_F(ResourceBaseTest, has_executor) {
ASSERT_FALSE(both_disable_->HasExecutor());
}
TEST_F(ResourceBaseTest, dump) {
ASSERT_FALSE(only_loader_->Dump().empty());
ASSERT_FALSE(only_executor_->Dump().empty());
ASSERT_FALSE(both_enable_->Dump().empty());
ASSERT_FALSE(both_disable_->Dump().empty());
std::stringstream ss;
ss << only_loader_ << only_executor_ << both_enable_ << both_disable_;
ASSERT_FALSE(ss.str().empty());
}
/************ ResourceAdvanceTest ************/
class ResourceAdvanceTest : public testing::Test {