CUBRID Engine  latest
broker_tester.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <sys/time.h>
#include "broker_config.h"
#include "broker_util.h"
#include "broker_shm.h"
#include "broker_filename.h"
#include "cas_protocol.h"
#include "cas_common.h"
#include "cubrid_getopt.h"
#include "cas_cci.h"
#include "ini_parser.h"
Include dependency graph for broker_tester.c:

Go to the source code of this file.

Classes

struct  TESTER_INFO
 

Macros

#define TESTER_ERR_MSG_SIZE   1024
 
#define TIME_BUF_SIZE   50
 
#define MAX_DISPLAY_LENGTH   20
 
#define DEFAULT_EMPTY_STRING   "\0"
 
#define DEFAULT_CUB_USER_NAME   "PUBLIC"
 
#define DEFAULT_ORACLE_USER_NAME   "scott"
 
#define DEFAULT_ORACLE_PASSWORD   "tiger"
 
#define DEFAULT_MYSQL_USER_NAME   "root"
 
#define RESULT_FORMAT   "%-15s"
 
#define SHARD_ID_FORMAT   "%-10d"
 
#define STR_SHARD_ID_FORMAT   "%-10s"
 
#define ROWCOUNT_FORMAT   "%-15d"
 
#define QUERY_FORMAT   "%s"
 
#define STR_ROWCOUNT_FORMAT   "%-15s"
 
#define TIME_FORMAT   "%-20s"
 
#define PRINT_CCI_ERROR(...)
 
#define PRINT_RESULT(...)
 
#define PRINT_TITLE(n, ...)
 

Functions

static int init_tester_info (char *broker_name)
 
static void init_default_conn_info (int appl_server_type)
 
static int get_master_shm_id (void)
 
static void get_time (struct timeval *start_time, char *time, int buf_len)
 
static int execute_test_with_query (int conn_handle, char *query, int shard_flag)
 
static int execute_test (int conn_handle, int shard_flag)
 
static void print_usage (void)
 
static void print_conn_result (char *broker_name, int conn_hd_id)
 
static void print_shard_result (void)
 
static void print_title (int shard_flag)
 
static void print_result (int row_count, int err_code, int shard_flag, int shard_id, char *time, char *query)
 
static int print_result_set (int req, T_CCI_ERROR *err_buf, T_CCI_COL_INFO *col_info, int col_count)
 
static void print_query_test_result (int ret)
 
static void print_line (const char *ch, int num)
 
static void free_br_tester_info (void)
 
static bool is_number_type (T_CCI_U_TYPE type)
 
int main (int argc, char *argv[])
 

Variables

static const char SECTION_NAME [] = "broker"
 
static FILE * out_file_fp
 
static char tester_err_msg [TESTER_ERR_MSG_SIZE]
 
TESTER_INFO br_tester_info
 

Macro Definition Documentation

#define DEFAULT_CUB_USER_NAME   "PUBLIC"

Definition at line 61 of file broker_tester.c.

Referenced by init_default_conn_info().

#define DEFAULT_EMPTY_STRING   "\0"

Definition at line 60 of file broker_tester.c.

Referenced by init_default_conn_info().

#define DEFAULT_MYSQL_USER_NAME   "root"

Definition at line 64 of file broker_tester.c.

Referenced by init_default_conn_info().

#define DEFAULT_ORACLE_PASSWORD   "tiger"

Definition at line 63 of file broker_tester.c.

Referenced by init_default_conn_info().

#define DEFAULT_ORACLE_USER_NAME   "scott"

Definition at line 62 of file broker_tester.c.

Referenced by init_default_conn_info().

#define MAX_DISPLAY_LENGTH   20

Definition at line 58 of file broker_tester.c.

Referenced by print_result_set().

#define PRINT_CCI_ERROR (   ...)
Value:
do { \
{ \
{ \
fprintf (out_file_fp , "<Error>\n");\
fprintf (out_file_fp , __VA_ARGS__); \
} \
fprintf (stderr, "<Error>\n"); \
fprintf (stderr, __VA_ARGS__); \
} \
} while(0)
TESTER_INFO br_tester_info
static FILE * out_file_fp
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 74 of file broker_tester.c.

Referenced by main(), print_result(), and print_result_set().

#define PRINT_RESULT (   ...)
Value:
do { \
{ \
fprintf (out_file_fp ,__VA_ARGS__); \
} \
fprintf (stdout, __VA_ARGS__); \
} while (0)
static FILE * out_file_fp
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 88 of file broker_tester.c.

Referenced by print_conn_result(), print_line(), print_query_test_result(), print_result(), print_result_set(), print_shard_result(), and print_title().

#define PRINT_TITLE (   n,
  ... 
)
Value:
do { \
{ \
fprintf (out_file_fp ,__VA_ARGS__); \
} \
n += fprintf (stdout, __VA_ARGS__); \
} while (0)
static FILE * out_file_fp
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 97 of file broker_tester.c.

Referenced by print_result_set(), and print_title().

#define QUERY_FORMAT   "%s"

Definition at line 70 of file broker_tester.c.

Referenced by print_result(), and print_title().

#define RESULT_FORMAT   "%-15s"

Definition at line 66 of file broker_tester.c.

Referenced by print_result(), and print_title().

#define ROWCOUNT_FORMAT   "%-15d"

Definition at line 69 of file broker_tester.c.

Referenced by print_result().

#define SHARD_ID_FORMAT   "%-10d"

Definition at line 67 of file broker_tester.c.

Referenced by print_result().

#define STR_ROWCOUNT_FORMAT   "%-15s"

Definition at line 71 of file broker_tester.c.

Referenced by print_title().

#define STR_SHARD_ID_FORMAT   "%-10s"

Definition at line 68 of file broker_tester.c.

Referenced by print_title().

#define TESTER_ERR_MSG_SIZE   1024

Definition at line 56 of file broker_tester.c.

#define TIME_FORMAT   "%-20s"

Definition at line 72 of file broker_tester.c.

Referenced by print_result(), and print_title().

Function Documentation

static int execute_test ( int  conn_handle,
int  shard_flag 
)
static

Definition at line 450 of file broker_tester.c.

References execute_test_with_query(), TESTER_INFO::input_file_name, NULL, p, print_title(), and trim().

Referenced by main().

Here is the caller graph for this function:

static int execute_test_with_query ( int  conn_handle,
char *  query,
int  shard_flag 
)
static
static void free_br_tester_info ( void  )
static

Definition at line 769 of file broker_tester.c.

References TESTER_INFO::command, TESTER_INFO::db_name, TESTER_INFO::db_passwd, TESTER_INFO::db_user, FREE_MEM, TESTER_INFO::input_file_name, and TESTER_INFO::output_file_name.

Referenced by main().

Here is the caller graph for this function:

static int get_master_shm_id ( void  )
static

Definition at line 278 of file broker_tester.c.

References BROKER_PATH_MAX, envvar_get(), FID_CUBRID_BROKER_CONF, get_cubrid_file(), ini_findsec(), ini_gethex(), ini_parser_free(), ini_parser_load(), NULL, SECTION_NAME, and strncpy_bufsize.

Referenced by init_tester_info().

Here is the caller graph for this function:

static void get_time ( struct timeval *  start_time,
char *  time,
int  buf_len 
)
static

Definition at line 326 of file broker_tester.c.

References assert, and NULL.

Referenced by execute_test_with_query().

Here is the caller graph for this function:

static void init_default_conn_info ( int  appl_server_type)
static
static bool is_number_type ( T_CCI_U_TYPE  type)
static

Definition at line 751 of file broker_tester.c.

Referenced by print_result_set().

Here is the caller graph for this function:

static void print_conn_result ( char *  broker_name,
int  conn_hd_id 
)
static

Definition at line 550 of file broker_tester.c.

References TESTER_INFO::db_name, TESTER_INFO::db_user, and PRINT_RESULT.

Referenced by main().

Here is the caller graph for this function:

static void print_line ( const char *  ch,
int  num 
)
static

Definition at line 496 of file broker_tester.c.

References i, and PRINT_RESULT.

Referenced by print_result_set(), and print_title().

Here is the caller graph for this function:

static void print_query_test_result ( int  ret)
static

Definition at line 566 of file broker_tester.c.

References PRINT_RESULT.

Referenced by main().

Here is the caller graph for this function:

static void print_result ( int  row_count,
int  err_code,
int  shard_flag,
int  shard_id,
char *  time,
char *  query 
)
static

Definition at line 600 of file broker_tester.c.

References ON, PRINT_CCI_ERROR, PRINT_RESULT, QUERY_FORMAT, RESULT_FORMAT, ROWCOUNT_FORMAT, SHARD_ID_FORMAT, tester_err_msg, and TIME_FORMAT.

Referenced by execute_test_with_query().

Here is the caller graph for this function:

static int print_result_set ( int  req,
T_CCI_ERROR *  err_buf,
T_CCI_COL_INFO *  col_info,
int  col_count 
)
static

Definition at line 636 of file broker_tester.c.

References FREE_MEM, i, is_number_type(), MAX_DISPLAY_LENGTH, NULL, PRINT_CCI_ERROR, print_line(), PRINT_RESULT, PRINT_TITLE, and strlen.

Referenced by execute_test_with_query().

Here is the caller graph for this function:

static void print_shard_result ( void  )
static

Definition at line 583 of file broker_tester.c.

References ON, PRINT_RESULT, and TESTER_INFO::shard_flag.

Referenced by main().

Here is the caller graph for this function:

static void print_title ( int  shard_flag)
static

Definition at line 527 of file broker_tester.c.

References ON, print_line(), PRINT_RESULT, PRINT_TITLE, QUERY_FORMAT, RESULT_FORMAT, STR_ROWCOUNT_FORMAT, STR_SHARD_ID_FORMAT, and TIME_FORMAT.

Referenced by execute_test(), and main().

Here is the caller graph for this function:

static void print_usage ( void  )
static

Definition at line 512 of file broker_tester.c.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

TESTER_INFO br_tester_info

Definition at line 127 of file broker_tester.c.

FILE* out_file_fp
static

Definition at line 108 of file broker_tester.c.

Referenced by main().

const char SECTION_NAME[] = "broker"
static

Definition at line 106 of file broker_tester.c.

Referenced by get_master_shm_id().

char tester_err_msg[TESTER_ERR_MSG_SIZE]
static

Definition at line 110 of file broker_tester.c.

Referenced by execute_test_with_query(), and print_result().