✨ feat(TSG-7599): 修改测试用例
This commit is contained in:
committed by
pengxuanzheng
parent
8c49f4d2c2
commit
89a92df45a
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
|
|||||||
hos_instance = hos_get_instance();
|
hos_instance = hos_get_instance();
|
||||||
if (hos_instance == NULL)
|
if (hos_instance == NULL)
|
||||||
{
|
{
|
||||||
hos_instance = hos_init_instance(conf_file, module_name, 1, bucket);
|
hos_instance = hos_init_instance(conf_file, module_name, 1);
|
||||||
}
|
}
|
||||||
if (hos_instance == NULL)
|
if (hos_instance == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ int main(int argc, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//初始化hos instance
|
//初始化hos instance
|
||||||
hos_instance hos_instance = hos_init_instance(conf_path, module, thread_sum, bucket);
|
hos_instance hos_instance = hos_init_instance(conf_path, module, thread_sum);
|
||||||
if (hos_instance == NULL)
|
if (hos_instance == NULL)
|
||||||
{
|
{
|
||||||
printf("error:hos_client_handle\n error:[%d]%s\n", hos_get_init_instance_errorcode(), hos_get_init_instance_errormsg());
|
printf("error:hos_client_handle\n error:[%d]%s\n", hos_get_init_instance_errorcode(), hos_get_init_instance_errormsg());
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-cove
|
|||||||
|
|
||||||
add_definitions(-g -W -Wall -std=c++11)
|
add_definitions(-g -W -Wall -std=c++11)
|
||||||
#add_executable(gtest_hos_client gtest_hos_init_instance.cpp gtest_hos_get_instance.cpp gtest_hos_close_fd.cpp gtest_hos_open_fd.cpp)
|
#add_executable(gtest_hos_client gtest_hos_init_instance.cpp gtest_hos_get_instance.cpp gtest_hos_close_fd.cpp gtest_hos_open_fd.cpp)
|
||||||
add_executable(gtest_hos_client CheckHosClient.cpp gtest_hos_write.cpp)
|
#add_executable(gtest_hos_client CheckHosClient.cpp gtest_hos_write.cpp)
|
||||||
#add_executable(gtest_hos_client ${SRCS})
|
add_executable(gtest_hos_client ${SRCS})
|
||||||
target_link_libraries(gtest_hos_client hos-client-cpp gtest gtest_main pthread)
|
target_link_libraries(gtest_hos_client hos-client-cpp gtest gtest_main pthread)
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ void CheckStructGHosFdContext(hos_fd_context_t *actual, hos_fd_context_t *expect
|
|||||||
|
|
||||||
void CheckHosInstance(hos_instance actual, hos_instance expect)
|
void CheckHosInstance(hos_instance actual, hos_instance expect)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(actual->result, expect->result);
|
EXPECT_EQ(actual->status, expect->status);
|
||||||
EXPECT_EQ(actual->error_code, expect->error_code);
|
EXPECT_EQ(actual->error_code, expect->error_code);
|
||||||
EXPECT_STREQ(actual->error_message, expect->error_message);
|
EXPECT_STREQ(actual->error_message, expect->error_message);
|
||||||
EXPECT_STREQ(actual->hos_url_prefix, expect->hos_url_prefix);
|
EXPECT_STREQ(actual->hos_url_prefix, expect->hos_url_prefix);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ hos_log_path="./hoslog"
|
|||||||
#default
|
#default
|
||||||
hos_log_level=30
|
hos_log_level=30
|
||||||
#default
|
#default
|
||||||
hos_poolsize=0
|
hos_poolsize=10
|
||||||
#default
|
#default
|
||||||
hos_cache_size=102400
|
hos_cache_size=102400
|
||||||
#default
|
#default
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -71,7 +71,7 @@ TEST(hos_close_fd, normal)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
int thread_num = 2;
|
int thread_num = 2;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -90,7 +90,7 @@ TEST(hos_close_fd, normal)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = INSTANCE_UNINIT_STATE;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ TEST(hos_close_fd, paramer_error)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
int thread_num = 2;
|
int thread_num = 2;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -133,7 +133,7 @@ TEST(hos_close_fd, paramer_error)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = INSTANCE_UNINIT_STATE;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ TEST(hos_close_fd, fd_not_exits)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
int thread_num = 2;
|
int thread_num = 2;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -177,7 +177,7 @@ TEST(hos_close_fd, fd_not_exits)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = INSTANCE_UNINIT_STATE;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -193,4 +193,4 @@ TEST(hos_close_fd, fd_not_exits)
|
|||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -55,11 +55,10 @@ TEST(hos_get_instance, normal)
|
|||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_get_instance();
|
hos_instance hos_instance = hos_get_instance();
|
||||||
memset(&expect_hos_instance, 0, sizeof(hos_instance_s));
|
ASSERT_EQ(hos_instance, nullptr);
|
||||||
expect_hos_instance.result = false;
|
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
|
||||||
|
|
||||||
hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET);
|
hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1);
|
||||||
|
ASSERT_NE(hos_instance, nullptr);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 1);
|
gtest_hos_handle_init(&expect_hos_handle, 1);
|
||||||
@@ -77,7 +76,7 @@ TEST(hos_get_instance, normal)
|
|||||||
|
|
||||||
int ret = hos_shutdown_instance();
|
int ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -59,7 +59,8 @@ TEST(hos_init_instance, normal)
|
|||||||
hos_instance_s expect_hos_instance;
|
hos_instance_s expect_hos_instance;
|
||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1);
|
||||||
|
ASSERT_NE(hos_instance, nullptr);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 1);
|
gtest_hos_handle_init(&expect_hos_handle, 1);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
@@ -87,52 +88,60 @@ TEST(hos_init_instance, param_error)
|
|||||||
{
|
{
|
||||||
hos_instance_s expect_hos_instance;
|
hos_instance_s expect_hos_instance;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(NULL, "hos_default_conf", 1, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(NULL, "hos_default_conf", 1);
|
||||||
expect_hos_instance.result = false;
|
ASSERT_EQ(hos_instance, nullptr);
|
||||||
|
expect_hos_instance.status = INSTANCE_UNINIT_STATE;
|
||||||
expect_hos_instance.error_code = HOS_PARAMETER_ERROR;
|
expect_hos_instance.error_code = HOS_PARAMETER_ERROR;
|
||||||
const char *err_msg = "param error:conf_path:(null), module:hos_default_conf, thread_num:1, bucket:firewall_hos_bucket";
|
const char *err_msg = "param error:conf_path:(null), module:hos_default_conf, thread_num:1";
|
||||||
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(&g_hos_instance, &expect_hos_instance);
|
||||||
}
|
|
||||||
|
|
||||||
TEST(hos_init_instance, bucket_not_exits)
|
|
||||||
{
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, "hos_bucket_not_exits");
|
|
||||||
|
|
||||||
hos_instance_s expect_hos_instance;
|
|
||||||
expect_hos_instance.result = false;
|
|
||||||
expect_hos_instance.error_code = HOS_BUCKET_NOT_EXIST;
|
|
||||||
const char *err_msg = "bucket:hos_bucket_not_exits not exits.";
|
|
||||||
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
|
||||||
|
|
||||||
hos_client_handle_t expect_hos_handle;
|
|
||||||
memset(&expect_hos_handle, 0, sizeof(expect_hos_handle));
|
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_init_instance, conf_error)
|
TEST(hos_init_instance, conf_error)
|
||||||
{
|
{
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_conf", 1, "hos_bucket_not_exits");
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_conf", 1);
|
||||||
|
ASSERT_EQ(hos_instance, nullptr);
|
||||||
hos_instance_s expect_hos_instance;
|
hos_instance_s expect_hos_instance;
|
||||||
expect_hos_instance.result = false;
|
expect_hos_instance.status = INSTANCE_UNINIT_STATE;
|
||||||
expect_hos_instance.error_code = HOS_CONF_ERROR;
|
expect_hos_instance.error_code = HOS_CONF_ERROR;
|
||||||
const char *err_msg = "hos param error:hos ip:, hos port:0, accesskeyid:, secretkey:";
|
const char *err_msg = "hos param error:hos ip:, hos port:0, accesskeyid:, secretkey:";
|
||||||
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(&g_hos_instance, &expect_hos_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_init_instance, server_conn_failed)
|
TEST(hos_init_instance, server_conn_failed)
|
||||||
{
|
{
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_server_conf", 1, "hos_bucket_not_exits");
|
|
||||||
hos_instance_s expect_hos_instance;
|
hos_instance_s expect_hos_instance;
|
||||||
expect_hos_instance.result = false;
|
hos_client_handle_t expect_hos_handle;
|
||||||
|
|
||||||
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_server_conf", 1);
|
||||||
|
memset(&expect_hos_instance, 0, sizeof(expect_hos_instance));
|
||||||
|
expect_hos_instance.status = INSTANCE_ATTEMPT_STATE;
|
||||||
expect_hos_instance.error_code = NETWORK_CONNECTION;
|
expect_hos_instance.error_code = NETWORK_CONNECTION;
|
||||||
const char *err_msg = "curlCode: 7, Couldn't connect to server";
|
const char *err_msg = "curlCode: 7, Couldn't connect to server";
|
||||||
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1);
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = "http://192.168.40.146:9098/hos/";
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
gtest_hos_handle_init(&expect_hos_handle, 1);
|
||||||
|
memcpy(expect_hos_handle.hos_config.ip, "192.168.40.146", INET_ADDRSTRLEN);
|
||||||
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
|
|
||||||
|
int ret = hos_shutdown_instance();
|
||||||
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
|
memset(&expect_hos_instance, 0, sizeof(expect_hos_instance));
|
||||||
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
|
Aws::Vector<Aws::S3::Model::Bucket>().swap(g_hos_handle.buckets);
|
||||||
|
data_info_t *data_info = (data_info_t *)expect_hos_handle.hos_func.fs2_info.reserved;
|
||||||
|
free(data_info->cache);
|
||||||
|
free(data_info->rx_bytes);
|
||||||
|
free(data_info->rx_pkts);
|
||||||
|
free(data_info->tx_bytes);
|
||||||
|
free(data_info->tx_pkts);
|
||||||
|
free(data_info->tx_failed_bytes);
|
||||||
|
free(data_info->tx_failed_pkts);
|
||||||
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -70,7 +70,8 @@ TEST(hos_open_fd, normal)
|
|||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
hos_fd_context_t expect_fd_info[2];
|
hos_fd_context_t expect_fd_info[2];
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
|
ASSERT_NE(hos_instance, nullptr);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -100,7 +101,7 @@ TEST(hos_open_fd, normal)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ TEST(hos_open_fd, paramer_error)
|
|||||||
hos_instance_s expect_hos_instance;
|
hos_instance_s expect_hos_instance;
|
||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -135,7 +136,7 @@ TEST(hos_open_fd, paramer_error)
|
|||||||
|
|
||||||
int ret = hos_shutdown_instance();
|
int ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ TEST(hos_open_fd, over_threadnums)
|
|||||||
hos_instance_s expect_hos_instance;
|
hos_instance_s expect_hos_instance;
|
||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -170,7 +171,7 @@ TEST(hos_open_fd, over_threadnums)
|
|||||||
|
|
||||||
int ret = hos_shutdown_instance();
|
int ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -190,5 +191,5 @@ TEST(hos_open_fd, over_threadnums)
|
|||||||
TEST(hos_open_fd, not_init_instance)
|
TEST(hos_open_fd, not_init_instance)
|
||||||
{
|
{
|
||||||
int fd = hos_open_fd(HOS_CONF, "object", NULL, NULL, 0);
|
int fd = hos_open_fd(HOS_CONF, "object", NULL, NULL, 0);
|
||||||
EXPECT_EQ(fd, HOS_INSTANCE_NOT_INIT);
|
EXPECT_EQ(fd, HOS_INSTANCE_NOT_ENABLE);
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -61,7 +61,7 @@ TEST(hos_shutdown_instance, normal)
|
|||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 1);
|
gtest_hos_handle_init(&expect_hos_handle, 1);
|
||||||
@@ -69,7 +69,7 @@ TEST(hos_shutdown_instance, normal)
|
|||||||
|
|
||||||
int ret = hos_shutdown_instance();
|
int ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -84,7 +84,6 @@ TEST(hos_shutdown_instance, normal)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_shutdown_instance, no_init)
|
TEST(hos_shutdown_instance, no_init)
|
||||||
@@ -99,7 +98,7 @@ TEST(hos_shutdown_instance, shutdown_more)
|
|||||||
hos_client_handle_t expect_hos_handle;
|
hos_client_handle_t expect_hos_handle;
|
||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 1);
|
gtest_hos_handle_init(&expect_hos_handle, 1);
|
||||||
@@ -107,7 +106,7 @@ TEST(hos_shutdown_instance, shutdown_more)
|
|||||||
|
|
||||||
int ret = hos_shutdown_instance();
|
int ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -122,11 +121,9 @@ TEST(hos_shutdown_instance, shutdown_more)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT);
|
EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -75,7 +75,7 @@ TEST(hos_upload_buff, normal)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -93,7 +93,7 @@ TEST(hos_upload_buff, normal)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -107,7 +107,6 @@ TEST(hos_upload_buff, normal)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_buff, bucket_not_exits)
|
TEST(hos_upload_buff, bucket_not_exits)
|
||||||
@@ -117,7 +116,7 @@ TEST(hos_upload_buff, bucket_not_exits)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -135,7 +134,7 @@ TEST(hos_upload_buff, bucket_not_exits)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -149,7 +148,6 @@ TEST(hos_upload_buff, bucket_not_exits)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_buff, param_error)
|
TEST(hos_upload_buff, param_error)
|
||||||
@@ -159,7 +157,7 @@ TEST(hos_upload_buff, param_error)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -173,7 +171,7 @@ TEST(hos_upload_buff, param_error)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -187,11 +185,10 @@ TEST(hos_upload_buff, param_error)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_buff, not_init_instance)
|
TEST(hos_upload_buff, not_init_instance)
|
||||||
{
|
{
|
||||||
int ret = hos_upload_buf(HOS_BUCKET, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0);
|
int ret = hos_upload_buf(HOS_BUCKET, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0);
|
||||||
EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT);
|
EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -75,7 +75,7 @@ TEST(hos_upload_file, normal)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -95,7 +95,7 @@ TEST(hos_upload_file, normal)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -109,7 +109,6 @@ TEST(hos_upload_file, normal)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_file, param_error)
|
TEST(hos_upload_file, param_error)
|
||||||
@@ -119,7 +118,7 @@ TEST(hos_upload_file, param_error)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -133,7 +132,7 @@ TEST(hos_upload_file, param_error)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -147,7 +146,6 @@ TEST(hos_upload_file, param_error)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_file, file_not_exits)
|
TEST(hos_upload_file, file_not_exits)
|
||||||
@@ -157,7 +155,7 @@ TEST(hos_upload_file, file_not_exits)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -171,7 +169,7 @@ TEST(hos_upload_file, file_not_exits)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -185,13 +183,12 @@ TEST(hos_upload_file, file_not_exits)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_file, not_init_instance)
|
TEST(hos_upload_file, not_init_instance)
|
||||||
{
|
{
|
||||||
int ret = hos_upload_file(HOS_BUCKET, HOS_BUFF, hos_callback, (void *)"object", 0);
|
int ret = hos_upload_file(HOS_BUCKET, HOS_BUFF, hos_callback, (void *)"object", 0);
|
||||||
EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT);
|
EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(hos_upload_file, bucket_not_exits)
|
TEST(hos_upload_file, bucket_not_exits)
|
||||||
@@ -201,7 +198,7 @@ TEST(hos_upload_file, bucket_not_exits)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, 2);
|
gtest_hos_handle_init(&expect_hos_handle, 2);
|
||||||
@@ -221,7 +218,7 @@ TEST(hos_upload_file, bucket_not_exits)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -235,5 +232,4 @@ TEST(hos_upload_file, bucket_not_exits)
|
|||||||
free(data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s));
|
||||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||||
EXPECT_EQ((void *)g_fd_context, (void *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu
|
|||||||
static void gtest_hos_instance_init(hos_instance instance)
|
static void gtest_hos_instance_init(hos_instance instance)
|
||||||
{
|
{
|
||||||
memset(instance, 0, sizeof(hos_instance_s));
|
memset(instance, 0, sizeof(hos_instance_s));
|
||||||
instance->result = true;
|
instance->status = INSTANCE_ENABLE_STATE;
|
||||||
instance->error_code = 0;
|
instance->error_code = 0;
|
||||||
instance->error_message[0] ='\0';
|
instance->error_message[0] ='\0';
|
||||||
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
instance->hos_url_prefix = "http://127.0.0.1:9098/hos/";
|
||||||
@@ -110,7 +110,7 @@ TEST(hos_write, normal)
|
|||||||
hos_fd_context_t expect_fd_info[2];
|
hos_fd_context_t expect_fd_info[2];
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -187,7 +187,7 @@ TEST(hos_write, normal)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ TEST(hos_write, bucket_not_exits)
|
|||||||
int thread_num = 3;
|
int thread_num = 3;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -287,7 +287,7 @@ TEST(hos_write, bucket_not_exits)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ TEST(hos_write, sync_mode)
|
|||||||
int thread_num = 3;
|
int thread_num = 3;
|
||||||
data_info_t * data_info = NULL;
|
data_info_t * data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -382,7 +382,7 @@ TEST(hos_write, sync_mode)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ TEST(hos_write, sync_mode_bucket_not_exits)
|
|||||||
int thread_num = 3;
|
int thread_num = 3;
|
||||||
data_info_t *data_info = NULL;
|
data_info_t *data_info = NULL;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -480,7 +480,7 @@ TEST(hos_write, sync_mode_bucket_not_exits)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -503,7 +503,7 @@ TEST(hos_write, paramer_error)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
int thread_num = 2;
|
int thread_num = 2;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -524,7 +524,7 @@ TEST(hos_write, paramer_error)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ TEST(hos_write, fd_not_find)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
int thread_num = 2;
|
int thread_num = 2;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -562,7 +562,7 @@ TEST(hos_write, fd_not_find)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -587,7 +587,7 @@ TEST(hos_write, over_threadnums)
|
|||||||
hos_fd_context_t expect_fd_info;
|
hos_fd_context_t expect_fd_info;
|
||||||
int thread_num = 2;
|
int thread_num = 2;
|
||||||
|
|
||||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
gtest_hos_handle_init(&expect_hos_handle, thread_num);
|
||||||
@@ -607,7 +607,7 @@ TEST(hos_write, over_threadnums)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
@@ -627,7 +627,7 @@ TEST(hos_write, over_threadnums)
|
|||||||
TEST(hos_write, not_init_instance)
|
TEST(hos_write, not_init_instance)
|
||||||
{
|
{
|
||||||
int ret = hos_write(3, HOS_BUFF, strlen(HOS_CONF), 0);
|
int ret = hos_write(3, HOS_BUFF, strlen(HOS_CONF), 0);
|
||||||
EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT);
|
EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_file(char *path, char **content, int *len)
|
static void read_file(char *path, char **content, int *len)
|
||||||
@@ -664,9 +664,9 @@ static void *hos_function(void *ptr)
|
|||||||
|
|
||||||
{
|
{
|
||||||
hos_instance = hos_get_instance();
|
hos_instance = hos_get_instance();
|
||||||
if (hos_instance->result == false)
|
if (hos_instance == NULL)
|
||||||
{
|
{
|
||||||
hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET);
|
hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gtest_hos_instance_init(&expect_hos_instance);
|
gtest_hos_instance_init(&expect_hos_instance);
|
||||||
@@ -723,7 +723,7 @@ static void *hos_function(void *ptr)
|
|||||||
|
|
||||||
ret = hos_shutdown_instance();
|
ret = hos_shutdown_instance();
|
||||||
EXPECT_EQ(ret, 0);
|
EXPECT_EQ(ret, 0);
|
||||||
expect_hos_instance.result = 0;
|
expect_hos_instance.status = 0;
|
||||||
expect_hos_instance.hos_url_prefix = NULL;
|
expect_hos_instance.hos_url_prefix = NULL;
|
||||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,34 @@ static int hos_attempt_connection()
|
|||||||
}
|
}
|
||||||
return g_hos_instance.error_code;
|
return g_hos_instance.error_code;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
//不主动验证bucket
|
||||||
|
//验证bucket存不存在
|
||||||
|
for (Aws::S3::Model::Bucket &new_bucket : g_hos_handle.buckets)
|
||||||
|
{
|
||||||
|
if (strcmp(new_bucket.GetName().c_str(), g_hos_handle.hos_config.bucket) == 0)
|
||||||
|
{
|
||||||
|
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_DEBUG, __FUNCTION__, "[%s] debug: bucket:%s exits",
|
||||||
|
g_hos_instance.hos_url_prefix, g_hos_handle.hos_config.bucket);
|
||||||
|
bucket_exit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bucket_exit == false)
|
||||||
|
{
|
||||||
|
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_FATAL, __FUNCTION__, "[%s]error: bucket:%s not exist.",
|
||||||
|
g_hos_instance.hos_url_prefix, g_hos_handle.hos_config.bucket);
|
||||||
|
char url[1024];
|
||||||
|
snprintf(url, 1024, g_hos_instance.hos_url_prefix);
|
||||||
|
char bucket[1024];
|
||||||
|
snprintf(bucket, 1024, g_hos_handle.hos_config.bucket);
|
||||||
|
hos_shutdown_instance();
|
||||||
|
atomic_set(&g_hos_handle.count, 0); //立即shutdown
|
||||||
|
g_hos_instance.error_code = HOS_BUCKET_NOT_EXIST;
|
||||||
|
snprintf(g_hos_instance.error_message, 1024, "[%s] error: bucket %s not exits.", url, bucket);
|
||||||
|
return HOS_BUCKET_NOT_EXIST;
|
||||||
|
}
|
||||||
g_hos_handle.buckets = outcome.GetResult().GetBuckets();
|
g_hos_handle.buckets = outcome.GetResult().GetBuckets();
|
||||||
|
#endif
|
||||||
atomic_set(&g_hos_instance.status, INSTANCE_ENABLE_STATE);
|
atomic_set(&g_hos_instance.status, INSTANCE_ENABLE_STATE);
|
||||||
return HOS_CLIENT_OK;
|
return HOS_CLIENT_OK;
|
||||||
}
|
}
|
||||||
@@ -633,17 +660,20 @@ const char *hos_get_upload_endpoint()
|
|||||||
return g_hos_instance.hos_url_prefix;
|
return g_hos_instance.hos_url_prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
hos_instance hos_init_instance(const char *conf_path, const char *module, size_t thread_num, const char *bucket)
|
hos_instance hos_init_instance(const char *conf_path, const char *module, size_t thread_num)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_client_lock);
|
std::lock_guard<std::mutex> locker(m_client_lock);
|
||||||
hos_config_t *hos_conf = &g_hos_handle.hos_config;
|
hos_config_t *hos_conf = &g_hos_handle.hos_config;
|
||||||
|
|
||||||
if (conf_path == NULL || thread_num == 0 || module == NULL || bucket == NULL)
|
memset(&g_hos_handle, 0, sizeof(g_hos_handle));
|
||||||
|
memset(&g_hos_instance, 0, sizeof(g_hos_instance));
|
||||||
|
|
||||||
|
if (conf_path == NULL || thread_num == 0 || module == NULL)
|
||||||
{
|
{
|
||||||
g_hos_instance.error_code = HOS_PARAMETER_ERROR;
|
g_hos_instance.error_code = HOS_PARAMETER_ERROR;
|
||||||
snprintf(g_hos_instance.error_message, HOS_ERROR_MESSAGE_SIZE,
|
snprintf(g_hos_instance.error_message, HOS_ERROR_MESSAGE_SIZE,
|
||||||
"param error:conf_path:%s, module:%s, thread_num:%lu, bucket:%s", conf_path, module, thread_num, bucket);
|
"param error:conf_path:%s, module:%s, thread_num:%lu", conf_path, module, thread_num);
|
||||||
return &g_hos_instance;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MESA_load_profile_string_nodef(conf_path, module, "hos_serverip", hos_conf->ip, MAX_HOS_STRING_LEN);
|
MESA_load_profile_string_nodef(conf_path, module, "hos_serverip", hos_conf->ip, MAX_HOS_STRING_LEN);
|
||||||
@@ -816,7 +846,7 @@ int hos_upload_file(const char *bucket, const char *file_path, put_finished_call
|
|||||||
struct stat buffer;
|
struct stat buffer;
|
||||||
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
||||||
{
|
{
|
||||||
return HOS_INSTANCE_NOT_INIT;
|
return HOS_INSTANCE_NOT_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bucket == NULL) || (file_path == NULL) || (thread_id > g_hos_handle.hos_config.thread_num))
|
if ((bucket == NULL) || (file_path == NULL) || (thread_id > g_hos_handle.hos_config.thread_num))
|
||||||
@@ -839,7 +869,7 @@ int hos_upload_buf(const char *bucket, const char *object, const char *buf, size
|
|||||||
{
|
{
|
||||||
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
||||||
{
|
{
|
||||||
return HOS_INSTANCE_NOT_INIT;
|
return HOS_INSTANCE_NOT_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bucket == NULL) || (object == NULL) || (buf == NULL) || (buf_len == 0)
|
if ((bucket == NULL) || (object == NULL) || (buf == NULL) || (buf_len == 0)
|
||||||
@@ -857,7 +887,7 @@ long hos_open_fd(const char *bucket, const char *object, put_finished_callback c
|
|||||||
{
|
{
|
||||||
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
||||||
{
|
{
|
||||||
return HOS_INSTANCE_NOT_INIT;
|
return HOS_INSTANCE_NOT_ENABLE;
|
||||||
}
|
}
|
||||||
if ((bucket == NULL) || (object == NULL) || (thread_id > g_hos_handle.hos_config.thread_num) || strlen(bucket) == 0 || strlen(object) == 0)
|
if ((bucket == NULL) || (object == NULL) || (thread_id > g_hos_handle.hos_config.thread_num) || strlen(bucket) == 0 || strlen(object) == 0)
|
||||||
{
|
{
|
||||||
@@ -897,7 +927,7 @@ int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id
|
|||||||
|
|
||||||
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
if (g_hos_instance.status != INSTANCE_ENABLE_STATE)
|
||||||
{
|
{
|
||||||
return HOS_INSTANCE_NOT_INIT;
|
return HOS_INSTANCE_NOT_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((stream == NULL) || (thread_id > hos_conf->thread_num))
|
if ((stream == NULL) || (thread_id > hos_conf->thread_num))
|
||||||
@@ -996,7 +1026,7 @@ int hos_close_fd(size_t fd, size_t thread_id)
|
|||||||
hos_config_t *hos_conf = &g_hos_handle.hos_config;
|
hos_config_t *hos_conf = &g_hos_handle.hos_config;
|
||||||
size_t upload_len = 0;
|
size_t upload_len = 0;
|
||||||
|
|
||||||
if (g_hos_instance.status == INSTANCE_ENABLE_STATE)
|
if (g_hos_instance.status == INSTANCE_UNINIT_STATE)
|
||||||
{
|
{
|
||||||
return HOS_INSTANCE_NOT_INIT;
|
return HOS_INSTANCE_NOT_INIT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ typedef void (*put_finished_callback)(bool result, const char *bucket, const cha
|
|||||||
* thread_num 线程数
|
* thread_num 线程数
|
||||||
* 返回值: hos 实例创建结果
|
* 返回值: hos 实例创建结果
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
hos_instance hos_init_instance(const char *conf_path, const char *module, size_t thread_num, const char *bucket);
|
hos_instance hos_init_instance(const char *conf_path, const char *module, size_t thread_num);
|
||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
* 函数名: hos_get_instance
|
* 函数名: hos_get_instance
|
||||||
* 返回值: hos_instance 成功,result 为true
|
* 返回值: hos_instance 成功,result 为true
|
||||||
|
|||||||
Reference in New Issue
Block a user