From d81fa80865acab41e92f865bdf7165e5ca2b5a60 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 16 Oct 2024 17:27:32 +0800 Subject: [PATCH] az: remove unused key newing --- .../mnode/impl/test/arbgroup/CMakeLists.txt | 2 +- source/libs/azure/src/az.cpp | 13 +--------- source/libs/stream/CMakeLists.txt | 13 +++++----- source/libs/stream/test/CMakeLists.txt | 2 +- source/libs/tcs/test/tcsTest.cpp | 24 +++++++++++++++---- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt b/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt index 44ac305498..0da36e1f67 100644 --- a/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt @@ -4,7 +4,7 @@ aux_source_directory(. MNODE_ARBGROUP_TEST_SRC) add_executable(arbgroupTest ${MNODE_ARBGROUP_TEST_SRC}) target_link_libraries( arbgroupTest - PRIVATE dnode nodes planner gtest qcom + PRIVATE dnode nodes planner gtest qcom tcs ) add_test( diff --git a/source/libs/azure/src/az.cpp b/source/libs/azure/src/az.cpp index 80b5fb883e..b05f5be2ca 100644 --- a/source/libs/azure/src/az.cpp +++ b/source/libs/azure/src/az.cpp @@ -72,8 +72,6 @@ static int32_t azListBucket(char const *bucketname) { try { auto sharedKeyCredential = std::make_shared(accountName, accountKey); - StorageSharedKeyCredential *pSharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); - BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential); std::string containerName = bucketname; @@ -216,8 +214,7 @@ int32_t azPutObjectFromFileOffset(const char *file, const char *object_name, int try { auto sharedKeyCredential = std::make_shared(accountName, accountKey); - std::string accountURL = tsS3Hostname[0]; - StorageSharedKeyCredential *pSharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); + std::string accountURL = tsS3Hostname[0]; accountURL = "https://" + accountURL; BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential); @@ -278,8 +275,6 @@ int32_t azGetObjectBlockImpl(const char *object_name, int64_t offset, int64_t si try { auto sharedKeyCredential = std::make_shared(accountName, accountKey); - StorageSharedKeyCredential *pSharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); - accountURL = "https://" + accountURL; BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential); @@ -353,8 +348,6 @@ void azDeleteObjectsByPrefix(const char *prefix) { try { auto sharedKeyCredential = std::make_shared(accountName, accountKey); - StorageSharedKeyCredential *pSharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); - BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential); std::string containerName = tsS3BucketName; @@ -414,8 +407,6 @@ int32_t azGetObjectToFile(const char *object_name, const char *fileName) { try { auto sharedKeyCredential = std::make_shared(accountName, accountKey); - StorageSharedKeyCredential *pSharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); - BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential); std::string containerName = tsS3BucketName; @@ -450,8 +441,6 @@ int32_t azGetObjectsByPrefix(const char *prefix, const char *path) { try { auto sharedKeyCredential = std::make_shared(accountName, accountKey); - StorageSharedKeyCredential *pSharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); - BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential); std::string containerName = tsS3BucketName; diff --git a/source/libs/stream/CMakeLists.txt b/source/libs/stream/CMakeLists.txt index 53e26469f0..27f5c46004 100644 --- a/source/libs/stream/CMakeLists.txt +++ b/source/libs/stream/CMakeLists.txt @@ -12,8 +12,8 @@ if(${BUILD_WITH_ROCKSDB}) if (${BUILD_CONTRIB}) target_link_libraries( stream - PUBLIC rocksdb tdb - PRIVATE os util transport qcom executor wal index tcs + PUBLIC rocksdb tdb tcs + PRIVATE os util transport qcom executor wal index ) target_include_directories( stream @@ -31,14 +31,14 @@ if(${BUILD_WITH_ROCKSDB}) ) target_link_libraries( stream - PUBLIC rocksdb tdb - PRIVATE os util transport qcom executor wal index tcs + PUBLIC rocksdb tdb tcs + PRIVATE os util transport qcom executor wal index ) else() target_link_libraries( stream - PUBLIC rocksdb tdb - PRIVATE os util transport qcom executor wal index tcs + PUBLIC rocksdb tdb tcs + PRIVATE os util transport qcom executor wal index ) target_include_directories( stream @@ -59,4 +59,3 @@ endif(${BUILD_WITH_ROCKSDB}) if(${BUILD_TEST}) ADD_SUBDIRECTORY(test) endif(${BUILD_TEST}) - diff --git a/source/libs/stream/test/CMakeLists.txt b/source/libs/stream/test/CMakeLists.txt index c472207b27..f2c985964d 100644 --- a/source/libs/stream/test/CMakeLists.txt +++ b/source/libs/stream/test/CMakeLists.txt @@ -101,4 +101,4 @@ IF(NOT TD_DARWIN) NAME backendTest COMMAND backendTest ) -ENDIF () \ No newline at end of file +ENDIF () diff --git a/source/libs/tcs/test/tcsTest.cpp b/source/libs/tcs/test/tcsTest.cpp index e5593bfc18..ed2cb59858 100644 --- a/source/libs/tcs/test/tcsTest.cpp +++ b/source/libs/tcs/test/tcsTest.cpp @@ -4,6 +4,7 @@ #include #include "tcs.h" +#include "tcsInt.h" int32_t tcsInitEnv() { int32_t code = 0; @@ -19,7 +20,21 @@ int32_t tcsInitEnv() { tsS3AccessKeySecret[0] = ""; tsS3BucketName = ""; */ + + const char *hostname = "endpoint/.blob.core.windows.net"; + const char *accessKeyId = ""; + const char *accessKeySecret = ""; + const char *bucketName = ""; + + tstrncpy(&tsS3Hostname[0][0], hostname, TSDB_FQDN_LEN); + tstrncpy(&tsS3AccessKeyId[0][0], accessKeyId, TSDB_FQDN_LEN); + tstrncpy(&tsS3AccessKeySecret[0][0], accessKeySecret, TSDB_FQDN_LEN); + tstrncpy(tsS3BucketName, bucketName, TSDB_FQDN_LEN); + + tstrncpy(tsTempDir, "/tmp/", PATH_MAX); + tsS3Enabled = true; + tsS3Ablob = true; return code; } @@ -28,11 +43,10 @@ int32_t tcsInitEnv() { TEST(TcsTest, InterfaceTest) { int code = 0; - if (!tsS3Enabled) { - (void)fprintf(stderr, "tcs not configured.\n"); - - return; - } + code = tcsInitEnv(); + GTEST_ASSERT_EQ(code, 0); + GTEST_ASSERT_EQ(tsS3Enabled, 1); + GTEST_ASSERT_EQ(tsS3Ablob, 1); code = tcsInit(); GTEST_ASSERT_EQ(code, 0);