diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 592cb79c87..a8a849ba1a 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -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 diff --git a/cpp/src/scheduler/ResourceFactory.cpp b/cpp/src/scheduler/ResourceFactory.cpp index 65dd488e3c..496802cd19 100644 --- a/cpp/src/scheduler/ResourceFactory.cpp +++ b/cpp/src/scheduler/ResourceFactory.cpp @@ -14,11 +14,11 @@ namespace engine { std::shared_ptr ResourceFactory::Create(const std::string &name, const std::string &alias) { if (name == "disk") { - return std::make_shared(alias); + return std::make_shared(alias); } else if (name == "cpu") { return std::make_shared(alias); } else if (name == "gpu") { - return std::make_shared(alias); + return std::make_shared(alias); } else { return nullptr; } diff --git a/cpp/src/scheduler/resource/DiskResource.h b/cpp/src/scheduler/resource/DiskResource.h index b4ff32e75e..77d2e97879 100644 --- a/cpp/src/scheduler/resource/DiskResource.h +++ b/cpp/src/scheduler/resource/DiskResource.h @@ -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 {} }; } diff --git a/cpp/src/scheduler/resource/GpuResource.h b/cpp/src/scheduler/resource/GpuResource.h index be91950b78..74fae13b75 100644 --- a/cpp/src/scheduler/resource/GpuResource.h +++ b/cpp/src/scheduler/resource/GpuResource.h @@ -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 {} }; } diff --git a/cpp/unittest/scheduler/resource_factory_test.cpp b/cpp/unittest/scheduler/resource_factory_test.cpp new file mode 100644 index 0000000000..829fb46cda --- /dev/null +++ b/cpp/unittest/scheduler/resource_factory_test.cpp @@ -0,0 +1,15 @@ +#include "scheduler/ResourceFactory.h" +#include + + +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(disk)); + ASSERT_TRUE(std::dynamic_pointer_cast(cpu)); + ASSERT_TRUE(std::dynamic_pointer_cast(gpu)); +}