Changeset 164
- Timestamp:
- 05/13/09 21:17:02 (6 months ago)
- Location:
- trunk
- Files:
-
- 20 modified
-
doc/schema-postgres.sql (modified) (1 diff)
-
t/api.t (modified) (1 diff)
-
t/cleanup.t (modified) (2 diffs)
-
t/coalesce.t (modified) (1 diff)
-
t/dead-dbs.t (modified) (1 diff)
-
t/empty-db.t (modified) (2 diffs)
-
t/evenly-distribute.t (modified) (2 diffs)
-
t/fail-working-multiple.t (modified) (1 diff)
-
t/funcid.t (modified) (1 diff)
-
t/grab_and_work_on.t (modified) (1 diff)
-
t/high-funcid-starvation.t (modified) (2 diffs)
-
t/insert-and-do.t (modified) (1 diff)
-
t/lib/db-common.pl (modified) (9 diffs)
-
t/priority.t (modified) (2 diffs)
-
t/replace-with.t (modified) (1 diff)
-
t/retry-delay.t (modified) (1 diff)
-
t/scoreboard.t (modified) (2 diffs)
-
t/server-time.t (modified) (1 diff)
-
t/unique.t (modified) (1 diff)
-
t/work-before-funcids-exist.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/schema-postgres.sql
r131 r164 32 32 grabbed_until INTEGER NOT NULL, 33 33 priority SMALLINT, 34 coalesce VARCHAR(255), 35 UNIQUE(funcid, uniqkey) 34 coalesce VARCHAR(255) 36 35 ); 36 37 CREATE UNIQUE INDEX job_funcid_uniqkey ON job (funcid, uniqkey); 37 38 38 39 CREATE INDEX job_funcid_runafter ON job (funcid, run_after); -
trunk/t/api.t
r161 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 108;10 use Test::More tests => 54*3; 11 11 12 12 run_tests(54, sub { -
trunk/t/cleanup.t
r114 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 20;9 use Test::More tests => 30; 10 10 11 11 # for testing: … … 15 15 run_tests(10, sub { 16 16 my $client = test_client(dbs => ['ts1']); 17 my $dbh = DBI->connect(dsn_for("ts1"), 'root', '');17 my $dbh = DBI->connect(dsn_for("ts1"), $ENV{TS_DB_USER}, $ENV{TS_DB_PASS}); 18 18 $client->can_do("Worker::Fail"); 19 19 $client->can_do("Worker::Complete"); -
trunk/t/coalesce.t
r84 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 28;9 use Test::More tests => 14 * 3; 10 10 11 11 run_tests(14, sub { -
trunk/t/dead-dbs.t
r36 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 4;10 use Test::More tests => 6; 11 11 12 12 run_tests(2, sub { -
trunk/t/empty-db.t
r36 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 6;10 use Test::More tests => 9; 11 11 12 12 run_tests(3, sub { … … 16 16 { 17 17 dsn => dsn_for('tempty1'), 18 user => "root",19 pass => "",18 user => $ENV{TS_DB_USER}, 19 pass => $ENV{TS_DB_PASS}, 20 20 }, 21 21 ]); -
trunk/t/evenly-distribute.t
r89 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 8;10 use Test::More tests => 12; 11 11 12 12 run_tests(4, sub { … … 19 19 } 20 20 21 my $db1 = DBI->connect(dsn_for("ts1"), 'root', '');22 my $db2 = DBI->connect(dsn_for("ts2"), 'root', '');21 my $db1 = DBI->connect(dsn_for("ts1"), $ENV{TS_DB_USER}, $ENV{TS_DB_PASS}); 22 my $db2 = DBI->connect(dsn_for("ts2"), $ENV{TS_DB_USER}, $ENV{TS_DB_PASS}); 23 23 die unless $db1 && $db2; 24 24 -
trunk/t/fail-working-multiple.t
r84 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 8;9 use Test::More tests => 12; 10 10 11 11 run_tests(4, sub { -
trunk/t/funcid.t
r42 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 16;10 use Test::More tests => 24; 11 11 12 12 run_tests(8, sub { -
trunk/t/grab_and_work_on.t
r141 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 18;9 use Test::More tests => 27; 10 10 11 11 run_tests(9, sub { -
trunk/t/high-funcid-starvation.t
r58 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 8;10 use Test::More tests => 12; 11 11 12 12 run_tests(4, sub { … … 19 19 } 20 20 21 my $db1 = DBI->connect(dsn_for("ts1"), 'root', '');21 my $db1 = DBI->connect(dsn_for("ts1"), $ENV{TS_DB_USER}, $ENV{TS_DB_PASS}); 22 22 die unless $db1; 23 23 -
trunk/t/insert-and-do.t
r103 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 52;9 use Test::More tests => 26*3; 10 10 11 11 run_tests(26, sub { -
trunk/t/lib/db-common.pl
r160 r164 9 9 10 10 run_tests_mysql($n, $code); 11 run_tests_pgsql($n, $code); 11 12 run_tests_sqlite($n, $code); 12 13 } … … 21 22 SKIP: { 22 23 local $ENV{USE_MYSQL} = 1; 24 local $ENV{TS_DB_USER} ||= 'root'; 23 25 my $dbh = eval { mysql_dbh() }; 24 26 skip "MySQL not accessible as root on localhost", $n if $@; 25 27 skip "InnoDB not available on localhost's MySQL", $n if $innodb && ! has_innodb($dbh); 28 $code->(); 29 } 30 } 31 32 sub run_tests_pgsql { 33 my ($n, $code) = @_; 34 SKIP: { 35 local $ENV{USE_PGSQL} = 1; 36 local $ENV{TS_DB_USER} ||= 'postgres'; 37 my $dbh = eval { pgsql_dbh() }; 38 skip "PgSQL not accessible as root on localhost", $n if $@; 26 39 $code->(); 27 40 } … … 70 83 map { { 71 84 dsn => dsn_for($_), 72 user => "root",73 pass => "",85 user => $ENV{TS_DB_USER}, 86 pass => $ENV{TS_DB_PASS}, 74 87 prefix => $pfx, 75 88 } } @$dbs … … 92 105 sub schema_file { 93 106 return "doc/schema.sql" if $ENV{USE_MYSQL}; 107 return "doc/schema-postgres.sql" if $ENV{USE_PGSQL}; 94 108 return "t/schema-sqlite.sql"; 95 109 } … … 109 123 if ($ENV{USE_MYSQL}) { 110 124 return 'dbi:mysql:' . mysql_dbname($dbname); 125 } 126 elsif ($ENV{USE_PGSQL}) { 127 return 'dbi:Pg:dbname=' . mysql_dbname($dbname); 111 128 } else { 112 129 return 'dbi:SQLite:dbname=' . db_filename($dbname); … … 130 147 create_mysql_db(mysql_dbname($dbname)); 131 148 } 149 elsif ($ENV{USE_PGSQL}) { 150 create_pgsql_db(mysql_dbname($dbname)); 151 } 132 152 my $dbh = DBI->connect(dsn_for($dbname), 133 'root', '', { RaiseError => 1, PrintError => 0 })153 $ENV{TS_DB_USER}, $ENV{TS_DB_PASS}, { RaiseError => 1, PrintError => 0 }) 134 154 or die "Couldn't connect: $!\n"; 135 155 my @sql = load_sql($schema); 136 156 for my $sql (@sql) { 137 $sql =~ s!^\s*create\s+table\s+(\w+)!CREATE TABLE ${pfx}$1!i; 157 $sql =~ s!^\s*create\s+table\s+(\w+)!CREATE TABLE ${pfx}$1!mi; 158 $sql =~ s!^\s*(create.*?index)\s+(\w+)\s+on\s+(\w+)!$1 $2 ON ${pfx}$3!i; 138 159 $sql .= " ENGINE=INNODB\n" if $ENV{USE_MYSQL}; 139 160 $dbh->do($sql); … … 148 169 } 149 170 171 my $pg_dbh; 172 173 sub pgsql_dbh { 174 return $pg_dbh if $pg_dbh; 175 $pg_dbh ||= 176 DBI->connect("DBI:Pg:dbname=postgres", "postgres", "", { RaiseError => 1 }) 177 or die "Couldn't connect to database"; 178 } 179 150 180 sub create_mysql_db { 151 181 my $dbname = shift; … … 156 186 my $dbname = shift; 157 187 mysql_dbh()->do("DROP DATABASE IF EXISTS $dbname"); 188 } 189 190 sub create_pgsql_db { 191 my $dbname = shift; 192 pgsql_dbh()->do("CREATE DATABASE $dbname"); 193 } 194 195 sub drop_pgsql_db { 196 my $dbname = shift; 197 undef $pg_dbh; 198 eval { pgsql_dbh()->do("DROP DATABASE IF EXISTS $dbname") }; 158 199 } 159 200 … … 163 204 if ($ENV{USE_MYSQL}) { 164 205 drop_mysql_db(mysql_dbname($db)); 206 } elsif ($ENV{USE_PGSQL}) { 207 drop_pgsql_db(mysql_dbname($db)); 165 208 } else { 166 209 my $file = db_filename($db); -
trunk/t/priority.t
r136 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 62;9 use Test::More tests => 31*3; 10 10 11 11 our $record_expected; … … 58 58 my ($class, $job) = @_; 59 59 my $priority = $job->priority; 60 60 61 ok((!defined($main::record_expected) && (!defined($priority))) 61 62 || ($priority == $main::record_expected), "priority matches expected priority"); -
trunk/t/replace-with.t
r84 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 20;9 use Test::More tests => 30; 10 10 11 11 run_tests(10, sub { -
trunk/t/retry-delay.t
r36 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 16;10 use Test::More tests => 24; 11 11 12 12 run_tests(8, sub { -
trunk/t/scoreboard.t
r160 r164 6 6 require 't/lib/db-common.pl'; 7 7 8 use Test::More tests => 20;8 use Test::More tests => 30; 9 9 10 10 use TheSchwartz; … … 26 26 map { { 27 27 dsn => dsn_for($_), 28 user => "root",29 pass => "",28 user => $ENV{TS_DB_USER}, 29 pass => $ENV{TS_DB_PASS}, 30 30 prefix => $pfx, 31 31 } } @$dbs -
trunk/t/server-time.t
r161 r164 7 7 8 8 use TheSchwartz; 9 use Test::More tests => 4;9 use Test::More tests => 6; 10 10 11 11 run_tests(2, sub { -
trunk/t/unique.t
r64 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 1 2;10 use Test::More tests => 18; 11 11 12 12 #use Data::ObjectDriver; -
trunk/t/work-before-funcids-exist.t
r43 r164 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 4;10 use Test::More tests => 6; 11 11 12 12 run_tests(2, sub {
