File: 55storage_stress.t

package info (click to toggle)
libdbix-class-perl 0.08010-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,052 kB
  • ctags: 1,064
  • sloc: perl: 10,536; sql: 225; makefile: 45
file content (55 lines) | stat: -rwxr-xr-x 1,530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use strict;
use warnings;
use Test::More;

# XXX obviously, the guts of this test haven't been written yet --blblack

use lib qw(t/lib);

plan skip_all => 'Set $ENV{DBICTEST_STORAGE_STRESS} to run this test'
    . ' (it is very resource intensive!)'
        unless $ENV{DBICTEST_STORAGE_STRESS};

my $NKIDS = 20;
my $CYCLES = 5;
my @KILL_RATES = qw/0 0.001 0.01 0.1 0.2 0.5 0.75 1.0/;

# Stress the storage with these parameters...
sub stress_storage {
    my ($connect_info, $num_kids, $cycles, $kill_rate) = @_;

    foreach my $cycle (1..$cycles) {
        my $schema = DBICTest::Schema->connection(@$connect_info, { AutoCommit => 1 });
        foreach my $kidno (1..$num_kids) {
            ok(1);
        }
    }
}

# Get a set of connection information -
#  whatever the user has supplied for the vendor-specific tests
sub get_connect_infos {
    my @connect_infos;
    foreach my $db_prefix (qw/PG MYSQL DB2 MSSQL ORA/) {
        my @conn_info = @ENV{
            map { "DBICTEST_${db_prefix}_${_}" } qw/DSN USER PASS/
        };
        push(@connect_infos, \@conn_info) if $conn_info[0];
    }
    \@connect_infos;
}

my $connect_infos = get_connect_infos();

plan skip_all => 'This test needs some non-sqlite connect info!'
    unless @$connect_infos;

plan tests => (1 * @$connect_infos * $NKIDS * $CYCLES * @KILL_RATES) + 1;

use_ok('DBICTest::Schema');

foreach my $connect_info (@$connect_infos) {
    foreach my $kill_rate (@KILL_RATES) {
        stress_storage($connect_info, $NKIDS, $CYCLES, $kill_rate);
    }
}