[-use|rname <username>] [-p|assword <password>]
[-log]
-m|achines <host1>,<host2>,...
-
+
<command>
Where:
my ($clearpid, $clearin, $clearout, $oldHandler, $cleartool);
-our $VIEW_DRIVE = 'M';
+our $VIEW_DRIVE = $ENV{CLEARCASE_VIEW_DRIVE} || 'M';
our $VOB_MOUNT = 'vob';
our $WIN_VOB_PREFIX = '\\';
our $SFX = $ENV{CLEARCASE_XN_SFX} ? $ENV{CLEARCASE_XN_SFX} : '@@';
# We can go to the registry pretty easy in Cygwin but I'm not sure how to do
# that in plain old Windows. Most people either have Clearcase installed on
# the C drive or commonly on the D drive on servers. So we'll look at both.
- $CCHOME = 'C:\\IBMRational\\RationalSDLC\\Clearcase';
+ $CCHOME = 'C:\\Program Files (x86)\\ibm\\RationalSDLC\\Clearcase';
- $CCHOME = 'D:\\IBMRational\\RationalSDLC\\Clearcase'
+ $CCHOME = 'D:\\Program Files (x86)\\ibm\\RationalSDLC\\Clearcase'
unless -d $CCHOME;
error 'Unable to figure out where Clearcase is installed', 1
# to use these Clearcase objects say in a web page where the server is often
# run as a plain user who does not have cleartool in their path.
unless ($cleartool) {
- if ($ARCHITECTURE =~ /Win/ or $ARCHITECTURE eq 'cygwin') {
+ if ($ARCHITECTURE =~ /Win/i or $ARCHITECTURE eq 'cygwin') {
$cleartool = 'cleartool';
} elsif (-x '/opt/rational/clearcase/bin/cleartool') {
$cleartool = '/opt/rational/clearcase/bin/cleartool';
$msg = "ERROR: $msg";
} # if
- $self->log ($msg);
+ $self->msg($msg);
$self->incrementErr;
################################################################################
umask 002
-export SITE_PERLLIB=/cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/lib
-export PATH=/cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/clearcase:$PATH
+if [ -d /cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/lib ]; then
+ export PERL5LIB=/cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/lib:$PERL5LIB
+fi
-export http_proxy=webgate0.gddsi.com:8080
-export ftp_proxy=webgate0.gddsi.com
+# This no longer work
+#export http_proxy=webgate0.gddsi.com:8080
+#export ftp_proxy=webgate0.gddsi.com
export QTDIR="/usr/local/Trolltech/Qt-4.2.2"
export QMAKESPEC="$QTDIR/mkspecs/solaris-cc"
export CQ_HELP_BROWSER=firefox
export CQ_PERLLIB=/opt/rational/common/lib/perl5/5.6.1/sun4-solaris-multi:/opt/rational/common/lib/perl5/5.6.1:/opt/rational/common/lib/perl5/site_perl/5.6.1/sun4-solaris-multi:/opt/rational/common/lib/perl5/site_perl/5.6.1:/opt/rational/common/lib/perl5/site_perl
-export PERL5LIB=/cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/lib:$PERL5LIB
export TZ="US/Arizona"
export LM_LICENSE_FILE="1850@ma06app30:flex2:1850@flex2:15280@ranadm2:19353@ranadm2:19355@ranadm2:2468@ranadm2:1717@flex2:1711@bartlett:1711@flex3:27000@ranadm2:28000@ranadm2:5270@flex2"
-alias xemacs="ssh muosbldforge2 xemacs"
-
-export EDITOR="ssh muosbldforge2 xemacs"
-
if [ $(uname) = "SunOS" ]; then
export QTDIR=/usr/local/Trolltech/Qt-4.2.2
export ORACLE_HOME="/usr/local/oracle/product/9.2"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/X11R6/lib
fi
+# Where the Clearcase view drive is on Windows
+export CLEARCASE_VIEW_DRIVE=X
+
# Additional paths...
-append_to_path "/c/Program Files/IBM/RationalSDLC/common"
-append_to_path "/d/Program Files/IBM/RationalSDLC/common"
-append_to_path "/c/Program Files/IBM/RationalSDLC/Clearquest/cqcli/bin"
-append_to_path "/d/Program Files/IBM/RationalSDLC/Clearquest/cqcli/bin"
-append_to_path "/c/Program Files/IBM/RationalSDLC/ClearCase/bin"
-append_to_path "/d/Program Files/IBM/RationalSDLC/ClearCase/bin"
+append_to_path "/cleartrig/ent/SNSD/muos/ccadm_tools/vobs/ranccadm/scripts/clearcase"
+append_to_path "/cygcrive/c/Program Files/IBM/RationalSDLC/common"
+append_to_path "/cygcrive/d/Program Files/IBM/RationalSDLC/common"
+append_to_path "/cygcrive/c/Program Files/IBM/RationalSDLC/Clearquest/cqcli/bin"
+append_to_path "/cygcrive/d/Program Files/IBM/RationalSDLC/Clearquest/cqcli/bin"
+append_to_path "/cygcrive/c/Program Files/IBM/RationalSDLC/ClearCase/bin"
+append_to_path "/cygcrive/d/Program Files/IBM/RationalSDLC/ClearCase/bin"
+append_to_path "/cygdrive/c/Program Files (x86)/ibm/gsk8/lib"
# Common CDPATHS
CDPATH=$CDPATH:/vobs/ranccadm
/tools/bin\
$systemroot/System32\
$systemroot\
-"
+"
manpath_dirs="\
/usr/share/man\
/opt/ssh/man\
/opt/medusa/share/man\
/usr/afsws/man\
-"
+"
PATH=
for component in $path_dirs; do
################################################################################
#
-# File: testcc.conf
+# File: testclearcase.conf
# Revision: 2.0
-# Description: Parameters for testcc
+# Description: Parameters for testclearcse.pl
#
# Author: Andrew@DeFaria.com
# Created: Thu Sep 6 14:05:55 MST 2007
# (c) Copyright 2007, Andrew@DeFaria.com, all rights reserved.
#
#################################################################################
-vobhost: gdvob1
-vobpath: /net/$vobhost
-vobstore: $vobpath/local/gdvob1a
+# Note this conf file is set up for Windows...
+vobhost: az251dp2ch2d
+vobpath: //$vobhost
+vobstore: $vobpath/temp
-viewhost: view2
-viewpath: /net/$viewhost
-viewstore: $viewpath/local/view2c
+viewhost: az251dp2ch2d
+viewpath: //$vobhost
+viewdrive: x:
+viewstore: $viewpath/viewstore
-[no]uc|m: Perform UCM Clearcase tests (Default: noucm)
-[no]clean: Cleanup after yourself (Default: clean)
+if -ucm is specified then the following additional parameters should be set:
+
+ -username: Username to connect to Clearquest with (Can set CQ_USERNAME)
+ -password: Password to use to connect to Clearquest (CQ_PASSWORD)
+ -weburl: Web URL to use for enabling Clearcase -> Clearquest
+ connection (CQ_WEBURL - Do not specify the trailing
+ "/oslc")
+ -database: Clearquest database to enable (CQ_DATABASE)
+ -dbset: Clearquest DBSet (CQ_DBSET)
+ -provider: Name of provider (Default: CQPROV)
+
=head1 DESCRIPTION
Clearcase smoke tests. Perform simple Clearcase operations to validate that
use Cwd;
use FindBin;
use Getopt::Long;
-#use Term::ANSIColor qw(:constants);
+use Pod::Usage;
use lib "$FindBin::Bin/../lib";
);
for (sort keys %opts) {
+ next if /help/ || /usage/ || /password/;
+
if (ref $opts{$_} eq 'ARRAY') {
my $name = $_;
- $log->msg("$name:\t$_") for @{$opts{$_}};
+
+ for (@{$opts{$_}}) {
+ $log->msg("$name:\t$_") if $_;
+ } # for
} else {
- $log->msg("$_:\t$opts{$_}");
+ if ($opts{$_}) {
+ $log->msg("$_:\t$opts{$_}");
+ } else {
+ $log->msg("$_:\t<undef>");
+ } # if
} # if
} # for
($status, @output) = $Clearcase::CC->execute('cd');
+ $log->err('Unable to perform cd command', 1) if $status;
+
$log->msg('Unmounting vob ' . $vob->tag);
($status, @output) = $vob->umount;
+ if ($status) {
+ $log->err('Unable to unmount vob ' . $vob->tag);
+ } else {
+ $log->msg('Umounted vob ' . $vob->tag);
+ } # if
+
$log->msg('Removing vob ' . $vob->tag);
($status, @output) = $vob->remove;
+ if ($status) {
+ $log->err("Failed to execute command " .
+ $Clearcase::CC->lastcmd . "\n" .
+ join "\t\n", @output);
+ } # if
+
$log->log($_) for @output;
return $status;
return $status;
} # SetView
+sub StopView($) {
+ my ($view) = @_;
+
+ $log->msg('Stopping view ' . $view->tag);
+
+ my ($status, @output) = $view->stop;
+
+ $log->log($_) for @output;
+
+ return $status;
+} # StopView
+
sub DestroyView($) {
my ($view) = @_;
($rc, @output) = $test_activity->remove;
$status += $rc;
-
+
$log->log($_) for @output;
# Need to remove baselines from streams first using rebase (Devstream)
$log->log($_) for @output;
$status += DestroyView($test_intview);
-
+
$log->msg('Removing '. $test_devstream->name);
($rc, @output) = $test_devstream->remove;
($status, @output) = $Clearcase::CC->execute("cd $dir");
- if ($status != 0) {
- $log->log($_) for @output;
- } # if
+ $log->log($_) for @output;
return $status;
} # SetupTest
+sub SetupAttributeTypes() {
+ my @CC_CMI_Types = qw(CONTEXT TASK PROVIDERS);
+
+ my $status = SetView($test_intview);
+
+ return $status if $status;
+
+ for (@CC_CMI_Types) {
+ my $cmd = "mkattype -nc -vtype string CC_CMI_$_";
+
+ my ($rc, @output) = $Clearcase::CC->execute($cmd);
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+ } # for
+
+ return $status;
+} # SetupAttributeTypes
+
+sub CRMRegister() {
+ my $cmd = "crmregister add -database $opts{database} -connection RDE "
+ . "-url $opts{weburl} -username $opts{username} "
+ . "-password $opts{password}";
+
+ my ($status, @output) = Execute $cmd;
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CRMRegister
+
+sub MakeCMProvider() {
+ my $cmd = 'mkcmprovider -vob ' . $test_pvob->tag
+ . '-type cmcq -version V1_0 -description '
+ . '"RDE CMI CQ Provider" '
+ . '-connection baseurl:' . $opts{weburl} . " $opts{provider}";
+
+ my ($status, @output) = $Clearcase::CC->execute($cmd);
+
+ $log->log($_) for @output;
+
+ return $status;
+} # MakeCMProvider
+
sub SetupUCMTest() {
my $status;
- $log->msg("Creating UCM Pvob $Clearcase::VOBTAG_PREFIX/tc.pvob");
+ $log->msg("Register RDE://$opts{username}\@$opts{database}");
+
+ $status = CRMRegister;
+
+ $log->err("Unable to register RDE://$opts{username}\@$opts{database} - Check logfile", $status)
+ if $status;
- ($status, $test_pvob) = CreatePvob("$Clearcase::VOBTAG_PREFIX/tc.pvob");
+ $log->msg("Creating UCM Pvob ${Clearcase::VOBTAG_PREFIX}tc.pvob");
+
+ ($status, $test_pvob) = CreatePvob("${Clearcase::VOBTAG_PREFIX}tc.pvob");
+
+ MountVob $test_pvob;
return $status;
} # SetupUCMTest
$test_project = Clearcase::UCM::Project->new('tc.project', $test_folder, $test_pvob);
$test_project->remove if $test_project->exists;
-
+
$log->msg('Creating UCM Project tc.project');
my ($status, @output) = $test_project->create;
$status += CreateUCMIntStream;
$status += CreateUCMDevStream;
$status += CreateUCMIntView;
+ $status += SetupAttributeTypes;
$status += CreateUCMDevView;
$status += CreateUCMComponent;
$status += AddModifiableComponent;
my $conf_file = "$FindBin::Bin/$script.conf";
my $status = 0;
-$opts{base} = 1;
-$opts{clean} = 1;
+$opts{help} = sub { pod2usage };
+$opts{usage} = sub { pod2usage (-verbose => 2)};
+$opts{base} = 1;
+$opts{clean} = 1;
+$opts{username} = $ENV{CQ_USERNAME};
+$opts{password} = $ENV{CQ_PASSWORD};
+$opts{weburl} = $ENV{CQ_WEBURL};
+
+$opts{weburl} .= $opts{weburl} ? "/oslc" : undef;
+$opts{database} = $ENV{CQ_DATABASE};
+$opts{dbset} = $ENV{CQ_DBSET};
+$opts{provider} = $ENV{CQ_PROVIDER} || 'CQPROV';
GetOptions(
\%opts,
'base!',
'ucm!',
'clean!',
-) or Usage;
+ 'username=s',
+ 'database=s',
+ 'dbset=s',
+ 'provider',
+) || pod2usage;
# Read the config file
if (-f $conf_file) {
$opts{$_} = $default_opts{$_} if !$opts{$_};
} # for
+# Check CQ parameters
+if ($opts{ucm}) {
+ for ('username', 'password', 'weburl', 'database', 'dbset', 'provider') {
+ pod2usage "In UCM mode you must specify -$_" unless $opts{$_};
+ } # for
+} # if
+
$log->msg("$script: Start");
LogOpts;
# Since we are creating private vobs (to avoid complications with having to
# know and code the registry password when making public vobs), we'll simply
# change $Clearcase::VOBTAG_PREFIX
-$Clearcase::VOBTAG_PREFIX = $ENV{TMP} || '/tmp';
+if ($ARCHITECTURE !~ /win/i) {
+ $Clearcase::VOBTAG_PREFIX = $ENV{TMP} . '/' || '/tmp';
+} # if
if ($opts{base}) {
- $status = SetupTest "$Clearcase::VOBTAG_PREFIX/tc.vob", 'tc.view';
+ $status = SetupTest "${Clearcase::VOBTAG_PREFIX}tc.vob", 'tc.view';
if ($status == 0) {
$status += RunTests;
} # if
# Note if we are doing UCM tests then we need the view and vob here...
- $status += Cleanup($test_view, $test_vob) if $opts{clean} and !$opts{ucm};
+ $status += Cleanup($test_view, $test_vob) if $opts{clean} && !$opts{ucm};
if ($status != 0) {
$log->err("$script: Failed (Base Clearcase)");
L<Getopt::Long|Getopt::Long>
-L<Term::ANSIColor|Term::ANSIColor>
-
=head2 ClearSCM Perl Modules
-=begin man
+=begin man
Clearcase
Clearcase::Element
=head1 SYNOPSIS
Usage: testclearquest.pl [-u|sage] [-v|erbose] [-d|ebug]
- [-get] [-add] [-modify] [-change] [-delete]
+ [-get] [-add] [-modify] [-change] [-delete]
[-username <username>] [-password <password>]
[-database <dbname>] [-dbset <dbset>]
[-module] [-server <server>] [-port <port>]
-
+
Where:
-usa|ge: Displays usage
-v|erbose: Be verbose
-change: Test change
-delete: Test delete
- -use|rname: Username to open database with (Default: from config file)
- -p|assword: Password to open database with (Default: from config file)
- -da|tabase: Database to open (Default: from config file)
- -db|set: Database Set to use (Default: from config file)
- -m|odule: Type of Clearquest module to use. Must be one of 'api',
- 'client', or 'rest'. The 'api' module can only be used if
- Clearquest is installed locally. The 'client' module can only
- be successful if a corresponding server is running. And the
- 'rest' module can only be used if a CQ Web server has been set
- up and configured (Default: rest)
- -s|erver: For module = client or rest this is the name of the server that
- will be providing the service
- -p|ort: For module = client, this is the point on the server to talk
- through.
+ -use|rname: Username to open database with (Default: CQ_USERNAME or from
+ config file)
+ -p|assword: Password to open database with (Default: CQ_PASSWORD or from
+ config file)
+ -da|tabase: Database to open (Default: CQ_DATABASE or from config file)
+ -db|set: Database Set to use (Default: CQ_DBSET or from config file)
+
=head1 Options
use FindBin;
use Getopt::Long;
+use Pod::Usage;
use lib "$FindBin::Bin/../lib";
use DateUtils;
use Display;
use Logger;
+use OSDep;
use TimeUtils;
use Utils;
my ($cq, %opts, $log, $createView, $test_pvob, $test_project);
-my $status = 0;
+my $status = 0;
my $project = 'tc.project';
sub displayRecord(%) {
my (%record) = @_;
-
+
$log->msg('-' x 79);
-
+
for (keys %record) {
$log->msg("$_: ", 1);
-
+
if (ref $record{$_} eq 'ARRAY') {
$log->msg(join ", ", @{$record{$_}});
} elsif ($record{$_}) {
$log->msg('<undef>');
} # if
} # for
-
+
return;
} # displayRecord
sub displayResults(@) {
my (@records) = @_;
-
+
if (@records) {
displayRecord %$_ foreach (@records);
} else {
$log->msg('Did not find any records');
} # if
-
+
return;
} # displayResults
sub GetRecord($$;@) {
my ($table, $key, @fields) = @_;
-
+
$log->msg("Gettng table: $table key: $key");
my %record = $cq->get($table, $key, @fields);
-
+
if ($cq->checkErr) {
$log->err($cq->errmsg);
} else {
displayRecord %record;
} # if
-
+
return $cq->error;
} # GetRecord
sub FindRecord($$;@) {
my ($table, $condition, @fields) = @_;
-
+
my $status;
-
+
$log->msg("Finding table: $table condition: $condition");
-
+
my ($result, $nbrRecs) = $cq->find($table, $condition, @fields);
$log->msg("$nbrRecs records qualified");
$createView = $record{ws_cr_view} if $table eq 'Platform_Options';
displayRecord %record;
-
+
$status += $cq->error;
} # unless
} # while
-
+
return $status
} # FindRecord
sub ModifyRecord($$;%) {
my ($table, $key, %update) = @_;
-
+
$log->msg("Modifying table: $table key: $key");
-
+
$cq->modify($table, $key, undef, \%update);
-
+
$log->err($cq->errmsg) if $cq->checkErr;
-
+
return $cq->error;
} # ModifyRecord
sub AssignWOR($) {
my ($key) = @_;
-
+
my %record = $cq->get('WOR', $key, ('State'));
-
+
return $cq->error if $cq->checkErr("Unable to find WOR where key = $key");
-
+
my ($action, %update);
-
+
if ($record{State} ne 'Submitted') {
$log->err("Cannot assign $key - not in submitted state");
-
+
return 1;
} # if
$action = 'Assign';
$update{PlannedStart} = Today2SQLDatetime;
$update{ucm_project} = $project;
-
+
$log->msg("Testing change WOR state of $key action: $action");
-
+
$cq->modify('WOR', $key, $action, \%update);
$log->err($cq->errmsg) if $cq->checkErr;
-
+
return $cq->error;
} # AssignWOR
sub ActivateWOR($) {
my ($key) = @_;
-
+
my %record = $cq->get('WOR', $key, ('State'));
-
+
return $cq->error if $cq->checkErr("Unable to find WOR where key = $key");
-
+
my ($action, %update);
-
+
if ($record{State} ne 'Assessing') {
$log->err("Cannot activate $key - not in Assessing state");
-
+
return 1;
} # if
$action = 'Activate';
-
+
$log->msg("Testing change WOR state of $key action: $action");
-
+
$cq->modify('WOR', $key, $action);
$log->err($cq->errmsg) if $cq->checkErr;
-
+
return $cq->error;
} # ActivateWOR
sub AddRecord($$;$$) {
my ($table, $record, $ordering, $returnField) = @_;
-
+
$returnField ||= 'id';
$log->msg("Adding table: $table");
-
+
my $dbid = $cq->add($table, $record, @$ordering);
-
+
if ($cq->checkErr) {
$log->err($cq->errmsg);
sub DeleteRecord($$) {
my ($table, $key) = @_;
-
+
$log->msg("Deleting table: $table key: $key");
-
+
$cq->delete($table, $key);
-
+
$log->err($cq->errmsg) if $cq->checkErr;
return $cq->error;
RCLC_name => 'Test RCLC',
Prod_Arch1 => 'testcode : N/A',
work_product_name => '10 - Software',
- Engr_target => 'Test Engineering Target',
+ #Engr_target => 'Test Engineering Target',
work_code_name => 'RAN-RW2',
);
## Main
GetOptions(
\%opts,
- usage => sub { Usage },
+ usage => sub { pod2usage },
+ help => sub { pod2usage (-verbose => 2)},
verbose => sub { set_verbose },
debug => sub { set_debug },
- 'verbose',
- 'debug',
- 'usage',
'get',
'add',
'modify',
'change',
'delete',
- 'module=s',
'username=s',
'password=s',
'database=s',
'dbset=s',
- 'server=s',
- 'port=i',
-) || Usage;
+) || pod2usage;
my $processStartTime = time;
# Since we are creating private vobs (to avoid complications with having to
# know and code the registry password when making public vobs), we'll simply
# change $Clearcase::VOBTAG_PREFIX
-$Clearcase::VOBTAG_PREFIX = $ENV{TMP} || '/tmp';
+if ($ARCHITECTURE !~ /win/i) {
+ $Clearcase::VOBTAG_PREFIX = $ENV{TMP} || '/tmp';
+} # if
local $| = 1;
unless ($cq->connect) {
$cq->checkErr('Unable to connect to database ' . $cq->connection, undef, $log);
-
+
if ($cq->module eq 'client') {
$log->msg('Unable to connect to server ' . $cq->server() . ':' . $cq->port());
} # if
-
+
exit $cq->error;
} else {
$log->msg('connected');
$log->msg('Enable tc.project for integration with Clearquest');
-$test_pvob = Clearcase::UCM::Pvob->new("$Clearcase::VOBTAG_PREFIX/tc.pvob");
+$test_pvob = Clearcase::UCM::Pvob->new("${Clearcase::VOBTAG_PREFIX}tc.pvob");
$test_project = Clearcase::UCM::Project->new('tc.project', 'tc.folder', $test_pvob);
-my ($rc, @output) = $test_project->change('-force -crmenable XTST1');
+my ($rc, @output) = $test_project->change("-force -crmenable $opts{CQ_DATABASE}");
$status += $rc;
} # unless
if ($opts{change}) {
- $status += AssignWOR $WORID;
- $status += ActivateWOR $WORID;
-} # if
+ my $worStatus;
+
+ $worStatus += AssignWOR $WORID;
+ $worStatus += ActivateWOR $WORID;
-$status += CreateView $WORID;
+ $status += $worStatus;
-$status += Cleanup($WORID);
+ unless ($worStatus) {
+ # If we weren't able to assign and activate the WOR then there's no need
+ # to create the view and no need to clean up unless we created the view.
+ $worStatus = CreateView $WORID;
+
+ $status += Cleanup($WORID) unless $worStatus;
+
+ $status += $worStatus;
+ } # unless
+} # if
if ($status) {
$log->err('Clearquest tests FAILED');