Remove unused modules and their tests.

This commit is contained in:
Daniel Nichter
2011-07-13 16:55:38 -06:00
parent 1f52b66919
commit ea0b8c3d5a
5 changed files with 0 additions and 2845 deletions

View File

@@ -1,234 +0,0 @@
#!/usr/bin/perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 2;
use InnoDBStatusParser;
use PerconaTest;
use Data::Dumper;
$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Quotekeys = 0;
my $is = new InnoDBStatusParser();
isa_ok($is, 'InnoDBStatusParser');
# Very basic status on quiet sandbox server.
is_deeply(
$is->parse(load_file('t/lib/samples/is001.txt')),
{
deadlock_locks => [],
deadlock_transactions => [],
insert_buffer_pages => [],
io_threads => [
{
event_set => undef,
id => '0',
io_avg_wait => undef,
io_reads => undef,
io_requests => undef,
io_wait => undef,
io_writes => undef,
max_io_wait => undef,
purpose => 'insert buffer thread',
state => 'waiting for i/o request'
},
{
event_set => undef,
id => '1',
io_avg_wait => undef,
io_reads => undef,
io_requests => undef,
io_wait => undef,
io_writes => undef,
max_io_wait => undef,
purpose => 'log thread',
state => 'waiting for i/o request'
},
{
event_set => undef,
id => '2',
io_avg_wait => undef,
io_reads => undef,
io_requests => undef,
io_wait => undef,
io_writes => undef,
max_io_wait => undef,
purpose => 'read thread',
state => 'waiting for i/o request'
},
{
event_set => undef,
id => '3',
io_avg_wait => undef,
io_reads => undef,
io_requests => undef,
io_wait => undef,
io_writes => undef,
max_io_wait => undef,
purpose => 'write thread',
state => 'waiting for i/o request'
}
],
mutex_waits => [],
status => [
{
Innodb_awe_memory_allocated => undef,
Innodb_buffer_pool_awe_mapped => undef,
Innodb_buffer_pool_awe_memory_frames => undef,
Innodb_buffer_pool_awe_pages_remapped_sec => undef,
Innodb_buffer_pool_hit_rate => '1',
Innodb_buffer_pool_pages_created => '178',
Innodb_buffer_pool_pages_created_sec => '0.00',
Innodb_buffer_pool_pages_data => '178',
Innodb_buffer_pool_pages_dirty => '0',
Innodb_buffer_pool_pages_free => '333',
Innodb_buffer_pool_pages_read => '0',
Innodb_buffer_pool_pages_read_sec => '0.00',
Innodb_buffer_pool_pages_total => '512',
Innodb_buffer_pool_pages_written => '189',
Innodb_buffer_pool_pages_written_sec => '0.43',
Innodb_buffer_pool_pending_data_writes => '0',
Innodb_buffer_pool_pending_dirty_writes => '0',
Innodb_buffer_pool_pending_fsyncs => 0,
Innodb_buffer_pool_pending_reads => '0',
Innodb_buffer_pool_pending_single_writes => '0',
Innodb_common_memory_allocated => '675584',
Innodb_data_bytes_per_read => '0',
Innodb_data_fsyncs => '16',
Innodb_data_fsyncs_sec => '0.08',
Innodb_data_pending_fsyncs => 0,
Innodb_data_pending_preads => undef,
Innodb_data_pending_pwrites => undef,
Innodb_data_reads => '0',
Innodb_data_reads_sec => '0.00',
Innodb_data_writes => '38',
Innodb_data_writes_sec => '0.14',
Innodb_dictionary_memory_allocated => undef,
Innodb_hash_searches_sec => '0.00',
Innodb_hash_table_buf_frames_reserved => '1',
Innodb_hash_table_size => '17393',
Innodb_hash_table_used_cells => '0',
Innodb_history_list_length => '0',
Innodb_insert_buffer_free_list_length => '0',
Innodb_insert_buffer_inserts => '0',
Innodb_insert_buffer_merged_records => '0',
Innodb_insert_buffer_merges => '0',
Innodb_insert_buffer_pending_reads => '0',
Innodb_insert_buffer_segment_size => '2',
Innodb_insert_buffer_size => '1',
Innodb_lock_struct_count => '0',
Innodb_lock_wait_timeouts => undef,
Innodb_log_caller_write_background_async => undef,
Innodb_log_caller_write_background_sync => undef,
Innodb_log_caller_write_buffer_pool => undef,
Innodb_log_caller_write_checkpoint_async => undef,
Innodb_log_caller_write_checkpoint_sync => undef,
Innodb_log_caller_write_commit_async => undef,
Innodb_log_caller_write_commit_sync => undef,
Innodb_log_caller_write_internal => undef,
Innodb_log_caller_write_log_archive => undef,
Innodb_log_flushed_to => '0 43655',
Innodb_log_ios => '11',
Innodb_log_ios_sec => '0.03',
Innodb_log_last_checkpoint => '0 43655',
Innodb_log_pending_chkp_writes => '0',
Innodb_log_pending_io => '0',
Innodb_log_pending_writes => '0',
Innodb_log_sequence_no => '0 43655',
Innodb_log_syncer_write_background_async => undef,
Innodb_log_syncer_write_background_sync => undef,
Innodb_log_syncer_write_buffer_pool => undef,
Innodb_log_syncer_write_checkpoint_async => undef,
Innodb_log_syncer_write_checkpoint_sync => undef,
Innodb_log_syncer_write_commit_async => undef,
Innodb_log_syncer_write_commit_sync => undef,
Innodb_log_syncer_write_internal => undef,
Innodb_log_syncer_write_log_archive => undef,
Innodb_main_thread_id => '140284306659664',
Innodb_main_thread_proc_no => '4257',
Innodb_main_thread_state => 'waiting for server activity',
Innodb_mutex_os_waits => '0',
Innodb_mutex_rw_excl_os_waits => '0',
Innodb_mutex_rw_excl_spins => '0',
Innodb_mutex_rw_shared_os_waits => '7',
Innodb_mutex_rw_shared_spins => '14',
Innodb_mutex_spin_rounds => '2',
Innodb_mutex_spin_waits => '0',
Innodb_nonhash_searches_sec => '0.00',
Innodb_num_io_threads => 4,
Innodb_os_log_pending_fsyncs => 0,
Innodb_pending_aio_reads => '0',
Innodb_pending_aio_writes => '0',
Innodb_pending_sync_io => '0',
Innodb_purged_to => '0 0',
Innodb_read_views_open => '1',
Innodb_reserved_extent_count => undef,
Innodb_rows_deleted => '0',
Innodb_rows_deleted_sec => '0.00',
Innodb_rows_inserted => '0',
Innodb_rows_inserted_sec => '0.00',
Innodb_rows_read => '0',
Innodb_rows_read_sec => '0.00',
Innodb_rows_updated => '0',
Innodb_rows_updated_sec => '0.00',
Innodb_status_interval => '37',
Innodb_status_time => '2009-07-07 13:18:38',
Innodb_status_truncated => 0,
Innodb_threads_inside_kernel => '0',
Innodb_threads_queued => '0',
Innodb_total_memory_allocated => '20634452',
Innodb_transaction_counter => '0 769',
Innodb_transactions => 1,
Innodb_transactions_truncated => 0,
Innodb_undo_log_record => '0 0',
Innodb_wait_array_reservation_count => '7',
Innodb_wait_array_signal_count => '7'
}
],
transaction_locks => [],
transactions => [
{
active_secs => undef,
heap_size => undef,
hostname => 'localhost',
ip => undef,
lock_structs => undef,
lock_wait_time => undef,
mysql_tables_locked => undef,
mysql_tables_used => undef,
mysql_thread_id => '3',
os_thread_id => '140284242860368',
proc_no => '4257',
query_id => '11',
query_status => undef,
query_text => 'show innodb status',
read_view_lower_limit => undef,
read_view_upper_limit => undef,
row_locks => undef,
thread_status => undef,
tickets => undef,
txn_id => '0 0',
txn_query_status => undef,
txn_status => 'not started',
undo_log_entries => undef,
user => 'msandbox'
}
]
},
'Basic InnoDB status'
);
# #############################################################################
# Done.
# #############################################################################
exit;

View File

@@ -1,637 +0,0 @@
#!/usr/bin/perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 26;
use PerconaTest;
use QueryParser;
use SQLParser;
use TableUsage;
use Data::Dumper;
$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Quotekeys = 0;
my $qp = new QueryParser();
my $sp = new SQLParser();
my $ta = new TableUsage(QueryParser => $qp, SQLParser => $sp);
isa_ok($ta, 'TableUsage');
sub test_get_table_usage {
my ( $query, $cats, $desc ) = @_;
my $got = $ta->get_table_usage(query=>$query);
is_deeply(
$got,
$cats,
$desc,
) or print Dumper($got);
return;
}
# ############################################################################
# Queries parsable by SQLParser: SELECT, INSERT, UPDATE and DELETE
# ############################################################################
test_get_table_usage(
"SELECT * FROM d.t WHERE id>100",
[
[
{ context => 'SELECT',
table => 'd.t',
},
{ context => 'WHERE',
table => 'd.t',
},
],
],
"SELECT FROM one table"
);
test_get_table_usage(
"SELECT t1.* FROM d.t1 LEFT JOIN d.t2 USING (id) WHERE d.t2.foo IS NULL",
[
[
{ context => 'SELECT',
table => 'd.t1',
},
{ context => 'JOIN',
table => 'd.t1',
},
{ context => 'JOIN',
table => 'd.t2',
},
{ context => 'WHERE',
table => 'd.t2',
},
],
],
"SELECT JOIN two tables"
);
test_get_table_usage(
"DELETE FROM d.t WHERE type != 'D' OR type IS NULL",
[
[
{ context => 'DELETE',
table => 'd.t',
},
{ context => 'WHERE',
table => 'd.t',
},
],
],
"DELETE one table"
);
test_get_table_usage(
"INSERT INTO d.t (col1, col2) VALUES ('a', 'b')",
[
[
{ context => 'INSERT',
table => 'd.t',
},
{ context => 'SELECT',
table => 'DUAL',
},
],
],
"INSERT VALUES, no SELECT"
);
test_get_table_usage(
"INSERT INTO d.t SET col1='a', col2='b'",
[
[
{ context => 'INSERT',
table => 'd.t',
},
{ context => 'SELECT',
table => 'DUAL',
},
],
],
"INSERT SET, no SELECT"
);
test_get_table_usage(
"UPDATE d.t SET foo='bar' WHERE foo IS NULL",
[
[
{ context => 'UPDATE',
table => 'd.t',
},
{ context => 'SELECT',
table => 'DUAL',
},
{ context => 'WHERE',
table => 'd.t',
},
],
],
"UPDATE one table"
);
test_get_table_usage(
"SELECT * FROM zn.edp
INNER JOIN zn.edp_input_key edpik ON edp.id = edpik.id
INNER JOIN `zn`.`key` input_key ON edpik.input_key = input_key.id
WHERE edp.id = 296",
[
[
{ context => 'SELECT',
table => 'zn.edp',
},
{ context => 'SELECT',
table => 'zn.edp_input_key',
},
{ context => 'SELECT',
table => 'zn.key',
},
{ context => 'JOIN',
table => 'zn.edp',
},
{ context => 'JOIN',
table => 'zn.edp_input_key',
},
{ context => 'JOIN',
table => 'zn.key',
},
{ context => 'WHERE',
table => 'zn.edp',
},
],
],
"SELECT with 2 JOIN and WHERE"
);
test_get_table_usage(
"REPLACE INTO db.tblA (dt, ncpc)
SELECT dates.dt, scraped.total_r
FROM tblB AS dates
LEFT JOIN dbF.tblC AS scraped
ON dates.dt = scraped.dt AND dates.version = scraped.version",
[
[
{ context => 'REPLACE',
table => 'db.tblA',
},
{ context => 'SELECT',
table => 'tblB',
},
{ context => 'SELECT',
table => 'dbF.tblC',
},
{ context => 'JOIN',
table => 'tblB',
},
{ context => 'JOIN',
table => 'dbF.tblC',
},
],
],
"REPLACE SELECT JOIN"
);
test_get_table_usage(
'UPDATE t1 AS a JOIN t2 AS b USING (id) SET a.foo="bar" WHERE b.foo IS NOT NULL',
[
[
{ context => 'UPDATE',
table => 't1',
},
{ context => 'SELECT',
table => 'DUAL',
},
{ context => 'JOIN',
table => 't1',
},
{ context => 'JOIN',
table => 't2',
},
{ context => 'WHERE',
table => 't2',
},
],
],
"UPDATE joins 2 tables, writes to 1, filters by 1"
);
test_get_table_usage(
'UPDATE t1 INNER JOIN t2 USING (id) SET t1.foo="bar" WHERE t1.id>100 AND t2.id>200',
[
[
{ context => 'UPDATE',
table => 't1',
},
{ context => 'SELECT',
table => 'DUAL',
},
{ context => 'JOIN',
table => 't1',
},
{ context => 'JOIN',
table => 't2',
},
{ context => 'WHERE',
table => 't1',
},
{ context => 'WHERE',
table => 't2',
},
],
],
"UPDATE joins 2 tables, writes to 1, filters by 2"
);
test_get_table_usage(
'UPDATE t1 AS a JOIN t2 AS b USING (id) SET a.foo="bar", b.foo="bat" WHERE a.id=1',
[
[
{ context => 'UPDATE',
table => 't1',
},
{ context => 'SELECT',
table => 'DUAL',
},
{ context => 'JOIN',
table => 't1',
},
{ context => 'JOIN',
table => 't2',
},
{ context => 'WHERE',
table => 't1',
},
],
[
{ context => 'UPDATE',
table => 't2',
},
{ context => 'SELECT',
table => 'DUAL',
},
{ context => 'JOIN',
table => 't1',
},
{ context => 'JOIN',
table => 't2',
},
{ context => 'WHERE',
table => 't1',
},
],
],
"UPDATE joins 2 tables, writes to 2, filters by 1"
);
test_get_table_usage(
'insert into t1 (a, b, c) select x, y, z from t2 where x is not null',
[
[
{ context => 'INSERT',
table => 't1',
},
{ context => 'SELECT',
table => 't2',
},
{ context => 'WHERE',
table => 't2',
},
],
],
"INSERT INTO t1 SELECT FROM t2",
);
test_get_table_usage(
'insert into t (a, b, c) select a.x, a.y, b.z from a, b where a.id=b.id',
[
[
{ context => 'INSERT',
table => 't',
},
{ context => 'SELECT',
table => 'a',
},
{ context => 'SELECT',
table => 'b',
},
{ context => 'JOIN',
table => 'a',
},
{ context => 'JOIN',
table => 'b',
},
],
],
"INSERT INTO t SELECT FROM a, b"
);
test_get_table_usage(
'INSERT INTO bar
SELECT edpik.*
FROM zn.edp
INNER JOIN zn.edp_input_key AS edpik ON edpik.id = edp.id
INNER JOIN `zn`.`key` input_key
INNER JOIN foo
WHERE edp.id = 296
AND edpik.input_key = input_key.id',
[
[
{ context => 'INSERT',
table => 'bar',
},
{ context => 'SELECT',
table => 'zn.edp_input_key',
},
{ context => 'JOIN',
table => 'zn.edp',
},
{ context => 'JOIN',
table => 'zn.edp_input_key',
},
{ context => 'JOIN',
table => 'zn.key',
},
{ context => 'TLIST',
table => 'foo',
},
{ context => 'WHERE',
table => 'zn.edp',
},
],
],
"INSERT SELECT with TLIST table"
);
test_get_table_usage(
"select country.country, city.city from city join country using (country_id) where country = 'Brazil' and city like 'A%' limit 1",
[
[
{ context => 'SELECT',
table => 'country',
},
{ context => 'SELECT',
table => 'city',
},
{ context => 'JOIN',
table => 'city',
},
{ context => 'JOIN',
table => 'country',
},
],
],
"Unresolvable tables in WHERE"
);
test_get_table_usage(
"select c from t where 1",
[
[
{ context => 'SELECT',
table => 't',
},
{ context => 'WHERE',
table => 'DUAL',
},
],
],
"WHERE <constant>"
);
test_get_table_usage(
"select c from t where 1=1",
[
[
{ context => 'SELECT',
table => 't',
},
{ context => 'WHERE',
table => 'DUAL',
},
],
],
"WHERE <constant>=<constant>"
);
test_get_table_usage(
"select now()",
[
[
{ context => 'SELECT',
table => 'DUAL',
},
],
],
"SELECT NOW()"
);
#test_get_table_usage(
# "SELECT
# automated_process.id id,
# class,
# automated_process_instance.server,
# IF(start IS NULL, 0, 1),
# owner
# FROM
# zn.automated_process_instance
# INNER JOIN zn.automated_process ON automated_process=automated_process.id
# WHERE
# automated_process_instance.id = 5251414",
# [
# [
# { context => 'SELECT',
# table => 'zn.automated_process',
# },
# { context => 'SELECT',
# table => 'zn.automated_process_instance',
# },
# { context => 'JOIN',
# table => 'zn.automated_process_instance',
# },
# { context => 'JOIN',
# table => 'zn.automated_process',
# },
# { context => 'WHERE',
# table => 'zn.automated_process_instance',
# },
# ]
# ],
# "SELECT explicit INNER JOIN with condition"
#);
# ############################################################################
# Queries parsable by QueryParser
# ############################################################################
test_get_table_usage(
"ALTER TABLE tt.ks ADD PRIMARY KEY(`d`,`v`)",
[
[
{ context => 'ALTER',
table => 'tt.ks',
},
],
],
"ALTER TABLE"
);
test_get_table_usage(
"DROP TABLE foo",
[
[
{ context => 'DROP_TABLE',
table => 'foo',
},
],
],
"DROP TABLE"
);
test_get_table_usage(
"DROP TABLE IF EXISTS foo",
[
[
{ context => 'DROP_TABLE',
table => 'foo',
},
],
],
"DROP TABLE IF EXISTS"
);
# #############################################################################
# Change DUAL to something else.
# #############################################################################
$ta = new TableUsage(
QueryParser => $qp,
SQLParser => $sp,
constant_data_value => '<const>',
);
test_get_table_usage(
"INSERT INTO d.t (col1, col2) VALUES ('a', 'b')",
[
[
{ context => 'INSERT',
table => 'd.t',
},
{ context => 'SELECT',
table => '<const>',
},
],
],
"Change constant_data_value"
);
# Restore original TableUsage obj for other tests.
$ta = new TableUsage(
QueryParser => $qp,
SQLParser => $sp,
);
# ############################################################################
# Use Schema instead of EXPLAIN EXTENDED.
# ############################################################################
use OptionParser;
use DSNParser;
use Quoter;
use TableParser;
use FileIterator;
use Schema;
use SchemaIterator;
my $o = new OptionParser(description => 'SchemaIterator');
$o->get_specs("$trunk/bin/pt-table-checksum");
my $q = new Quoter;
my $tp = new TableParser(Quoter => $q);
my $fi = new FileIterator();
my $file_itr = $fi->get_file_itr("$trunk/t/lib/samples/mysqldump-no-data/dump001.txt");
my $schema = new Schema();
my $schema_itr = new SchemaIterator(
file_itr => $file_itr,
OptionParser => $o,
Quoter => $q,
TableParser => $tp,
keep_ddl => 1,
Schema => $schema,
);
# Init schema.
1 while ($schema_itr->next_schema_object());
# Before, this is as correct as we can determine. The WHERE access is missing
# because c3 is not qualified and there's multiple tables, so the code can't
# figure out to which table it belongs.
test_get_table_usage(
"SELECT a.c1, c3 FROM a JOIN b ON a.c2=c3 WHERE NOW()<c3",
[
[
{ context => 'SELECT',
table => 'a',
},
{ context => 'JOIN',
table => 'a',
},
{ context => 'JOIN',
table => 'b',
},
],
],
"Tables without Schema"
);
# After, now we have a db for table b, but not for a because the schema
# we loaded has two table a (test.a and test2.a). The WHERE access is
# now present.
$sp->set_Schema($schema);
test_get_table_usage(
"SELECT a.c1, c3 FROM a JOIN b ON a.c2=c3 WHERE NOW()<c3",
[
[
{ context => 'SELECT',
table => 'a',
},
{ context => 'SELECT',
table => 'test.b',
},
{ context => 'JOIN',
table => 'a',
},
{ context => 'JOIN',
table => 'test.b',
},
{ context => 'WHERE',
table => 'test.b',
},
],
],
"Tables with Schema"
);
# Set it back for the next tests.
$sp->set_Schema(undef);
# #############################################################################
# Done.
# #############################################################################
my $output = '';
{
local *STDERR;
open STDERR, '>', \$output;
$ta->_d('Complete test coverage');
}
like(
$output,
qr/Complete test coverage/,
'_d() works'
);
exit;