diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index 84e57c4180..027bee709d 100644 --- a/include/dnode/vnode/vnode.h +++ b/include/dnode/vnode/vnode.h @@ -63,6 +63,19 @@ typedef struct SVnodeCfg { } SVnodeCfg; /* ------------------------ SVnode ------------------------ */ +/** + * @brief Initialize the vnode module + * + * @return int 0 for success and -1 for failure + */ +int vnodeInit(); + +/** + * @brief clear a vnode + * + */ +void vnodeClear(); + /** * @brief Open a VNODE. * diff --git a/source/dnode/vnode/impl/src/vnodeMain.c b/source/dnode/vnode/impl/src/vnodeMain.c index 59e3bae5d7..ab33b58858 100644 --- a/source/dnode/vnode/impl/src/vnodeMain.c +++ b/source/dnode/vnode/impl/src/vnodeMain.c @@ -20,6 +20,19 @@ static void vnodeFree(SVnode *pVnode); static int vnodeOpenImpl(SVnode *pVnode); static void vnodeCloseImpl(SVnode *pVnode); +int vnodeInit() { + // TODO + if (walInit() < 0) { + return -1; + } + + return 0; +} + +void vnodeClear() { + walCleanUp(); +} + SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { SVnode *pVnode = NULL; diff --git a/source/dnode/vnode/impl/test/vnodeApiTests.cpp b/source/dnode/vnode/impl/test/vnodeApiTests.cpp index 0aa6a9edb6..3b0c059b98 100644 --- a/source/dnode/vnode/impl/test/vnodeApiTests.cpp +++ b/source/dnode/vnode/impl/test/vnodeApiTests.cpp @@ -4,12 +4,20 @@ #include "vnode.h" TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) { + GTEST_ASSERT_GE(vnodeInit(), 0); + // Create and open a vnode SVnode *pVnode = vnodeOpen("vnode1", NULL); ASSERT_NE(pVnode, nullptr); + // Create table + // SArray *pArray = taosArrayInit() + // vnodeProcessWMsgs(pVnode, ); + // Close the vnode vnodeClose(pVnode); + + vnodeClear(); } TEST(vnodeApiTest, vnode_process_create_table) {