Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4466 dpurdie 1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
3
#
4
# Module name   : test_cqconnection.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Test the connectivity to the ClearQuest Database
10
#
11
# Usage         : See POD
12
#
13
#......................................................................#
14
 
15
require 5.008_002;
16
use strict;
17
use warnings;
18
 
19
use JatsError;
20
 
21
use Pod::Usage;                             # required for help support
22
use Getopt::Long;
23
use JatsRmApi;
24
 
25
use DBI;
26
use Cwd;
27
 
28
#
29
#   Global data
30
#
31
my $VERSION      = "1.0.0";                 # Update this
32
my $opt_debug    = $ENV{'GBE_DEBUG'};        # Allow global debug
33
my $opt_verbose  = $ENV{'GBE_VERBOSE'};      # Allow global verbose
34
my $opt_help = 0;
35
 
36
#
37
#   Release Manager Connection Information
38
#   Deployment manager Connection information
39
#
40
my $CQ_URL = $ENV{GBE_CQ_URL};
41
my $CQ_DB;
42
 
43
#-------------------------------------------------------------------------------
44
# Function        : Mainline Entry Point
45
#
46
# Description     :
47
#
48
# Inputs          :
49
#
50
my $result = GetOptions (
51
                "help+"         => \$opt_help,              # flag, multiple use allowed
52
                "manual:3"      => \$opt_help,
53
                "verbose:+"     => \$opt_verbose,           # flag, multiple use allowed
54
                );
55
 
56
                #
57
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
58
                #
59
 
60
#
61
#   Process help and manual options
62
#
63
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
64
pod2usage(-verbose => 1) if ($opt_help == 2 );
65
pod2usage(-verbose => 2) if ($opt_help > 2);
66
 
67
#
68
#   Configure the error reporting process now that we have the user options
69
#
70
ErrorConfig( 'name'    =>'CQTEST',
71
             'verbose' => $opt_verbose,
72
            );
73
 
74
 
75
#
76
#   Open the connection and display some data
77
#
78
getClearQuestData();
79
Message "Test Complete\n";
80
exit;
81
 
82
 
83
#-------------------------------------------------------------------------------
84
# Function        : getClearQuestData
85
#
86
# Description     : Extract Info from the DEVI database
87
#
88
# Inputs          :
89
#
90
# Returns         :
91
#
92
sub getClearQuestData
93
{
94
    my $count = 0;
95
    my (@row);
96
 
97
    Message("Test ClearQuest Interface");
98
 
99
    #
100
    #   Connect to database
101
    #
102
    connectCQ(\$CQ_DB, $opt_verbose);
103
 
104
    Message("Extract data");
105
    my $m_sqlstr = "SELECT si.dbid AS iss_id, ".
106
                    "si.new_num AS iss_num,".
107
                    "si.headline AS summary, ".
108
                    "sd.NAME AS state , ".
109
                    "si.package_ref, ".
110
                    "si.project, ".
111
                    "si.product, ".
112
                    "sd.id, ".
113
                    "si.submit_date".
114
         " FROM CQ_DEVI.admin.software_issue si,".
115
         " CQ_DEVI.admin.STATEDEF sd".
116
         " WHERE si.STATE = sd.ID";
117
    my $sth = $CQ_DB->prepare($m_sqlstr);
118
    if ( defined($sth) )
119
    {
120
        if ( $sth->execute( ) )
121
        {
122
            if ( $sth->rows )
123
            {
124
                while ( @row = $sth->fetchrow_array )
125
                {
126
                    $count++;
127
                    if ( $opt_verbose > 1 )
128
                    {
129
                        printf join(',',@row) . "\n";
130
                    }
131
                }
132
            }
133
            $sth->finish();
134
        }
135
        else
136
        {
137
            Error("Execute failure" );
138
        }
139
    }
140
    else
141
    {
142
        Error("Prepare failure" );
143
    }
144
 
145
    #
146
    #   Report the data extracted
147
    #
148
    Error("No data extracted from the database") unless ( $count );
149
    Message "Extracted $count records\n";
150
 
151
    #
152
    #   Close down the connection
153
    #
154
    disconnectCQ(\$CQ_DB);
155
}
156
 
157
 
158
#-------------------------------------------------------------------------------
159
#   Documentation
160
#
161
 
162
=pod
163
 
164
=head1 NAME
165
 
166
test_cqconnection - Test the connection to the ClearQuest Database
167
 
168
=head1 SYNOPSIS
169
 
170
jats etool test_cqconnection [options]
171
 
172
 Options:
173
    -help              - Brief help message
174
    -help -help        - Detailed help message
175
    -man               - Full documentation
176
    -verbose           - Display additional information
177
 
178
=head1 OPTIONS
179
 
180
=over 8
181
 
182
=item B<-help>
183
 
184
Print a brief help message and exits.
185
 
186
=item B<-help -help>
187
 
188
Print a detailed help message with an explanation for each option.
189
 
190
=item B<-man>
191
 
192
Prints the manual page and exits.
193
 
194
=item B<-verbose>
195
 
196
Prints additional information on the progress of the program.
197
 
198
=back
199
 
200
=head1 DESCRIPTION
201
 
202
This program is provided to test the connection between the users computer and
203
the ClearQuest Database. It does this by querying the database in the
204
same manner as many of the Release Manager Web Server scripts.
205
 
206
=head1 EXAMPLE
207
 
208
jats etool test_cqconnection
209
 
210
=cut
211