Skip to content

Instantly share code, notes, and snippets.

@bfaist
Last active June 10, 2016 13:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bfaist/7e68d5a2fdd04e2f6a509bf40b311f50 to your computer and use it in GitHub Desktop.
$perl t/pg_list_jobs.t
NOTICE: drop cascades to 6 other objects
DETAIL: drop cascades to table minion_test.mojo_migrations
drop cascades to table minion_test.minion_jobs
drop cascades to table minion_test.minion_workers
drop cascades to type minion_test.minion_state
drop cascades to table minion_test.minion_jobs column state
drop cascades to function minion_test.minion_jobs_notify_workers()
DBI connect('dbname=sam2_dev;host=bmipgsqld1.chmcres.cchmc.org;port=5432','srv_sam_dev',...) failed: FATAL: remaining connection slots are reserved for non-replication superuser connections at /usr/local/share/perl5/Mojo/Pg.pm line 80
use Mojo::Base -strict;
BEGIN { $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll' }
use Test::More;
plan skip_all => 'set TEST_ONLINE to enable this test' unless $ENV{TEST_ONLINE};
use Minion;
use Mojo::IOLoop;
use Sys::Hostname 'hostname';
use Time::HiRes qw(time usleep);
# Isolate tests
require Mojo::Pg;
my $pg = Mojo::Pg->new($ENV{TEST_ONLINE});
$pg->db->query('drop schema if exists minion_test cascade');
$pg->db->query('create schema minion_test');
my $minion = Minion->new(Pg => $ENV{TEST_ONLINE});
$minion->backend->pg->search_path(['minion_test']);
$minion->add_task(
add => sub {
my ($job, $first, $second) = @_;
$job->finish({added => $first + $second});
}
);
# List jobs
my $max_conn = $minion->backend->pg->db->query('show max_connections')->hash->{max_connections};
for(1 .. $max_conn+1) { $minion->enqueue(add => [3,3]) }
my $batch = $minion->backend->list_jobs(0, $max_conn+1);
# Clean up once we are done
$pg->db->query('drop schema minion_test cascade');
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment