line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Grid::Request::Test; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Grid::Request::Test - Helper funcations for unit Grid::Request tests. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Grid::Request::Test; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $req = Grid::Request:Test->get_test_request(); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $project = Grid::Request:Test->get_test_project(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $hostname = Grid::Request:Test->get_test_host(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
A module that models Grid::Request parameters. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=over 4 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=item get_test_request(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
B This method is used by tests to obtain a test request |
26
|
|
|
|
|
|
|
object. If the user has the GRID_REQUEST_TEST_PROJECT enviroment variable |
27
|
|
|
|
|
|
|
defined, for environments in which a project settings is required, then |
28
|
|
|
|
|
|
|
the returned object will have the project configured so that tests will |
29
|
|
|
|
|
|
|
run. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
B None. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
B A Grid::Request object. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
23177
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
107
|
|
38
|
1
|
|
|
1
|
|
667
|
use Grid::Request; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Test::More; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $GR_PROJECT_NAME = "GRID_REQUEST_TEST_PROJECT"; |
42
|
|
|
|
|
|
|
our $GR_HOST_NAME = "GRID_REQUEST_TEST_HOST"; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_test_request { |
48
|
|
|
|
|
|
|
my $req; |
49
|
|
|
|
|
|
|
my $project = get_test_project(); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if (defined $project && length $project) { |
52
|
|
|
|
|
|
|
$req = Grid::Request->new(project => $project); |
53
|
|
|
|
|
|
|
} else { |
54
|
|
|
|
|
|
|
$req = Grid::Request->new(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
return $req; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item get_test_project(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
B Retrieves the project to use when running the |
62
|
|
|
|
|
|
|
Grid::Request unit tests. Many of the unit tests trigger actual |
63
|
|
|
|
|
|
|
grid jobs, so the user/tester must be able to specify which project |
64
|
|
|
|
|
|
|
string to use. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
B None. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
B A scalar. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_test_project { |
73
|
|
|
|
|
|
|
if (exists $ENV{$GR_PROJECT_NAME} && defined $ENV{$GR_PROJECT_NAME} && |
74
|
|
|
|
|
|
|
length($ENV{$GR_PROJECT_NAME})) { |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Return the value. |
77
|
|
|
|
|
|
|
return $ENV{$GR_PROJECT_NAME}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item get_test_host(); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
B Retrieves the host to use to help test the |
85
|
|
|
|
|
|
|
hosts() method in Grid::Request. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
B None. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
B A scalar. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub get_test_host { |
94
|
|
|
|
|
|
|
if (exists $ENV{$GR_HOST_NAME} && |
95
|
|
|
|
|
|
|
defined $ENV{$GR_HOST_NAME} && |
96
|
|
|
|
|
|
|
length($ENV{$GR_HOST_NAME})) { |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Return the value. |
99
|
|
|
|
|
|
|
# TODO: Validation. |
100
|
|
|
|
|
|
|
return $ENV{$GR_HOST_NAME}; |
101
|
|
|
|
|
|
|
} else { |
102
|
|
|
|
|
|
|
warn "Please define the \"$GR_HOST_NAME\" environment variable.\n"; |
103
|
|
|
|
|
|
|
croak; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub diagnose { |
108
|
|
|
|
|
|
|
my $e; |
109
|
|
|
|
|
|
|
if ( $e = Exception::Class->caught('Grid::Request::DRMAAException') ) { |
110
|
|
|
|
|
|
|
diag($e->diagnosis()); |
111
|
|
|
|
|
|
|
} elsif ( $e = Exception::Class->caught('Grid::Request::Exception') ) { |
112
|
|
|
|
|
|
|
diag($e->error()); |
113
|
|
|
|
|
|
|
} else { |
114
|
|
|
|
|
|
|
$e = Exception::Class->caught(); |
115
|
|
|
|
|
|
|
diag($e); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |