diff --git a/src/ds3_connection.c b/src/ds3_connection.c index 26279d00..3b76b326 100644 --- a/src/ds3_connection.c +++ b/src/ds3_connection.c @@ -40,7 +40,6 @@ ds3_connection_pool* ds3_connection_pool_init(void) { } ds3_connection_pool* ds3_connection_pool_init_with_size(uint16_t pool_size) { - printf("ds3_connection_pool_init_with_size(%u)\n", pool_size); ds3_connection_pool* pool = g_new0(ds3_connection_pool, 1); pool->connections = g_new0(ds3_connection*, pool_size); @@ -64,7 +63,6 @@ void ds3_connection_pool_clear(ds3_connection_pool* pool, ds3_bool already_locke if (already_locked == False) { g_mutex_lock(&pool->mutex); } - printf("ds3_connection_pool_clear(%s)\n", (already_locked ? "locked" : "not locked")); for (index = 0; index < pool->num_connections; index++) { if (pool->connections[index] != NULL) { @@ -80,7 +78,6 @@ void ds3_connection_pool_clear(ds3_connection_pool* pool, ds3_bool already_locke } static int _queue_inc(int index, uint16_t size) { - printf("_pool_inc(%d, %u) :[%d]\n", index, size, (index+1) % size); return (index+1) % size; } @@ -93,7 +90,6 @@ ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) { ds3_connection* connection = NULL; g_mutex_lock(&pool->mutex); - printf("ds3_connection_acquire() BEGIN: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail); while (_queue_is_empty(pool) && pool->num_connections >= pool->max_connections) { g_cond_wait(&pool->available_connection_notifier, &pool->mutex); } @@ -109,7 +105,6 @@ ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) { pool->queue_tail = _queue_inc(pool->queue_tail, pool->max_connections); } - printf("ds3_connection_acquire() END: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail); g_mutex_unlock(&pool->mutex); return connection; @@ -117,7 +112,6 @@ ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) { void ds3_connection_release(ds3_connection_pool* pool, ds3_connection* connection) { g_mutex_lock(&pool->mutex); - printf("ds3_connection_release() BEGIN: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail); curl_easy_reset(connection); @@ -125,7 +119,6 @@ void ds3_connection_release(ds3_connection_pool* pool, ds3_connection* connectio pool->queue_head = _queue_inc(pool->queue_head, pool->max_connections); - printf("ds3_connection_release() END: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail); g_cond_signal(&pool->available_connection_notifier); g_mutex_unlock(&pool->mutex); } diff --git a/test/put_directory.cpp b/test/put_directory.cpp index fd23098f..b14e3227 100644 --- a/test/put_directory.cpp +++ b/test/put_directory.cpp @@ -25,78 +25,12 @@ #include "ds3_utils.h" #include "test.h" -/* -BOOST_AUTO_TEST_CASE( put_directory) { - printf("-----Testing PUT all objects in a directory-------\n"); - - const char* dir_path = getenv("DS3_TEST_DIRECTORY"); - if (dir_path == NULL) { - printf("ENV[DS3_TEST_DIRECTORY] unset - Skipping put_directory test.\n"); - return; - } - - const char* bucket_name = "test_bulk_put_directory"; - printf(" Putting all files in [%s] to bucket [%s]\n", dir_path, bucket_name); - - ds3_client* client = get_client(); - int client_thread=1; - ds3_client_register_logging(client, DS3_DEBUG, test_log, (void*)&client_thread); // Use DEBUG level logging - - ds3_error* error = create_bucket_with_data_policy(client, bucket_name, ids.data_policy_id->value); - - char* objects_list[100]; - uint64_t num_objs = 0; - GDir* dir_info = g_dir_open(dir_path, 0, NULL); - for (char* current_obj = (char*)g_dir_read_name(dir_info); current_obj != NULL; current_obj = (char*)g_dir_read_name(dir_info)) { - objects_list[num_objs++] = current_obj; - printf(" obj[%" PRIu64 "][%s]\n", num_objs, objects_list[num_objs-1]); - } - - ds3_bulk_object_list_response* bulk_object_list = ds3_convert_file_list_with_basepath((const char**)objects_list, num_objs, dir_path); - - ds3_request* request = ds3_init_put_bulk_job_spectra_s3_request(bucket_name, bulk_object_list); - ds3_master_object_list_response* mol; - error = ds3_put_bulk_job_spectra_s3_request(client, request, &mol); - ds3_request_free(request); - ds3_bulk_object_list_response_free(bulk_object_list); - handle_error(error); - - // Allocate cache - ds3_master_object_list_response* chunks_list = ensure_available_chunks(client, mol->job_id); - - // Use helper functions from test.cpp - GPtrArray* put_dir_args = new_put_chunks_threads_args(client, NULL, dir_path, bucket_name, mol, chunks_list, 1, True); // Last param indicates verbose logging in the spawned thread - - // capture test start time - struct timespec start_time_t, end_time_t; - double elapsed_t; - clock_gettime(CLOCK_MONOTONIC, &start_time_t); - - GThread* put_dir_xfer_thread = g_thread_new("put_dir_xfer_thread", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 0)); - - // Block and cleanup GThread(s) - g_thread_join(put_dir_xfer_thread); - - // find elapsed CPU and real time - clock_gettime(CLOCK_MONOTONIC, &end_time_t); - elapsed_t = timespec_to_seconds(&end_time_t) - timespec_to_seconds(&start_time_t); - ds3_log_message(client->log, DS3_INFO, " Elapsed time[%f]", elapsed_t); - - g_dir_close(dir_info); - ds3_master_object_list_response_free(chunks_list); - ds3_master_object_list_response_free(mol); - put_chunks_threads_args_free(put_dir_args); - clear_bucket(client, bucket_name); - free_client(client); -} -*/ - BOOST_AUTO_TEST_CASE( put_directory_4_threads) { printf("-----Testing PUT all objects in a directory with 4 threads-------\n"); const char* dir_path = getenv("DS3_TEST_DIRECTORY"); if (dir_path == NULL) { - printf("ENV[DS3_TEST_DIRECTORY] unset - Skipping put_directory test.\n"); + printf("ENV[DS3_TEST_DIRECTORY] unset - Skipping put_directory_4_threads test.\n"); return; } diff --git a/test/test.cpp b/test/test.cpp index 8a4509cf..b6f67cf2 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -45,12 +45,13 @@ struct BoostTestFixture { BOOST_GLOBAL_FIXTURE( BoostTestFixture ); -void log_timestamp(char* string_buff, long buff_size) +static void _log_timestamp(char* string_buff, long buff_size) { time_t ltime; struct tm result; struct timeval tv; char usec_buff[8]; + int millisec; gettimeofday(&tv, NULL); millisec = lrint(tv.tv_usec/1000.0); // Round to nearest millisec @@ -58,15 +59,15 @@ void log_timestamp(char* string_buff, long buff_size) ltime = time(NULL); localtime_r(<ime, &result); - strftime(string_buff, buff_size, "%Y:%m:%dT%H:%M:%S", tm); + strftime(string_buff, buff_size, "%Y:%m:%dT%H:%M:%S", &result); strcat(string_buff, "."); - sprintf(usec_buff,"%d", (int)tmnow.tv_usec); + sprintf(usec_buff,"%03d", millisec); strcat(string_buff, usec_buff); } void test_log(const char* message, void* user_data) { char timebuffer[32]; - log_timestamp(timebuffer, 32); + _log_timestamp(timebuffer, 32); if (user_data) { int client_num = *((int*)user_data); fprintf(stderr, "%s Client[%d] %s\n", timebuffer, client_num, message);