#!perl
use Cassandane::Tiny;

sub test_fatals_abort_enabled
    :NoStartInstances
    ($self)
{
    $self->{instance}->{config}->set(
        'fatals_abort' => 'yes',
        'prometheus_enabled' => 'no',
    );
    $self->_start_instances();

    my $basedir = $self->{instance}->get_basedir();

    # run `promstatsd -1` without having set up for prometheus, which should
    # produce a "Prometheus metrics are not being tracked..." fatal error
    eval {
        $self->{instance}->run_command({ cyrus => 1 }, 'promstatsd', '-1');
    };
    my $e = $@;
    $self->assert_not_null($e);
    $self->assert_matches(qr{promstatsd pid \d+\) terminated by signal 6},
                          $e->{'-text'});

    my @cores = $self->{instance}->find_cores();
    if (@cores) {
        # if we dumped core, there'd better only be one core file
        $self->assert_num_equals(1, scalar @cores);

        # don't barf on it existing during shutdown
        unlink $cores[0];
    }
}
