2016-06-24 14:12:58 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# DefineTest.pm - Defines all tests that can be run
|
|
|
|
####################################################################################################################################
|
|
|
|
package pgBackRestTest::Common::DefineTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw();
|
|
|
|
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
# Test definition constants
|
|
|
|
################################################################################################################################
|
|
|
|
use constant TESTDEF_MODULE => 'module';
|
|
|
|
push @EXPORT, qw(TESTDEF_MODULE);
|
|
|
|
use constant TESTDEF_MODULE_NAME => 'name';
|
|
|
|
push @EXPORT, qw(TESTDEF_MODULE_NAME);
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
use constant TESTDEF_EXPECT => 'expect';
|
|
|
|
push @EXPORT, qw(TESTDEF_EXPECT);
|
2016-06-24 14:12:58 +02:00
|
|
|
use constant TESTDEF_TEST => 'test';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST);
|
2017-01-10 03:49:04 +02:00
|
|
|
use constant TESTDEF_TEST_ALL => 'all';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_ALL);
|
|
|
|
use constant TESTDEF_TEST_COVERAGE => 'coverage';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_COVERAGE);
|
2016-12-23 15:22:59 +02:00
|
|
|
use constant TESTDEF_TEST_INDIVIDUAL => 'individual';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_INDIVIDUAL);
|
2016-06-24 14:12:58 +02:00
|
|
|
use constant TESTDEF_TEST_NAME => 'name';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_NAME);
|
|
|
|
use constant TESTDEF_TEST_TOTAL => 'total';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_TOTAL);
|
|
|
|
use constant TESTDEF_TEST_CONTAINER => 'container';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_CONTAINER);
|
2016-09-06 15:35:02 +02:00
|
|
|
use constant TESTDEF_TEST_PROCESS => 'process';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_PROCESS);
|
2016-06-24 14:12:58 +02:00
|
|
|
use constant TESTDEF_TEST_DB => 'db';
|
|
|
|
push @EXPORT, qw(TESTDEF_TEST_DB);
|
|
|
|
|
2017-01-10 03:49:04 +02:00
|
|
|
use constant TESTDEF_COVERAGE_FULL => true;
|
|
|
|
push @EXPORT, qw(TESTDEF_COVERAGE_FULL);
|
|
|
|
use constant TESTDEF_COVERAGE_PARTIAL => false;
|
|
|
|
push @EXPORT, qw(TESTDEF_COVERAGE_PARTIAL);
|
|
|
|
|
|
|
|
use constant TESTDEF_MODULE_FILE => 'File';
|
|
|
|
push @EXPORT, qw(TESTDEF_MODULE_FILE);
|
|
|
|
use constant TESTDEF_MODULE_FILE_COMMON => TESTDEF_MODULE_FILE . 'Common';
|
|
|
|
push @EXPORT, qw(TESTDEF_MODULE_FILE_COMMON);
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Define tests
|
|
|
|
################################################################################################################################
|
|
|
|
my $oTestDef =
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE =>
|
|
|
|
[
|
|
|
|
# Help tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'help',
|
|
|
|
&TESTDEF_TEST_CONTAINER => true,
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_EXPECT => true,
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'help',
|
|
|
|
&TESTDEF_TEST_TOTAL => 1,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
# Config tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'config',
|
|
|
|
&TESTDEF_TEST_CONTAINER => true,
|
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'option',
|
|
|
|
&TESTDEF_TEST_TOTAL => 34,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'config',
|
|
|
|
&TESTDEF_TEST_TOTAL => 25,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
# File tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'file',
|
|
|
|
&TESTDEF_TEST_CONTAINER => true,
|
|
|
|
|
2017-01-10 03:49:04 +02:00
|
|
|
&TESTDEF_TEST_COVERAGE =>
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_FILE => TESTDEF_COVERAGE_FULL,
|
|
|
|
&TESTDEF_MODULE_FILE_COMMON => TESTDEF_COVERAGE_FULL,
|
|
|
|
},
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
2016-12-23 15:30:34 +02:00
|
|
|
{
|
|
|
|
&TESTDEF_TEST_NAME => 'unit',
|
|
|
|
&TESTDEF_TEST_TOTAL => 1,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
|
|
|
},
|
2017-01-05 22:19:56 +02:00
|
|
|
{
|
|
|
|
&TESTDEF_TEST_NAME => 'owner',
|
|
|
|
&TESTDEF_TEST_TOTAL => 8,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
|
|
|
},
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'path-create',
|
|
|
|
&TESTDEF_TEST_TOTAL => 8,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'move',
|
|
|
|
&TESTDEF_TEST_TOTAL => 24,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'compress',
|
|
|
|
&TESTDEF_TEST_TOTAL => 4,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'wait',
|
|
|
|
&TESTDEF_TEST_TOTAL => 2,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'manifest',
|
|
|
|
&TESTDEF_TEST_TOTAL => 8,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'list',
|
|
|
|
&TESTDEF_TEST_TOTAL => 72,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'remove',
|
|
|
|
&TESTDEF_TEST_TOTAL => 32,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'hash',
|
|
|
|
&TESTDEF_TEST_TOTAL => 16,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'exists',
|
|
|
|
&TESTDEF_TEST_TOTAL => 6,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'copy',
|
|
|
|
&TESTDEF_TEST_TOTAL => 144,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2017-01-05 01:31:16 +02:00
|
|
|
# Stanza tests
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_MODULE_NAME => 'stanza',
|
2016-06-24 14:12:58 +02:00
|
|
|
&TESTDEF_TEST_CONTAINER => false,
|
2016-12-23 15:22:59 +02:00
|
|
|
&TESTDEF_EXPECT => true,
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
2016-12-23 18:43:26 +02:00
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'create',
|
|
|
|
&TESTDEF_TEST_TOTAL => 2
|
2016-12-23 18:43:26 +02:00
|
|
|
},
|
2017-01-05 01:31:16 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
# Archive tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'archive',
|
|
|
|
&TESTDEF_TEST_CONTAINER => false,
|
|
|
|
&TESTDEF_EXPECT => true,
|
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
2017-01-05 01:39:50 +02:00
|
|
|
{
|
|
|
|
&TESTDEF_TEST_NAME => 'unit',
|
|
|
|
&TESTDEF_TEST_TOTAL => 1,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
|
|
|
&TESTDEF_EXPECT => false,
|
|
|
|
},
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'push',
|
2016-06-24 14:12:58 +02:00
|
|
|
&TESTDEF_TEST_TOTAL => 8
|
|
|
|
},
|
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'stop',
|
2016-06-24 14:12:58 +02:00
|
|
|
&TESTDEF_TEST_TOTAL => 6
|
|
|
|
},
|
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'get',
|
2016-06-24 14:12:58 +02:00
|
|
|
&TESTDEF_TEST_TOTAL => 8
|
|
|
|
},
|
2017-01-05 01:31:16 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
# Backup tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'backup',
|
|
|
|
&TESTDEF_TEST_CONTAINER => false,
|
|
|
|
&TESTDEF_EXPECT => false,
|
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'unit',
|
|
|
|
&TESTDEF_TEST_TOTAL => 1,
|
|
|
|
&TESTDEF_TEST_INDIVIDUAL => false,
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
2017-01-05 01:31:16 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
# Expire tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'expire',
|
|
|
|
&TESTDEF_TEST_CONTAINER => false,
|
|
|
|
&TESTDEF_EXPECT => true,
|
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
2016-12-20 23:52:20 +02:00
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'expire',
|
|
|
|
&TESTDEF_TEST_TOTAL => 1
|
2016-12-20 23:52:20 +02:00
|
|
|
},
|
2017-01-05 01:31:16 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
# Full tests
|
|
|
|
{
|
|
|
|
&TESTDEF_MODULE_NAME => 'full',
|
|
|
|
&TESTDEF_TEST_CONTAINER => false,
|
|
|
|
&TESTDEF_EXPECT => true,
|
|
|
|
|
|
|
|
&TESTDEF_TEST =>
|
|
|
|
[
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
|
|
|
&TESTDEF_TEST_NAME => 'synthetic',
|
|
|
|
&TESTDEF_TEST_TOTAL => 8,
|
2016-09-06 15:35:02 +02:00
|
|
|
&TESTDEF_TEST_PROCESS => true
|
2016-06-24 14:12:58 +02:00
|
|
|
},
|
|
|
|
{
|
2017-01-05 01:31:16 +02:00
|
|
|
&TESTDEF_TEST_NAME => 'real',
|
2016-08-24 18:39:27 +02:00
|
|
|
&TESTDEF_TEST_TOTAL => 11,
|
2016-09-06 15:35:02 +02:00
|
|
|
&TESTDEF_TEST_PROCESS => true,
|
2016-06-24 14:12:58 +02:00
|
|
|
&TESTDEF_TEST_DB => true
|
|
|
|
}
|
|
|
|
]
|
2017-01-05 01:31:16 +02:00
|
|
|
},
|
2016-06-24 14:12:58 +02:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# testDefGet
|
|
|
|
####################################################################################################################################
|
|
|
|
sub testDefGet
|
|
|
|
{
|
|
|
|
return $oTestDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(testDefGet);
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# testDefModuleGet
|
|
|
|
####################################################################################################################################
|
|
|
|
sub testDefModuleGet
|
|
|
|
{
|
|
|
|
my $strModule = shift;
|
|
|
|
|
|
|
|
# Find the module
|
|
|
|
foreach my $hModule (@{$oTestDef->{&TESTDEF_MODULE}})
|
|
|
|
{
|
|
|
|
if ($hModule->{&TESTDEF_MODULE_NAME} eq $strModule)
|
|
|
|
{
|
|
|
|
return $hModule;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
confess &log(ASSERT, "unable to find module ${strModule}");
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(testDefModuleGet);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# testDefModuleTestGet
|
|
|
|
####################################################################################################################################
|
|
|
|
sub testDefModuleTestGet
|
|
|
|
{
|
|
|
|
my $hModule = shift;
|
|
|
|
my $strModuleTest = shift;
|
|
|
|
|
|
|
|
foreach my $hModuleTest (@{$hModule->{&TESTDEF_TEST}})
|
|
|
|
{
|
|
|
|
if ($hModuleTest->{&TESTDEF_TEST_NAME} eq $strModuleTest)
|
|
|
|
{
|
|
|
|
return $hModuleTest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
confess &log(ASSERT, "unable to find module test ${strModuleTest}");
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(testDefModuleTestGet);
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
1;
|