From 204ca5e2e30e13926ded1a5dd8ff5f85ebde32fe Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Thu, 1 Jun 2023 10:18:35 +0800 Subject: [PATCH 1/3] FixConfigLensBug Signed-off-by: Jeremyzz --- .../gaussdb_rd/src/common/include/doc_limit.h | 2 +- .../test/unittest/api/documentdb_api_test.cpp | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/doc_limit.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/doc_limit.h index 557b92da..fc2515f3 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/doc_limit.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/doc_limit.h @@ -17,6 +17,6 @@ #define DOC_LIMIT_H namespace DocumentDB { -constexpr int MAX_DB_CONFIG_LEN = 512 * 1024; // 512 * 1024: 512k length +constexpr int MAX_DB_CONFIG_LEN = 1024 * 1024; // 1024 * 1024: 1024k length } // namespace DocumentDB #endif // DOC_LIMIT_H \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp index d4518ff6..6e5b3d80 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp @@ -226,6 +226,35 @@ HWTEST_F(DocumentDBApiTest, OpenDBConfigTest003, TestSize.Level0) EXPECT_EQ(status, GRD_INVALID_ARGS); } +/** + * @tc.name: OpenDBConfigTest004 + * @tc.desc: call GRD_DBOpen, input the value's length of configStr is 1024K + * @tc.type: FUNC + * @tc.require: + * @tc.author: mazhao + */ +HWTEST_F(DocumentDBApiTest, OpenDBConfigTest004, TestSize.Level0) +{ + /** + * @tc.steps:step1. input the value's length of configStr is 1024 k(not contained '\0') + */ + GRD_DB *db = nullptr; + std::string part1 = "{ \"pageSize\": \" "; + std::string part2 = "\" }"; + std::string path = "./document.db"; + std::string val = string(1024 * 1024 - part1.size() - part2.size(), 'k'); + std::string configStr = part1 + val + part2; + int ret = GRD_DBOpen(path.c_str(), configStr.c_str(), GRD_DB_OPEN_CREATE, &db); + EXPECT_EQ(ret, GRD_OVER_LIMIT); + /** + * @tc.steps:step2. input the value's length of configStr is 1024 k(contained '\0') + */ + std::string val2 = string(1024 * 1024 - part1.size() - part2.size() - 1, 'k'); + std::string configStr2 = part1 + val2 + part2 + "\0"; + ret = GRD_DBOpen(path.c_str(), configStr2.c_str(), GRD_DB_OPEN_CREATE, &db); + EXPECT_EQ(ret, GRD_INVALID_ARGS); +} + /** * @tc.name: OpenDBConfigMaxConnNumTest001 * @tc.desc: Test open document db with invalid config item maxConnNum -- Gitee From e123bb3bede5791ac776bf9695cb1179f9b3e2b9 Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Thu, 1 Jun 2023 15:24:48 +0800 Subject: [PATCH 2/3] fix code check Signed-off-by: Jeremyzz --- .../gaussdb_rd/test/unittest/api/documentdb_api_test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp index 6e5b3d80..8dee7515 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp @@ -28,6 +28,7 @@ using namespace testing::ext; using namespace DocumentDBUnitTest; namespace { +const int MAX_DB_CONFIG_LEN = 1024 * 1024; class DocumentDBApiTest : public testing::Test { public: static void SetUpTestCase(void); @@ -242,14 +243,14 @@ HWTEST_F(DocumentDBApiTest, OpenDBConfigTest004, TestSize.Level0) std::string part1 = "{ \"pageSize\": \" "; std::string part2 = "\" }"; std::string path = "./document.db"; - std::string val = string(1024 * 1024 - part1.size() - part2.size(), 'k'); + std::string val = string(MAX_DB_CONFIG_LEN - part1.size() - part2.size(), 'k'); std::string configStr = part1 + val + part2; int ret = GRD_DBOpen(path.c_str(), configStr.c_str(), GRD_DB_OPEN_CREATE, &db); EXPECT_EQ(ret, GRD_OVER_LIMIT); /** * @tc.steps:step2. input the value's length of configStr is 1024 k(contained '\0') */ - std::string val2 = string(1024 * 1024 - part1.size() - part2.size() - 1, 'k'); + std::string val2 = string(MAX_DB_CONFIG_LEN - part1.size() - part2.size() - 1, 'k'); std::string configStr2 = part1 + val2 + part2 + "\0"; ret = GRD_DBOpen(path.c_str(), configStr2.c_str(), GRD_DB_OPEN_CREATE, &db); EXPECT_EQ(ret, GRD_INVALID_ARGS); -- Gitee From a03c6003e43984e85d19c449baf37b0d3601696f Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Mon, 5 Jun 2023 11:22:08 +0800 Subject: [PATCH 3/3] fix code checkout opinion Signed-off-by: Jeremyzz --- .../gaussdb_rd/test/unittest/api/documentdb_api_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp index 8dee7515..5aec50c0 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp @@ -16,6 +16,7 @@ #include #include "doc_errno.h" +#include "doc_limit.h" #include "documentdb_test_utils.h" #include "grd_base/grd_db_api.h" #include "grd_base/grd_error.h" @@ -28,7 +29,6 @@ using namespace testing::ext; using namespace DocumentDBUnitTest; namespace { -const int MAX_DB_CONFIG_LEN = 1024 * 1024; class DocumentDBApiTest : public testing::Test { public: static void SetUpTestCase(void); @@ -411,7 +411,7 @@ int GetDBPageSize(const std::string &path) if (db == nullptr) { return 0; } - + int pageSize = 0; SQLiteUtils::ExecSql(db, "PRAGMA page_size;", nullptr, [&pageSize](sqlite3_stmt *stmt, bool &isMatchOneData) { pageSize = sqlite3_column_int(stmt, 0); -- Gitee