From: Peter Rabbitson Date: Wed, 10 Jun 2015 14:18:01 +0000 (+0200) Subject: Make sure tests still pass in a fork-limited environment X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5e98e5a9dd098563003db50ef406370a34615af;p=dbsrgits%2FDBIx-Class-Historic.git Make sure tests still pass in a fork-limited environment Inspired by a temporarily stuck smoker http://www.cpantesters.org/cpan/report/751da1f2-e3ff-11e4-a1d1-8536eb4f9f07 Read under -w --- diff --git a/maint/travis-ci_scripts/40_script.bash b/maint/travis-ci_scripts/40_script.bash index 062f796..c329a93 100755 --- a/maint/travis-ci_scripts/40_script.bash +++ b/maint/travis-ci_scripts/40_script.bash @@ -7,6 +7,12 @@ if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then exit 0 ; fi run_harness_tests() { local -x HARNESS_OPTIONS=c:j$VCPU_USE + if [[ "$VCPU_USE" == 1 ]]; then + ulim=$(( ( $(ps xH | wc -l) - 3 ) + 4 )) # (real count excluding header + ps + wc) + space for ( make + tee + harness + ) + echo_err "$(tstamp) Setting process/thread limit to $ulim" + ulimit -u $ulim + sleep 10 # needed to settle things down a bit + fi make test 2> >(tee "$TEST_STDERR_LOG") } diff --git a/t/51threadnodb.t b/t/51threadnodb.t index 95c9aaf..dd1a501 100644 --- a/t/51threadnodb.t +++ b/t/51threadnodb.t @@ -15,6 +15,7 @@ use threads; use strict; use warnings; use Test::More; +use DBIx::Class::_Util 'sigwarn_silencer'; use lib qw(t/lib); use DBICTest; @@ -36,14 +37,27 @@ my $schema = DBICTest->init_schema(no_deploy => 1); isa_ok ($schema, 'DBICTest::Schema'); my @threads; -push @threads, threads->create(sub { - my $rsrc = $schema->source('Artist'); - undef $schema; - isa_ok ($rsrc->schema, 'DBICTest::Schema'); - my $s2 = $rsrc->schema->clone; - - sleep 1; # without this many tasty crashes -}) for (1.. $num_children); +SKIP: { + + local $SIG{__WARN__} = sigwarn_silencer( qr/Thread creation failed/i ); + + for (1.. $num_children) { + push @threads, threads->create(sub { + my $rsrc = $schema->source('Artist'); + undef $schema; + isa_ok ($rsrc->schema, 'DBICTest::Schema'); + my $s2 = $rsrc->schema->clone; + + sleep 1; # without this many tasty crashes + }) || do { + skip "EAGAIN encountered, your system is likely bogged down: skipping rest of test", 1 + if $! == Errno::EAGAIN(); + + die "Unable to start thread: $!"; + }; + } +} + ok(1, "past spawning"); $_->join for @threads; diff --git a/t/storage/txn.t b/t/storage/txn.t index 4c6d505..f8a729f 100644 --- a/t/storage/txn.t +++ b/t/storage/txn.t @@ -107,6 +107,7 @@ for my $want (0,1) { is ($schema->storage->transaction_depth, 0, 'Start outside txn'); my @pids; + SKIP: for my $action ( sub { my $s = shift; @@ -129,8 +130,13 @@ for my $want (0,1) { }, ) { my $pid = fork(); - die "Unable to fork: $!\n" - if ! defined $pid; + + if( ! defined $pid ) { + skip "EAGAIN encountered, your system is likely bogged down: skipping forking test", 1 + if $! == Errno::EAGAIN(); + + die "Unable to fork: $!" + } if ($pid) { push @pids, $pid; @@ -206,8 +212,13 @@ sub _test_forking_action { if $^O eq 'MSWin32'; my $pid = fork(); - die "Unable to fork: $!\n" - if ! defined $pid; + if( ! defined $pid ) { + + skip "EAGAIN encountered, your system is likely bogged down: skipping forking test", 1 + if $! == Errno::EAGAIN(); + + die "Unable to fork: $!" + } if ($pid) { push @pids, $pid;