DBIx-QuickORM

 view release on metacpan or  search on metacpan

t/AI/fork_sth_guards.t  view on Meta::CPAN

        frames => [{result => 1}, {row => {id => 1}}, {done => 1}],
        extra  => {owner_pid => $$ + 1},
    );

    ok(!$sth->in_owner_process, "handle reports it is not in the owning process");

    like(dies { $sth->ready },  qr/different process than the one that created it/, "ready croaks in a non-owner process");
    like(dies { $sth->result }, qr/different process than the one that created it/, "result croaks in a non-owner process");
    like(dies { $sth->next },   qr/different process than the one that created it/, "next croaks in a non-owner process");

    # The guard blocked all reads, so nothing reaped the child. Do it here.
    waitpid($pid, 0);
};

subtest forked_write_child_error_does_not_throw_from_destructor => sub {
    # A forked write sets on_finish, which makes cancel_on_destroy false: the
    # destructor must run the child to completion rather than cancel it. When
    # the child errored, draining must warn, not croak out of DESTROY.
    my $on_finish_ran = 0;

    my ($sth) = fork_handle(

t/AI/transaction_extra.t  view on Meta::CPAN

        my $inner;
        { my $outer = $con->txn; $inner = $con->txn; }    # parent (root) destroyed first
        undef $inner;                                     # then the orphaned child
    }

    ok(!$con->in_txn, "no transaction is left open after out-of-order destruction");
    is(scalar(grep { defined } @{$con->transactions}), 0, "the transaction stack is empty");

    ok(lives { $con->txn(sub { $h->insert({name => 'after_wedge'}) }) }, "a later transaction still runs");
    ok(scalar(grep { $_ eq 'after_wedge' } @{disk_names()}), "and its work actually persists to disk");
    ok(lives { $con->reconnect }, "reconnect is not blocked by a phantom active transaction");
};

$probe->disconnect;

done_testing;

t/aside.t  view on Meta::CPAN

    my $startC = Time::HiRes::time();
    my $readyC;
    until($readyC = $asideC->ready) {
        sleep 0.1;
    }
    my $elapsedC = Time::HiRes::time() - $startC;

    # Both queries carry a server-side one-second sleep and run concurrently, so
    # the first wait must span about a second and the second, already in flight,
    # must resolve in no more time than the first did.
    ok($elapsed >= 0.9, "The first async query blocked for about a second (${elapsed}s)");
    ok($elapsedC <= $elapsed, "The second async result resolved no slower than the first (${elapsedC}s)");

    isa_ok($ready, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($ready, $row, "same ref");

    isa_ok($readyC, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($readyC, $row, "same ref");

    is(blessed($aside), 'DBIx::QuickORM::Row::Async', "Still async");
    my $copy = $aside->row;

t/forked.t  view on Meta::CPAN

    my $readyC;
    until($readyC = $forkedC->ready) {
        sleep 0.1;
    }
    my $elapsedC = Time::HiRes::time() - $startC;

    if ($sleep) {
        # Both forked queries carry a server-side one-second sleep and run in
        # separate child processes, so the first wait spans about a second and
        # the second, already in flight, resolves in no more time than the first.
        ok($elapsed >= 0.9, "The first forked query blocked for about a second (${elapsed}s)");
        ok($elapsedC <= $elapsed, "The second forked result resolved no slower than the first (${elapsedC}s)");
    }

    ok($forked->async->pid, "got a pid");

    isa_ok($ready, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($ready, $row, "same ref");

    isa_ok($readyC, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($readyC, $row, "same ref");

worktrees/audit-fixes-master/t/AI/fork_sth_guards.t  view on Meta::CPAN

        frames => [{result => 1}, {row => {id => 1}}, {done => 1}],
        extra  => {owner_pid => $$ + 1},
    );

    ok(!$sth->in_owner_process, "handle reports it is not in the owning process");

    like(dies { $sth->ready },  qr/different process than the one that created it/, "ready croaks in a non-owner process");
    like(dies { $sth->result }, qr/different process than the one that created it/, "result croaks in a non-owner process");
    like(dies { $sth->next },   qr/different process than the one that created it/, "next croaks in a non-owner process");

    # The guard blocked all reads, so nothing reaped the child. Do it here.
    waitpid($pid, 0);
};

subtest forked_write_child_error_does_not_throw_from_destructor => sub {
    # A forked write sets on_finish, which makes cancel_on_destroy false: the
    # destructor must run the child to completion rather than cancel it. When
    # the child errored, draining must warn, not croak out of DESTROY.
    my $on_finish_ran = 0;

    my ($sth) = fork_handle(

worktrees/audit-fixes-master/t/AI/transaction_extra.t  view on Meta::CPAN

        my $inner;
        { my $outer = $con->txn; $inner = $con->txn; }    # parent (root) destroyed first
        undef $inner;                                     # then the orphaned child
    }

    ok(!$con->in_txn, "no transaction is left open after out-of-order destruction");
    is(scalar(grep { defined } @{$con->transactions}), 0, "the transaction stack is empty");

    ok(lives { $con->txn(sub { $h->insert({name => 'after_wedge'}) }) }, "a later transaction still runs");
    ok(scalar(grep { $_ eq 'after_wedge' } @{disk_names()}), "and its work actually persists to disk");
    ok(lives { $con->reconnect }, "reconnect is not blocked by a phantom active transaction");
};

$probe->disconnect;

done_testing;

worktrees/audit-fixes-master/t/aside.t  view on Meta::CPAN

    my $startC = Time::HiRes::time();
    my $readyC;
    until($readyC = $asideC->ready) {
        sleep 0.1;
    }
    my $elapsedC = Time::HiRes::time() - $startC;

    # Both queries carry a server-side one-second sleep and run concurrently, so
    # the first wait must span about a second and the second, already in flight,
    # must resolve in no more time than the first did.
    ok($elapsed >= 0.9, "The first async query blocked for about a second (${elapsed}s)");
    ok($elapsedC <= $elapsed, "The second async result resolved no slower than the first (${elapsedC}s)");

    isa_ok($ready, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($ready, $row, "same ref");

    isa_ok($readyC, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($readyC, $row, "same ref");

    is(blessed($aside), 'DBIx::QuickORM::Row::Async', "Still async");
    my $copy = $aside->row;

worktrees/audit-fixes-master/t/forked.t  view on Meta::CPAN

    my $readyC;
    until($readyC = $forkedC->ready) {
        sleep 0.1;
    }
    my $elapsedC = Time::HiRes::time() - $startC;

    if ($sleep) {
        # Both forked queries carry a server-side one-second sleep and run in
        # separate child processes, so the first wait spans about a second and
        # the second, already in flight, resolves in no more time than the first.
        ok($elapsed >= 0.9, "The first forked query blocked for about a second (${elapsed}s)");
        ok($elapsedC <= $elapsed, "The second forked result resolved no slower than the first (${elapsedC}s)");
    }

    ok($forked->async->pid, "got a pid");

    isa_ok($ready, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($ready, $row, "same ref");

    isa_ok($readyC, ['DBIx::QuickORM::Row'], "Row was returned from ready()");
    ref_is($readyC, $row, "same ref");



( run in 0.961 second using v1.01-cache-2.11-cpan-b16cb0d3907 )