Skip to content
Snippets Groups Projects
Unverified Commit f7aa521d authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov Committed by GitHub
Browse files

Merge pull request #28 from cellframe/feature-2313

Feature 2313
parents d241e2df f8fe21b7
No related branches found
No related tags found
No related merge requests found
...@@ -100,7 +100,7 @@ connect_param* node_cli_connect(void) ...@@ -100,7 +100,7 @@ connect_param* node_cli_connect(void)
connect_param *param = DAP_NEW_Z(connect_param); connect_param *param = DAP_NEW_Z(connect_param);
CURL *curl_handle = curl_easy_init(); CURL *curl_handle = curl_easy_init();
int ret = curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, UNIX_SOCKET_FILE); // unix socket mode int ret = curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, UNIX_SOCKET_FILE); // unix socket mode
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 60L); // complete within 60 seconds curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 600L); // complete within 10 minutes
ret = curl_easy_setopt(curl_handle, CURLOPT_CONNECT_ONLY, 1L); // connection only ret = curl_easy_setopt(curl_handle, CURLOPT_CONNECT_ONLY, 1L); // connection only
ret = curl_easy_setopt(curl_handle, CURLOPT_URL, "http:/localhost/connect"); ret = curl_easy_setopt(curl_handle, CURLOPT_URL, "http:/localhost/connect");
// execute request // execute request
......
...@@ -3,18 +3,29 @@ ...@@ -3,18 +3,29 @@
#include "dap_common.h" #include "dap_common.h"
#include "dap_strfuncs.h" #include "dap_strfuncs.h"
#include "dap_file_utils.h"
//#include "dap_list.h" //#include "dap_list.h"
#include "dap_chain_global_db.h" #include "dap_chain_global_db.h"
#include "dap_chain_global_db_driver.h" #include "dap_chain_global_db_driver.h"
#include "dap_global_db_test.h" #include "dap_global_db_test.h"
#define DB_FILE "./base.sqlite" #define DB_FILE "./base.tmp"
static void test_create_db(void) static void test_create_db(const char *db_type)
{ {
unlink(DB_FILE); if(dap_dir_test(DB_FILE)) {
int res = dap_db_driver_init("sqlite", DB_FILE); rmdir(DB_FILE);
dap_assert(!res, "Test init global_db"); char *l_cmd = dap_strdup_printf("rm -rf %s", DB_FILE);
system(l_cmd);
DAP_DELETE(l_cmd);
}
else
unlink(DB_FILE);
int res = dap_db_driver_init(db_type, DB_FILE);
char *l_str = dap_strdup_printf("Test init %s global_db", db_type);
dap_assert(!res, l_str);
DAP_DELETE(l_str);
} }
static void test_write_read_one(void) static void test_write_read_one(void)
{ {
...@@ -49,14 +60,13 @@ static void test_write_read_one(void) ...@@ -49,14 +60,13 @@ static void test_write_read_one(void)
dap_store_obj_free(l_store_obj, 1); dap_store_obj_free(l_store_obj, 1);
dap_store_obj_free(l_store_obj2, 1); dap_store_obj_free(l_store_obj2, 1);
dap_assert(1, "Test dap_global_db one record"); dap_assert(1, "Test dap_global_db one record");
} }
static void test_close_db(void) static void test_close_db(void)
{ {
dap_db_driver_deinit();//dap_chain_global_db_deinit(); dap_db_driver_deinit(); //dap_chain_global_db_deinit();
dap_assert(1, "Test close global_db"); dap_assert(1, "Test close global_db");
} }
...@@ -112,24 +122,36 @@ void dap_global_db_tests_run(void) ...@@ -112,24 +122,36 @@ void dap_global_db_tests_run(void)
{ {
dap_print_module_name("dap_global_db"); dap_print_module_name("dap_global_db");
unlink(DB_FILE); // cdb
test_create_db(); test_create_db("cdb");
test_write_read_one();
benchmark_mgs_time("Read and Write in cdb 20000 records",
benchmark_test_time(test_write_db_count, 1));
// sqlite
test_create_db("sqlite");
test_write_read_one(); test_write_read_one();
// test_write_db_count(1000000); // test_write_db_count(1000000);
benchmark_mgs_time("Read and Write in global_db 20000 records", benchmark_mgs_time("Read and Write in sqlite 20000 records",
benchmark_test_time(test_write_db_count, 1)); benchmark_test_time(test_write_db_count, 1));
//test_close_db();
//dap_assert(1, "Test dap_global_db: write and read 20000 records"); //dap_assert(1, "Test dap_global_db: write and read 20000 records");
/* /*
benchmark_mgs_time("Read and Write in global_db 100 times", benchmark_mgs_time("Read and Write in global_db 100 times",
benchmark_test_time(test_write_db_count, 1)); benchmark_test_time(test_write_db_count, 1));
dap_assert(1, "Test dap_global_db 100 records"); dap_assert(1, "Test dap_global_db 100 records");
*/ */
// benchmark_mgs_rate("Read and Write in global_db", // benchmark_mgs_rate("Read and Write in global_db",
// benchmark_test_rate(test_write_db_count, 2000)); // benchmark_test_rate(test_write_db_count, 2000));
//dap_usleep(2 * DAP_USEC_PER_SEC); //dap_usleep(2 * DAP_USEC_PER_SEC);
test_close_db(); test_close_db();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment