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-348 Add ResourceFactory Test See merge request megasearch/milvus!343 Former-commit-id: c55c49518e73e46616d706fb9cb582dcef883d61
This commit is contained in:
commit
3e4d98f04a
@ -7,6 +7,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||
- MS-344 - Add TaskTable Test
|
||||
- MS-345 - Add Node Test
|
||||
- MS-346 - Add some implementation of scheduler to solve compile error
|
||||
- MS-348 - Add ResourceFactory Test
|
||||
|
||||
## Bug
|
||||
|
||||
|
@ -14,11 +14,11 @@ namespace engine {
|
||||
std::shared_ptr<Resource>
|
||||
ResourceFactory::Create(const std::string &name, const std::string &alias) {
|
||||
if (name == "disk") {
|
||||
return std::make_shared<CpuResource>(alias);
|
||||
return std::make_shared<DiskResource>(alias);
|
||||
} else if (name == "cpu") {
|
||||
return std::make_shared<CpuResource>(alias);
|
||||
} else if (name == "gpu") {
|
||||
return std::make_shared<CpuResource>(alias);
|
||||
return std::make_shared<GpuResource>(alias);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -14,6 +14,17 @@ namespace milvus {
|
||||
namespace engine {
|
||||
|
||||
class DiskResource : public Resource {
|
||||
public:
|
||||
explicit
|
||||
DiskResource(std::string name)
|
||||
: Resource(std::move(name), ResourceType::DISK) {}
|
||||
|
||||
protected:
|
||||
void
|
||||
LoadFile(TaskPtr task) override {}
|
||||
|
||||
void
|
||||
Process(TaskPtr task) override {}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,17 @@ namespace milvus {
|
||||
namespace engine {
|
||||
|
||||
class GpuResource : public Resource {
|
||||
public:
|
||||
explicit
|
||||
GpuResource(std::string name)
|
||||
: Resource(std::move(name), ResourceType::GPU) {}
|
||||
|
||||
protected:
|
||||
void
|
||||
LoadFile(TaskPtr task) override {}
|
||||
|
||||
void
|
||||
Process(TaskPtr task) override {}
|
||||
};
|
||||
|
||||
}
|
||||
|
15
cpp/unittest/scheduler/resource_factory_test.cpp
Normal file
15
cpp/unittest/scheduler/resource_factory_test.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "scheduler/ResourceFactory.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
using namespace zilliz::milvus::engine;
|
||||
|
||||
TEST(resource_factory_test, create) {
|
||||
auto disk = ResourceFactory::Create("disk");
|
||||
auto cpu = ResourceFactory::Create("cpu");
|
||||
auto gpu = ResourceFactory::Create("gpu");
|
||||
|
||||
ASSERT_TRUE(std::dynamic_pointer_cast<DiskResource>(disk));
|
||||
ASSERT_TRUE(std::dynamic_pointer_cast<CpuResource>(cpu));
|
||||
ASSERT_TRUE(std::dynamic_pointer_cast<GpuResource>(gpu));
|
||||
}
|
Loading…
Reference in New Issue
Block a user