1####################################################################################################################################
2# Archive Performance Tests
3####################################################################################################################################
4package pgBackRestTest::Module::Performance::PerformanceArchivePerlTest;
5use parent 'pgBackRestTest::Common::RunTest';
6
7####################################################################################################################################
8# Perl includes
9####################################################################################################################################
10use strict;
11use warnings FATAL => qw(all);
12use Carp qw(confess);
13use English '-no_match_vars';
14
15use Storable qw(dclone);
16use Time::HiRes qw(gettimeofday);
17
18use pgBackRestDoc::Common::Log;
19
20use pgBackRestTest::Common::ExecuteTest;
21use pgBackRestTest::Common::RunTest;
22
23####################################################################################################################################
24# initModule
25####################################################################################################################################
26sub initModule
27{
28    my $self = shift;
29
30    $self->{strSpoolPath} = $self->testPath() . '/spool';
31}
32
33####################################################################################################################################
34# initTest
35####################################################################################################################################
36sub initTest
37{
38    my $self = shift;
39
40    # Create spool path
41    storageTest()->pathCreate($self->{strSpoolPath}, {bIgnoreExists => true, bCreateParent => true});
42}
43
44####################################################################################################################################
45# run
46####################################################################################################################################
47sub run
48{
49    my $self = shift;
50
51    ################################################################################################################################
52    if ($self->begin("archive-push async (detect ok file)"))
53    {
54        #---------------------------------------------------------------------------------------------------------------------------
55        storageTest()->put(
56            storageTest()->openWrite(
57                'spool/archive/' . $self->stanza() . '/out/000000010000000100000001.ok', {bPathCreate => true}));
58
59        my $iRunTotal = 1;
60        my $lTimeBegin = gettimeofday();
61
62        for (my $iIndex = 0; $iIndex < $iRunTotal; $iIndex++)
63        {
64            executeTest(
65                $self->backrestExe() . ' --stanza=' . $self->stanza() . ' --archive-async --spool-path=' . $self->{strSpoolPath} .
66                ' --archive-timeout=1 archive-push /pg_xlog/000000010000000100000001');
67        }
68
69        &log(INFO, 'time per execution: ' . ((gettimeofday() - $lTimeBegin) / $iRunTotal));
70    }
71}
72
731;
74