diff --git a/t/pt-pmp/aggregate_stacktrace.sh b/t/pt-pmp/aggregate_stacktrace.sh deleted file mode 100644 index 62dbb549..00000000 --- a/t/pt-pmp/aggregate_stacktrace.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash - -# This test file must be ran by util/test-bash-functions. - -TESTS=6 -PT_TMPDIR=$TEST_PT_TMPDIR - -# ############################################################################ -TEST_NAME="stacktrace-001.txt" -# ############################################################################ -cat > $PT_TMPDIR/expected < $PT_TMPDIR/got -no_diff $PT_TMPDIR/got $PT_TMPDIR/expected - -# ############################################################################ -TEST_NAME="stacktrace-002.txt" -# ############################################################################ -cat > $PT_TMPDIR/expected < $PT_TMPDIR/got -no_diff $PT_TMPDIR/got $PT_TMPDIR/expected - -# ############################################################################ -TEST_NAME="stacktrace-003.txt" -# ############################################################################ -cat > $PT_TMPDIR/expected < $PT_TMPDIR/got -no_diff $PT_TMPDIR/got $PT_TMPDIR/expected - -# ############################################################################ -TEST_NAME="stacktrace-003-b.txt" -# ############################################################################ -cat > $PT_TMPDIR/expected < $PT_TMPDIR/got -no_diff $PT_TMPDIR/got $PT_TMPDIR/expected - -# ############################################################################ -TEST_NAME="stacktrace-004.txt" -# ############################################################################ -cat > $PT_TMPDIR/expected < $PT_TMPDIR/got -no_diff $PT_TMPDIR/got $PT_TMPDIR/expected - -# ############################################################################ -TEST_NAME="stacktrace-005.txt" -# ############################################################################ -cat > $PT_TMPDIR/expected < $PT_TMPDIR/got -no_diff $PT_TMPDIR/got $PT_TMPDIR/expected diff --git a/t/pt-pmp/pt-pmp.t b/t/pt-pmp/pt-pmp.t index 4d3f85ea..378e6309 100644 --- a/t/pt-pmp/pt-pmp.t +++ b/t/pt-pmp/pt-pmp.t @@ -11,9 +11,30 @@ use warnings FATAL => 'all'; use English qw(-no_match_vars); use PerconaTest; +use Test::More; -my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/; -push @ARGV, "$trunk/t/$tool/*.sh" unless @ARGV; -system("$trunk/util/test-bash-functions $trunk/bin/$tool @ARGV"); +my $sample = "$trunk/t/pt-pmp/samples"; -exit; +opendir my $dh, $sample or die "Error opening $sample: $OS_ERROR"; +while ( my $file = readdir $dh ) { + next unless -f "$sample/$file" && "$sample/$file" =~ m/\.in$/; + (my $outfile = $file) =~ s/\.in/.out/; + ok( + no_diff( + "$trunk/bin/pt-pmp $sample/$file", + "t/pt-pmp/samples/$outfile", + ), + "$file" + ); +} +closedir $dh; + +ok( + no_diff( + "$trunk/bin/pt-pmp -l 2 $sample/stacktrace003.in", + "t/pt-pmp/samples/stacktrace003-limit2.out", + ), + "Limit 2 (stacktrace003-limit2.out)" +); + +done_testing; diff --git a/t/pt-pmp/samples/stacktrace-001.txt b/t/pt-pmp/samples/stacktrace001.in similarity index 100% rename from t/pt-pmp/samples/stacktrace-001.txt rename to t/pt-pmp/samples/stacktrace001.in diff --git a/t/pt-pmp/samples/stacktrace001.out b/t/pt-pmp/samples/stacktrace001.out new file mode 100644 index 00000000..c45192b8 --- /dev/null +++ b/t/pt-pmp/samples/stacktrace001.out @@ -0,0 +1,20 @@ + 187 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,open_table,open_tables,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 62 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,close_thread_tables,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 39 read(libpthread.so.0),vio_read(unistd.h:35),my_real_read,my_net_read,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 18 pthread_cond_wait,safe_cond_wait,os_event_wait_low,os_aio_simulated_handle,fil_aio_wait,io_handler_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 15 pthread_cond_wait,safe_cond_wait,end_thread,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 15 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,open_table,open_tables,mysql_update,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 12 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,open_table,open_tables,open_and_lock_tables,mysql_insert,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 2 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_107(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,Log_event::read_log_event,mysql_binlog_send,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_master_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_lock_timeout_and_monitor_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_error_monitor_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),handle_connections_sockets,main + 1 _sanity,_myfree,st_join_table::cleanup,JOIN::cleanup,JOIN::join_free,do_select,JOIN::exec,mysql_select,handle_select,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 pread64(libpthread.so.0),_os_file_pread(unistd.h:57),_os_file_read,_fil_io,buf_read_page_low,buf_read_page,buf_page_get_gen,btr_cur_search_to_nth_level,btr_estimate_n_rows_in_range,ha_innobase::records_in_range,check_quick_keys,check_quick_select,get_key_scans_params,SQL_SELECT::test_quick_select,mysql_update,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,_sanity,_myrealloc,String::realloc,String::append,Log_event::read_log_event,mysql_binlog_send,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,_sanity,_mymalloc,_myrealloc,mi_alloc_rec_buff,mi_open,ha_myisam::open,handler::ha_open,open_tmp_table,create_tmp_table,select_union::create_result_table,mysql_derived_prepare,mysql_handle_derived,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,_sanity,_mymalloc,init_dynamic_array,QUICK_RANGE_SELECT,get_quick_select,TRP_RANGE::make_quick,SQL_SELECT::test_quick_select,make_join_statistics,JOIN::optimize,mysql_select,mysql_derived_filling,mysql_handle_derived,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,_mymalloc,alloc_root,MYSQLparse,mysql_make_view,open_unireg_entry,open_table,open_tables,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_107(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,mi_open,ha_myisam::open,handler::ha_open,open_tmp_table,create_tmp_table,select_union::create_result_table,mysql_derived_prepare,mysql_handle_derived,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 do_sigwait(libpthread.so.0),sigwait(libpthread.so.0),signal_hand,start_thread(libpthread.so.0),clone(libc.so.6) diff --git a/t/pt-pmp/samples/stacktrace-002.txt b/t/pt-pmp/samples/stacktrace002.in similarity index 100% rename from t/pt-pmp/samples/stacktrace-002.txt rename to t/pt-pmp/samples/stacktrace002.in diff --git a/t/pt-pmp/samples/stacktrace002.out b/t/pt-pmp/samples/stacktrace002.out new file mode 100644 index 00000000..d3e181bb --- /dev/null +++ b/t/pt-pmp/samples/stacktrace002.out @@ -0,0 +1,12 @@ + 2387 pthread_cond_wait,open_table,open_tables,open_and_lock_tables_derived,execute_sqlcom_select,mysql_execute_command,mysql_parse,dispatch_command,do_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 5 pthread_cond_wait,open_table,open_tables,open_and_lock_tables_derived,mysql_insert,mysql_execute_command,mysql_parse,dispatch_command,do_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 4 pthread_cond_wait,os_event_wait_low,os_aio_simulated_handle,fil_aio_wait,io_handler_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 4 pthread_cond_wait,open_table,open_tables,open_and_lock_tables_derived,mysql_delete,mysql_execute_command,mysql_parse,dispatch_command,do_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_master_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_lock_timeout_and_monitor_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_error_monitor_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),handle_connections_sockets,main,select(libc.so.6) + 1 read(libpthread.so.0),my_real_read,my_net_read,do_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 pthread_cond_wait,cache_thread,one_thread_per_connection_end,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 free(libc.so.6),ut_free,page_cur_insert_rec_low,btr_cur_optimistic_insert,row_ins_index_entry_low,row_ins_index_entry,row_ins,row_ins_step,row_insert_for_mysql,ha_innobase::write_row,handler::ha_write_row,ha_partition::copy_partitions,ha_partition::change_partitions,handler::ha_change_partitions,mysql_change_partitions,fast_alter_partition_table,mysql_alter_table,mysql_execute_command,mysql_parse,dispatch_command,do_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 do_sigwait(libpthread.so.0),sigwait(libpthread.so.0),signal_hand,start_thread(libpthread.so.0),clone(libc.so.6) diff --git a/t/pt-pmp/samples/stacktrace003-limit2.out b/t/pt-pmp/samples/stacktrace003-limit2.out new file mode 100644 index 00000000..1782bb88 --- /dev/null +++ b/t/pt-pmp/samples/stacktrace003-limit2.out @@ -0,0 +1,9 @@ + 35 pthread_cond_wait,end_thread + 20 read(libpthread.so.0),read(unistd.h:35) + 18 pthread_cond_wait,os_event_wait_low + 3 select(libc.so.6),os_thread_sleep + 3 pthread_cond_wait,MYSQL_LOG::wait_for_update + 1 select(libc.so.6),handle_connections_sockets + 1 do_sigwait(libpthread.so.0),sigwait(libpthread.so.0) + 1 btr_search_guess_on_hash(libc.so.6),btr_cur_search_to_nth_level + 1 btr_cur_search_to_nth_level,btr_estimate_n_rows_in_range diff --git a/t/pt-pmp/samples/stacktrace-003.txt b/t/pt-pmp/samples/stacktrace003.in similarity index 100% rename from t/pt-pmp/samples/stacktrace-003.txt rename to t/pt-pmp/samples/stacktrace003.in diff --git a/t/pt-pmp/samples/stacktrace003.out b/t/pt-pmp/samples/stacktrace003.out new file mode 100644 index 00000000..3035b521 --- /dev/null +++ b/t/pt-pmp/samples/stacktrace003.out @@ -0,0 +1,11 @@ + 35 pthread_cond_wait,end_thread,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 20 read(libpthread.so.0),read(unistd.h:35),vio_read(unistd.h:35),my_real_read,my_net_read,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 18 pthread_cond_wait,os_event_wait_low,os_aio_simulated_handle,fil_aio_wait,io_handler_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 3 pthread_cond_wait,MYSQL_LOG::wait_for_update,mysql_binlog_send,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_master_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_lock_timeout_and_monitor_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),os_thread_sleep,srv_error_monitor_thread,start_thread(libpthread.so.0),clone(libc.so.6) + 1 select(libc.so.6),handle_connections_sockets,main + 1 do_sigwait(libpthread.so.0),sigwait(libpthread.so.0),signal_hand,start_thread(libpthread.so.0),clone(libc.so.6) + 1 btr_search_guess_on_hash(libc.so.6),btr_cur_search_to_nth_level,btr_pcur_open_with_no_init,row_search_for_mysql,ha_innobase::index_read,join_read_always_key,sub_select,evaluate_join_record,sub_select,evaluate_join_record,sub_select,evaluate_join_record,sub_select,evaluate_join_record,sub_select,evaluate_join_record,sub_select,do_select,JOIN::exec,mysql_select,handle_select,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 btr_cur_search_to_nth_level,btr_estimate_n_rows_in_range,ha_innobase::records_in_range,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_keys,check_quick_select,get_key_scans_params,SQL_SELECT::test_quick_select,get_quick_record_count,make_join_statistics,JOIN::optimize,mysql_select,handle_select,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) diff --git a/t/pt-pmp/samples/stacktrace-004.txt b/t/pt-pmp/samples/stacktrace004.in similarity index 100% rename from t/pt-pmp/samples/stacktrace-004.txt rename to t/pt-pmp/samples/stacktrace004.in diff --git a/t/pt-pmp/samples/stacktrace004.out b/t/pt-pmp/samples/stacktrace004.out new file mode 100644 index 00000000..e144a372 --- /dev/null +++ b/t/pt-pmp/samples/stacktrace004.out @@ -0,0 +1,5 @@ + 33 pthread_cond_wait,boost::condition_variable::wait,Queue::pop,Worker::work,boost::_mfi::mf0::operator,boost::_bi::list1::operator,boost::_bi::bind_t::operator,boost::detail::thread_data::run,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 StringBuilder::length,Parser::add,Parser::try_parse_query,Parser::parse_block,Parser::work,boost::_mfi::mf0::operator,boost::_bi::list1::operator,boost::_bi::bind_t::operator,boost::detail::thread_data::run,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 pthread_cond_wait,boost::thread::join(libboost_thread-mt.so.5),LogReader::wait,Replay::wait,main + 1 pthread_cond_wait,boost::condition_variable::wait,Queue::push,LogReader::work,boost::_mfi::mf0::operator,boost::_bi::list1::operator,boost::_bi::bind_t::operator,boost::detail::thread_data::run,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 pthread_cond_wait,boost::condition_variable::wait,Queue::pop,Reporter::work,boost::_mfi::mf0::operator,boost::_bi::list1::operator,boost::_bi::bind_t::operator,boost::detail::thread_data::run,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? diff --git a/t/pt-pmp/samples/stacktrace-005.txt b/t/pt-pmp/samples/stacktrace005.in similarity index 100% rename from t/pt-pmp/samples/stacktrace-005.txt rename to t/pt-pmp/samples/stacktrace005.in diff --git a/t/pt-pmp/samples/stacktrace005.out b/t/pt-pmp/samples/stacktrace005.out new file mode 100644 index 00000000..4b2e414c --- /dev/null +++ b/t/pt-pmp/samples/stacktrace005.out @@ -0,0 +1,6 @@ + 32 read(libc.so.6),vio_read_buff(libmysqlclient.so.16),libmysqlclient::??(libmysqlclient.so.16),my_net_read(libmysqlclient.so.16),cli_safe_read(libmysqlclient.so.16),libmysqlclient::??(libmysqlclient.so.16),mysql_real_query(libmysqlclient.so.16),Connection::run,Worker::work,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 pthread_cond_wait,LogReader::work,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 pthread_cond_wait,boost::thread::join(libboost_thread-mt.so.5),main + 1 pthread_cond_wait,boost::condition_variable::wait,Worker::work,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 pthread_cond_wait,boost::condition_variable::wait,Reporter::work,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),?? + 1 pthread_cond_wait,boost::condition_variable::wait,Queue::push,Parser::work,thread_proxy(libboost_thread-mt.so.5),start_thread(libpthread.so.0),clone(libc.so.6),??