diff --git a/source/dnode/mnode/impl/test/sdb/sdbTest.cpp b/source/dnode/mnode/impl/test/sdb/sdbTest.cpp index 21913375d69ae980ac9252c2bf108a2e7ed0f7db..4da414e27467b29a09d6d09777ce3e49f3cab556 100644 --- a/source/dnode/mnode/impl/test/sdb/sdbTest.cpp +++ b/source/dnode/mnode/impl/test/sdb/sdbTest.cpp @@ -23,6 +23,12 @@ class MndTestSdb : public ::testing::Test { void TearDown() override {} }; +typedef struct SMnode { + int32_t v100; + int32_t v200; + SSdb *pSdb; +} SMnode; + typedef struct SStrObj { char key[24]; int8_t v8; @@ -95,8 +101,39 @@ SSdbRaw *strDecode(SStrObj *pObj) { return pRaw; } +int32_t strInsert(SSdb *pSdb, SStrObj *pObj) { return 0; } + +int32_t strDelete(SSdb *pSdb, SStrObj *pObj, bool callFunc) { return 0; } + +int32_t strUpdate(SSdb *pSdb, SStrObj *pOld, SStrObj *pNew) { + pOld->v8 = pNew->v8; + pOld->v16 = pNew->v16; + pOld->v32 = pNew->v32; + pOld->v64 = pNew->v64; + return 0; +} + +int32_t strDefault(SMnode *pMnode) { + SStrObj strObj = {0}; + strcpy(strObj.key, "k1000"); + strObj.v8 = 1; + strObj.v16 = 1; + strObj.v32 = 1000; + strObj.v64 = 1000; + strcpy(strObj.vstr, "v1000"); + + SSdbRaw *pRaw = strEncode(&strObj); + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + return sdbWrite(pMnode->pSdb, pRaw); +} + TEST_F(MndTestSdb, 01_Basic) { + SMnode mnode; + mnode.v100 = 100; + mnode.v200 = 200; + SSdbOpt opt = {0}; + opt.pMnode = &mnode; opt.path = "/tmp/mnode_test_sdb"; SSdb *pSdb = sdbInit(&opt); @@ -106,11 +143,11 @@ TEST_F(MndTestSdb, 01_Basic) { .sdbType = SDB_USER, .keyType = SDB_KEY_BINARY, .deployFp = (SdbDeployFp)strEncode, - .encodeFp = (SdbEncodeFp)strDecode, - .decodeFp = (SdbDecodeFp)NULL, - .insertFp = (SdbInsertFp)NULL, - .updateFp = (SdbUpdateFp)NULL, - .deleteFp = (SdbDeleteFp)NULL, + .encodeFp = (SdbEncodeFp)strEncode, + .decodeFp = (SdbDecodeFp)strDecode, + .insertFp = (SdbInsertFp)strInsert, + .updateFp = (SdbUpdateFp)strDelete, + .deleteFp = (SdbDeleteFp)strUpdate, }; sdbSetTable(pSdb, strTable); diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index f85ff7a26e9cfdf4e8a2a626b0e1b4d8dce7d05a..d180271175dc557a531b4f8f2f040ed2f914abd8 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -141,7 +141,7 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) { } static int32_t sdbCreateDir(SSdb *pSdb) { - if (taosMkDir(pSdb->currDir) != 0) { + if (taosMulMkDir(pSdb->currDir) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); mError("failed to create dir:%s since %s", pSdb->currDir, terrstr()); return -1;