Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
castor
CASTOR
Commits
b6a74ed1
Commit
b6a74ed1
authored
Nov 01, 2010
by
Steven Murray
Browse files
Added a single reinstall stager db function.
parent
6c46c59c
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/tapegateway_release_tests/CastorTapeTests.pm
View file @
b6a74ed1
...
...
@@ -40,6 +40,7 @@ our $VERSION = 1.00;
our
@ISA
=
qw(Exporter)
;
our
@export
=
qw(
get_disk_servers
read_config
check_environment
get_environment
...
...
@@ -83,13 +84,23 @@ my @local_files;
# keep track of the files migrated in castor.
my
@remote_files
;
# keep track of the test environ
e
ment (and definition of the defaults).
# keep track of the test environment (and definition of the defaults).
my
%environment
=
(
allowed_stagers
=>
[
'
lxcastordev03
',
'
lxcastordev04
'
]
);
my
$time_reference
;
# Based on the output of bhosts, this subroutine returns the hostnames of the
# disk-servers sorted alphabetically.
sub
get_disk_servers
()
{
my
@servers
=
`
bhosts | egrep -v 'HOST_NAME|closed' | awk '{print
\
$1;}' | sort
`;
chomp
(
@servers
);
return
@servers
;
}
# Elapsed time since first call which implicitly sets the reference moment
sub
elapsed_time
()
{
...
...
@@ -149,7 +160,7 @@ sub check_environment ( )
}
# Extract enviroment variable (mainly for client application)
sub
get_environ
e
ment
(
$
)
sub
get_environment
(
$
)
{
my
$vname
=
shift
;
if
(
defined
$environment
{
$vname
}
)
{
...
...
@@ -560,23 +571,28 @@ sub check_remote_entries_break ()
#
@return
The value of the parameter.
sub getOrastagerconfigParam ( $ )
{
my
$paramName
=
$_
[0];
open(CONFIG, "</etc/castor/ORASTAGERCONFIG")
or die "Failed to open /etc/castor/ORASTAGERCONFIG: $!";
while(<CONFIG>) {
chomp;
if(m/^DbCnvSvc
\
s+
$paramName
\
s+(
\
w+)/) {
close CONFIG;
return $1;
}
my
$paramName
=
$_
[0];
my
$foundParamValue
= 0;
my
$paramValue
= "";
open(CONFIG, "</etc/castor/ORASTAGERCONFIG")
or die "Failed to open /etc/castor/ORASTAGERCONFIG: $!";
while(<CONFIG>) {
chomp;
if(m/^DbCnvSvc
\
s+
$paramName
\
s+(
\
w+)/) {
$paramValue
= $1;
$foundParamValue
= 1;
}
close CONFIG;
print("ABORT: Failed to get ORASTAGERCONFIG parameter: paramName=
$paramName
\n
");
exit(-1);
}
close CONFIG;
die("ABORT: Failed to get ORASTAGERCONFIG parameter: paramName=
$paramName
\n
")
if(!
$foundParamValue
);
return
$paramValue
;
}
# open_db : find connection parameters and open db connection
...
...
@@ -1187,9 +1203,10 @@ sub print_leftovers ( $ )
}
}
# Wipes and recreates the DB for lxcastordev03 (with a check to prevent wiping of unmigrated files
sub
wipeAndRecreateDefaultLxcastodev03
()
sub
reinstall_stager_db
()
{
my
$stager_host
=
getCastorConfParam
('
STAGER
',
'
HOST
');
# Print error message and abort if the user is not root
my
$uid
=
POSIX::
getuid
;
my
$gid
=
POSIX::
getgid
;
...
...
@@ -1197,32 +1214,7 @@ sub wipeAndRecreateDefaultLxcastodev03 ()
print
("
ABORT: This script must be ran as root
\n
");
exit
(
-
1
);
}
# Make sure we're running on the proper machine.
my
$host
=
`
uname -n
`;
if
(
!
$host
=~
/^lxcastordev03($|\.)/i
)
{
print
('
ABORT: This script is only made to be run on host lxcastordev03\n
');
exit
-
1
;
}
# Ensure all of the daemons accessing the stager-database are dead
killDaemonWithTimeout
('
jobmanagerd
'
,
2
);
killDaemonWithTimeout
('
mighunterd
'
,
2
);
killDaemonWithTimeout
('
rechandlerd
'
,
2
);
killDaemonWithTimeout
('
rhd
'
,
2
);
killDaemonWithTimeout
('
rmmasterd
'
,
2
);
killDaemonWithTimeout
('
rtcpclientd
'
,
2
);
killDaemonWithTimeout
('
stagerd
'
,
2
);
killDaemonWithTimeout
('
tapegatewayd
',
2
);
# Ensure there is no leftover in the DB
my
$dbh
=
open_db
();
if
(
check_leftovers
(
$dbh
)
)
{
print_leftovers
(
$dbh
);
$dbh
->
disconnect
();
die
("
Found leftovers in the stager's DB. Stopping here.
");
}
my
$checkout_location
=
$environment
{
checkout_location
};
my
$dbDir
=
$environment
{
dbDir
};
my
$originalDropSchema
=
$environment
{
originalDropSchema
};
...
...
@@ -1237,96 +1229,23 @@ sub wipeAndRecreateDefaultLxcastodev03 ()
die
"
ABORT:
$originalDbSchema
does not exist
\n
"
if
!
-
e
$originalDbSchemaFullpath
;
my
$dbUser
=
&getOrastagerconfigParam
("
user
");
my
$dbPasswd
=
&getOrastagerconfigParam
("
passwd
");
my
$dbName
=
&getOrastagerconfigParam
("
dbName
");
executeSQLPlusScript
(
$dbUser
,
$dbPasswd
,
$dbName
,
$originalDropSchemaFullpath
,
"
Dropping schema
");
my
$stageGid
=
$environment
{
stageGid
};
my
$stageUid
=
$environment
{
stageUid
};
my
$adminList
=
$environment
{
adminList
};
my
$hacked_creation
=
`
mktemp
`;
chomp
$hacked_creation
;
`
cat
$originalDbSchemaFullpath
>
$hacked_creation
`;
`
sed -i s/^ACCEPT/--ACCEPT/
$hacked_creation
`;
`
sed -i s/^PROMPT/--PROMPT/
$hacked_creation
`;
`
sed -i s/^UNDEF/--UNDEF/
$hacked_creation
`;
`
sed -i s/
\\
&stageGid/
$stageGid
/g
$hacked_creation
`;
`
sed -i s/
\\
&stageUid/
$stageUid
/g
$hacked_creation
`;
`
sed -i s/
\\
&adminList/
$adminList
/g
$hacked_creation
`;
executeSQLPlusScript
(
$dbUser
,
$dbPasswd
,
$dbName
,
$hacked_creation
,
"
Re-creating schema
");
unlink
$hacked_creation
;
# Restart the demons
`
/etc/init.d/jobmanagerd start
`;
#`/etc/init.d/mighunterd start`;
`
/etc/init.d/rechandlerd start
`;
`
/etc/init.d/rhd start
`;
`
/etc/init.d/rmmasterd start
`;
#`/etc/init.d/rtcpclientd start`;
`
/etc/init.d/stagerd start
`;
#`/etc/init.d/tapegatewayd start`;
my
$sleepPeriod
=
5
;
print
("
Sleeping
$sleepPeriod
seconds
\n
");
sleep
(
$sleepPeriod
);
my
$rmGetNodesResult
=
`
rmGetNodes | egrep 'name:'
`;
print
("
\n
");
print
("
rmGetNodes RESULTS
\n
");
print
("
==================
\n
");
print
(
$rmGetNodesResult
);
# Fill database with the standard set-up for a dev-box
`
nslistclass | grep NAME | awk '{print
\
$2}' | xargs -i enterFileClass --Name {} --GetFromCns
`;
`
enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev03 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1
`;
`
enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes
`;
`
enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes
`;
`
moveDiskServer default lxc2disk05.cern.ch
`;
`
moveDiskServer extra lxc2disk06.cern.ch
`;
`
rmAdminNode -r -R -n lxc2disk05.cern.ch
`;
`
rmAdminNode -r -R -n lxc2disk06.cern.ch
`;
# Add a tape-pool to dev service-class ready for shared tape-pool tests
`
modifySvcClass --Name dev --AddTapePool stager_dev03_2 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1
`;
# Set the number of drives on the default and dev service-classes to desired number for each
`
modifySvcClass --Name default --NbDrives 1
`;
`
modifySvcClass --Name dev --NbDrives 2
`;
`
modifySvcClass --Name dev --AddTapePool stager_dev03_2
`;
$dbh
->
disconnect
();
undef
$dbh
;
}
# Wipes and recreates the DB for lxcastordev04 (with a check to prevent wiping of unmigrated files
sub
wipeAndRecreateDefaultLxcastodev04
()
{
die
"
Please review and fix wipeAndRecreateDefaultLxcastodev04
";
# Print error message and abort if the user is not root
my
$uid
=
POSIX::
getuid
;
my
$gid
=
POSIX::
getgid
;
if
(
$uid
!=
0
||
$gid
!=
0
)
{
print
("
ABORT: This script must be ran as root
\n
");
exit
(
-
1
);
}
# Make sure we're running on the proper machine.
my
$host
=
`
uname -n
`;
if
(
!
$host
=~
/^lxcastordev04($|\.)/i
)
{
print
('
ABORT: This script is only made to be run on host lxcastordev04\n
');
exit
-
1
;
die
('
ABORT: This script is only made to be run on host $stager_host\n
')
if
(
!
$host
=~
/^$stager_host($|\.)/i
);
my
@diskServers
=
&get_disk_servers
;
my
$nbDiskServers
=
@diskServers
;
print
("
Found the following disk-servers:
");
foreach
(
@diskServers
)
{
print
("
$_
");
}
print
("
\n
");
die
("
ABORT: Reinstall requires at least 2 disk-servers
")
if
(
$nbDiskServers
<
2
);
# Ensure all of the daemons accessing the stager-database are dead
killDaemonWithTimeout
('
jobmanagerd
'
,
2
);
killDaemonWithTimeout
('
mighunterd
'
,
2
);
...
...
@@ -1345,20 +1264,6 @@ sub wipeAndRecreateDefaultLxcastodev04 ()
die
("
Found leftovers in the stager's DB. Stopping here.
");
}
my
$checkout_location
=
$environment
{
checkout_location
};
my
$dbDir
=
$environment
{
dbDir
};
my
$originalDropSchema
=
$environment
{
originalDropSchema
};
my
$originalDbSchema
=
$environment
{
originalDbSchema
};
my
$originalDropSchemaFullpath
=
$checkout_location
.
'
/
'
.
$dbDir
.
'
/
'
.
$originalDropSchema
;
my
$originalDbSchemaFullpath
=
$checkout_location
.
'
/
'
.
$dbDir
.
'
/
'
.
$originalDbSchema
;
die
"
ABORT:
$originalDropSchema
does not exist
\n
"
if
!
-
e
$originalDropSchemaFullpath
;
die
"
ABORT:
$originalDbSchema
does not exist
\n
"
if
!
-
e
$originalDbSchemaFullpath
;
my
$dbUser
=
&getOrastagerconfigParam
("
user
");
my
$dbPasswd
=
&getOrastagerconfigParam
("
passwd
");
my
$dbName
=
&getOrastagerconfigParam
("
dbName
");
...
...
@@ -1394,7 +1299,7 @@ sub wipeAndRecreateDefaultLxcastodev04 ()
`
/etc/init.d/stagerd start
`;
#`/etc/init.d/tapegatewayd start`;
my
$sleepPeriod
=
2
;
my
$sleepPeriod
=
5
;
print
("
Sleeping
$sleepPeriod
seconds
\n
");
sleep
(
$sleepPeriod
);
...
...
@@ -1407,26 +1312,22 @@ sub wipeAndRecreateDefaultLxcastodev04 ()
# Fill database with the standard set-up for a dev-box
`
nslistclass | grep NAME | awk '{print
\
$2}' | xargs -i enterFileClass --Name {} --GetFromCns
`;
`
enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev04 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1
`;
`
enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes
`;
`
enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes
`;
`
moveDiskServer default lxc2disk05.cern.ch
`;
`
moveDiskServer extra lxc2disk06.cern.ch
`;
print
`
enterSvcClass --Name default --DiskPools default --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes --NbDrives 1 --TapePool stager_dev03 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1
`;
print
`
enterSvcClass --Name dev --DiskPools extra --DefaultFileSize 10485760 --FailJobsWhenNoSpace yes
`;
print
`
enterSvcClass --Name diskonly --DiskPools extra --ForcedFileClass temp --DefaultFileSize 10485760 --Disk1Behavior yes --FailJobsWhenNoSpace yes
`;
`
rmAdminNode -r -R -n lxc2disk05.cern.ch
`;
`
rmAdminNode -r -R -n lxc2disk06.cern.ch
`;
print
`
moveDiskServer default
$diskServers
[0]
`;
print
`
moveDiskServer extra
$diskServers
[1]
`;
print
`
rmAdminNode -r -R -n
$diskServers
[0]
`;
print
`
rmAdminNode -r -R -n
$diskServers
[1]
`;
# Add a tape-pool to dev service-class ready for shared tape-pool tests
###`modifySvcClass --Name dev --AddTapePool stager_dev03_2 --MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1`;
# Add a tape-pool to dev service-class
my
$tapePool
=
get_environment
('
tapepool
');
print
`
modifySvcClass --Name dev --AddTapePool
$tapePool
--MigratorPolicy defaultMigrationPolicy --StreamPolicy streamPolicyAlwaysReturning1
`;
# Set the number of drives on the default and dev service-classes to desired number for each
###`modifySvcClass --Name default --NbDrives 1`;
###`modifySvcClass --Name dev --NbDrives 2`;
###`modifySvcClass --Name dev --AddTapePool stager_dev03_2`;
$dbh
->
disconnect
();
undef
$dbh
;
print
`
modifySvcClass --Name default --NbDrives 1
`;
print
`
modifySvcClass --Name dev --NbDrives 2
`;
}
...
...
test/tapegateway_release_tests/test_gateway_wipe_reinstall_migrate.pl
View file @
b6a74ed1
#!/usr/bin/perl -w
###############################################################################
#
test/castor/tape/mighunter/testmighunter
#
test/tapegateway_release_tests/test_gateway_wipe_reinstall_migrate.pl
#
# This file is part of the Castor project.
# See http://castor.web.cern.ch/castor
...
...
@@ -62,12 +62,12 @@ sub main ()
my
$conffile
=
'
./tapetests-lxcastordev.conf
';
CastorTapeTests::
read_config
(
$conffile
);
CastorTapeTests::
check_environment
();
my
$file_size
=
CastorTapeTests::
get_environ
e
ment
('
file_size
');
my
$file_number
=
CastorTapeTests::
get_environ
e
ment
('
file_number
');
my
$castor_directory
=
CastorTapeTests::
get_environ
e
ment
('
castor_directory
');
my
$single_subdir
=
CastorTapeTests::
get_environ
e
ment
('
castor_single_subdirectory
');
my
$dual_subdir
=
CastorTapeTests::
get_environ
e
ment
('
castor_dual_subdirectory
');
my
$username
=
CastorTapeTests::
get_environ
e
ment
('
username
');
my
$file_size
=
CastorTapeTests::
get_environment
('
file_size
');
my
$file_number
=
CastorTapeTests::
get_environment
('
file_number
');
my
$castor_directory
=
CastorTapeTests::
get_environment
('
castor_directory
');
my
$single_subdir
=
CastorTapeTests::
get_environment
('
castor_single_subdirectory
');
my
$dual_subdir
=
CastorTapeTests::
get_environment
('
castor_dual_subdirectory
');
my
$username
=
CastorTapeTests::
get_environment
('
username
');
my
$dbh
=
CastorTapeTests::
open_db
();
...
...
@@ -81,19 +81,12 @@ sub main ()
$dbh
->
disconnect
();
# Nuke and start clean
my
$host
=
`
hostname -s
`;
chomp
$host
;
if
(
$host
eq
'
lxcastordev03
'
)
{
my
$u
;
print
"
t=
"
.
CastorTapeTests::
elapsed_time
.
"
s.
";
print
"
Wiping the DB for a run of rtcpclientd with classic schema =============
\n
";
CastorTapeTests::
wipeAndRecreateDefaultLxcastodev03
();
}
elsif
(
$host
eq
'
lxcastordev04
'
)
{
my
$u
;
print
"
t=
"
.
CastorTapeTests::
elapsed_time
.
"
s.
";
print
"
Wiping the DB for a run of rtcpclientd with classic schema =============
\n
";
CastorTapeTests::
wipeAndRecreateDefaultLxcastodev04
();
}
else
{
die
"
Unexpected host.
";
if
(
(
$host
ne
'
lxcastordev03
')
&&
(
$host
ne
'
lxcastordev04
'))
{
die
("
ABORT: Unexpected host
\"
$host
\"
");
}
print
"
t=
"
.
CastorTapeTests::
elapsed_time
.
"
s.
";
print
"
Wiping the DB for a run of rtcpclientd with classic schema =============
\n
";
CastorTapeTests::
reinstall_stager_db
();
print
"
t=
"
.
CastorTapeTests::
elapsed_time
.
"
s
\n
";
my
$seed_index
=
CastorTapeTests::
make_seed
(
$file_size
);
...
...
@@ -171,12 +164,12 @@ sub main ()
sub
goodDaySingleAndDualCopyTest
(
$$
)
{
my
(
$seed_index
,
$file_number
)
=
(
shift
,
shift
);
my
$castor_directory
=
CastorTapeTests::
get_environ
e
ment
('
castor_directory
');
my
$single_subdir
=
CastorTapeTests::
get_environ
e
ment
('
castor_single_subdirectory
');
my
$dual_subdir
=
CastorTapeTests::
get_environ
e
ment
('
castor_dual_subdirectory
');
my
$username
=
CastorTapeTests::
get_environ
e
ment
('
username
');
my
$poll
=
CastorTapeTests::
get_environ
e
ment
('
poll_interval
');
my
$timeout
=
CastorTapeTests::
get_environ
e
ment
('
migration_timeout
');
my
$castor_directory
=
CastorTapeTests::
get_environment
('
castor_directory
');
my
$single_subdir
=
CastorTapeTests::
get_environment
('
castor_single_subdirectory
');
my
$dual_subdir
=
CastorTapeTests::
get_environment
('
castor_dual_subdirectory
');
my
$username
=
CastorTapeTests::
get_environment
('
username
');
my
$poll
=
CastorTapeTests::
get_environment
('
poll_interval
');
my
$timeout
=
CastorTapeTests::
get_environment
('
migration_timeout
');
for
my
$sd
(
0
,
1
)
{
for
my
$i
(
0
..
(
$file_number
-
1
)
)
{
...
...
@@ -207,7 +200,7 @@ sub managePostTransitionBacklog ()
# To be fleshed out.
# Check that the tapes from the tape pool have been left in a proper state.
my
$tapepool
=
CastorTapeTests::
get_environ
e
ment
('
tapepool
');
my
$tapepool
=
CastorTapeTests::
get_environment
('
tapepool
');
my
$tp_status
=
`
vmgrlisttape -P
$tapepool
`;
for
(
split
/^/
,
$tp_status
)
{
if
(
/BUSY/
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment