From b05784f524b446ffa282302185962c458838aff4 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 16 Oct 2024 16:44:08 +0800 Subject: [PATCH] tcs: fix mac stb link issue --- source/libs/azure/src/az.cpp | 4 +- source/libs/stream/CMakeLists.txt | 6 +-- source/libs/tcs/CMakeLists.txt | 4 +- source/libs/tcs/src/tcs.c | 7 ++-- source/libs/tcs/test/tcsTest.cpp | 61 +++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/source/libs/azure/src/az.cpp b/source/libs/azure/src/az.cpp index 0af669c56a..80b5fb883e 100644 --- a/source/libs/azure/src/az.cpp +++ b/source/libs/azure/src/az.cpp @@ -49,13 +49,13 @@ static void azDumpCfgByEp(int8_t epIndex) { "%-24s %s\n" "%-24s %s\n" "%-24s %s\n" - // "%-24s %s\n" + "%-24s %s\n" "%-24s %s\n" "%-24s %s\n", "hostName", tsS3Hostname[epIndex], "bucketName", tsS3BucketName, "protocol", "https only", - //"uristyle", (uriStyleG[epIndex] == S3UriStyleVirtualHost ? "virtualhost" : "path"), + "uristyle", "path only", "accessKey", tsS3AccessKeyId[epIndex], "accessKeySecret", tsS3AccessKeySecret[epIndex]); // clang-format on diff --git a/source/libs/stream/CMakeLists.txt b/source/libs/stream/CMakeLists.txt index f08b16f836..53e26469f0 100644 --- a/source/libs/stream/CMakeLists.txt +++ b/source/libs/stream/CMakeLists.txt @@ -13,7 +13,7 @@ if(${BUILD_WITH_ROCKSDB}) target_link_libraries( stream PUBLIC rocksdb tdb - PRIVATE os util transport qcom executor wal index + PRIVATE os util transport qcom executor wal index tcs ) target_include_directories( stream @@ -32,13 +32,13 @@ if(${BUILD_WITH_ROCKSDB}) target_link_libraries( stream PUBLIC rocksdb tdb - PRIVATE os util transport qcom executor wal index + PRIVATE os util transport qcom executor wal index tcs ) else() target_link_libraries( stream PUBLIC rocksdb tdb - PRIVATE os util transport qcom executor wal index + PRIVATE os util transport qcom executor wal index tcs ) target_include_directories( stream diff --git a/source/libs/tcs/CMakeLists.txt b/source/libs/tcs/CMakeLists.txt index 1c914a18b9..e0de823c7a 100644 --- a/source/libs/tcs/CMakeLists.txt +++ b/source/libs/tcs/CMakeLists.txt @@ -1,6 +1,6 @@ -aux_source_directory(src TOS_SRC) +aux_source_directory(src TCS_SRC) -add_library(tcs STATIC ${TOS_SRC}) +add_library(tcs STATIC ${TCS_SRC}) target_include_directories( tcs PUBLIC "${TD_SOURCE_DIR}/include/libs/tcs" diff --git a/source/libs/tcs/src/tcs.c b/source/libs/tcs/src/tcs.c index c0933f68d0..db02ca21fa 100644 --- a/source/libs/tcs/src/tcs.c +++ b/source/libs/tcs/src/tcs.c @@ -43,6 +43,7 @@ int32_t tcsInit() { tcs.GetObjectsByPrefix = s3GetObjectsByPrefix; tcs.DeleteObjects = s3DeleteObjects; tcs.GetObjectToFile = s3GetObjectToFile; + } else if (TOS_PROTO_ABLOB == proto) { tcs.Begin = azBegin; tcs.End = azEnd; @@ -74,19 +75,19 @@ int32_t tcsCheckCfg() { int32_t code = 0; if (!tsS3Enabled) { - (void)fprintf(stderr, "s3 not configured.\n"); + (void)fprintf(stderr, "tcs not configured.\n"); TAOS_RETURN(code); } code = tcsInit(); if (code != 0) { - (void)fprintf(stderr, "failed to initialize s3.\n"); + (void)fprintf(stderr, "failed to initialize tcs.\n"); TAOS_RETURN(code); } code = tcs.CheckCfg(); if (code != 0) { - (void)fprintf(stderr, "failed to check s3.\n"); + (void)fprintf(stderr, "failed to check tcs.\n"); TAOS_RETURN(code); } diff --git a/source/libs/tcs/test/tcsTest.cpp b/source/libs/tcs/test/tcsTest.cpp index 68b39bd710..e5593bfc18 100644 --- a/source/libs/tcs/test/tcsTest.cpp +++ b/source/libs/tcs/test/tcsTest.cpp @@ -2,6 +2,67 @@ #include #include #include + +#include "tcs.h" + +int32_t tcsInitEnv() { + int32_t code = 0; + + extern char tsS3Hostname[][TSDB_FQDN_LEN]; + extern char tsS3AccessKeyId[][TSDB_FQDN_LEN]; + extern char tsS3AccessKeySecret[][TSDB_FQDN_LEN]; + extern char tsS3BucketName[TSDB_FQDN_LEN]; + + /* TCS parameter format + tsS3Hostname[0] = "endpoint/.blob.core.windows.net"; + tsS3AccessKeyId[0] = ""; + tsS3AccessKeySecret[0] = ""; + tsS3BucketName = ""; + */ + tsS3Enabled = true; + + return code; +} + +// TEST(TcsTest, DISABLE_InterfaceTest) { +TEST(TcsTest, InterfaceTest) { + int code = 0; + + if (!tsS3Enabled) { + (void)fprintf(stderr, "tcs not configured.\n"); + + return; + } + + code = tcsInit(); + GTEST_ASSERT_EQ(code, 0); + + code = tcsCheckCfg(); + GTEST_ASSERT_EQ(code, 0); + /* + code = tcsPutObjectFromFileOffset(file, object_name, offset, size); + GTEST_ASSERT_EQ(code, 0); + code = tcsGetObjectBlock(object_name, offset, size, check, ppBlock); + GTEST_ASSERT_EQ(code, 0); + + tcsDeleteObjectsByPrefix(prefix); + // list object to check + + code = tcsPutObjectFromFile2(file, object, withcp); + GTEST_ASSERT_EQ(code, 0); + code = tcsGetObjectsByPrefix(prefix, path); + GTEST_ASSERT_EQ(code, 0); + code = tcsDeleteObjects(object_name, nobject); + GTEST_ASSERT_EQ(code, 0); + code = tcsGetObjectToFile(object_name, fileName); + GTEST_ASSERT_EQ(code, 0); + + // GTEST_ASSERT_NE(pEnv, nullptr); + */ + + tcsUninit(); +} + /* #include "walInt.h" const char* ranStr = "tvapq02tcp";