fix and regression test for RT #62642
[dbsrgits/DBIx-Class.git] / t / 55storage_stress.t
CommitLineData
fd1182b6 1use strict;
2use warnings;
3use Test::More;
4
5# XXX obviously, the guts of this test haven't been written yet --blblack
6
7use lib qw(t/lib);
8
9plan skip_all => 'Set $ENV{DBICTEST_STORAGE_STRESS} to run this test'
10 . ' (it is very resource intensive!)'
11 unless $ENV{DBICTEST_STORAGE_STRESS};
12
13my $NKIDS = 20;
14my $CYCLES = 5;
15my @KILL_RATES = qw/0 0.001 0.01 0.1 0.2 0.5 0.75 1.0/;
16
17# Stress the storage with these parameters...
18sub stress_storage {
19 my ($connect_info, $num_kids, $cycles, $kill_rate) = @_;
20
21 foreach my $cycle (1..$cycles) {
22 my $schema = DBICTest::Schema->connection(@$connect_info, { AutoCommit => 1 });
23 foreach my $kidno (1..$num_kids) {
24 ok(1);
25 }
26 }
27}
28
29# Get a set of connection information -
30# whatever the user has supplied for the vendor-specific tests
31sub get_connect_infos {
32 my @connect_infos;
33 foreach my $db_prefix (qw/PG MYSQL DB2 MSSQL ORA/) {
34 my @conn_info = @ENV{
35 map { "DBICTEST_${db_prefix}_${_}" } qw/DSN USER PASS/
36 };
37 push(@connect_infos, \@conn_info) if $conn_info[0];
38 }
39 \@connect_infos;
40}
41
42my $connect_infos = get_connect_infos();
43
44plan skip_all => 'This test needs some non-sqlite connect info!'
45 unless @$connect_infos;
46
47plan tests => (1 * @$connect_infos * $NKIDS * $CYCLES * @KILL_RATES) + 1;
48
49use_ok('DBICTest::Schema');
50
51foreach my $connect_info (@$connect_infos) {
52 foreach my $kill_rate (@KILL_RATES) {
53 stress_storage($connect_info, $NKIDS, $CYCLES, $kill_rate);
54 }
55}