📄 myproxy-test-replicate
字号:
if ($exitstatus != 0 && $output =~ /Unable to connect to/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}($exitstatus, $output) = &runtest("myproxy-destroy -s localhost -p $mport -v", undef);print "\t(remove credential from master repository): ";if ($exitstatus == 0 && $output =~ /was successfully removed/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}start_sl3();($exitstatus, $output) = &runtest("myproxy-replicate -v -c /tmp/myproxy-test.serverconf.$mport.master.$$ -r /tmp/myproxy-test.serverdir.$mport.master.$$", undef);print "\t(Replicate master server to all slaves): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Start of myproxy-store and myproxy-retrieve tests## commands to test: myproxy-store, myproxy-info, myproxy-destroy,# myproxy-get-delegation, myproxy-retrieve, and # myproxy-change-pass-phrase# For myproxy-store, we need an encrypted key to store.# So, let's encrypt our proxy key.$passphrase = sprintf "%010.d", int(rand(0x7fffffff));&runtest("openssl rsa -des3 -passout stdin -in \$X509_USER_KEY -out /tmp/myproxy-test.$$.key", $passphrase . "\n");$ENV{'X509_USER_KEY'} = "/tmp/myproxy-test.$$.key";## Test 26#($exitstatus, $output) = &runtest("myproxy-store -s localhost -p $mport -v -t 1", undef);print "MyProxy Test 26 (store credential with default name): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} elsif (($output =~ /Error checking authorization/) || ($output =~ /unknown command/)) { print "UNSUPPORTED\n"; $FAILURES++; print "Server does not support myproxy-store. Skipping futher myproxy-store tests.\n"; goto end_of_store_tests;} else { print "FAILED\n"; $FAILURES++; print STDERR $output; print "Skipping futher myproxy-store tests.\n"; goto end_of_store_tests;}## Test 27#($exitstatus, $output) = &runtest("myproxy-info -s localhost -p $mport -v", undef);print "MyProxy Test 27 (get info for stored credential): ";if ($exitstatus == 0 && $output =~ /username/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 28#($exitstatus, $output) = &runtest("myproxy-get-delegation -s localhost -p $mport -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n");print "MyProxy Test 28 (create proxy from stored credential on master): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 29#($exitstatus, $output) = &runtest("myproxy-retrieve -s localhost -p $mport -c /tmp/myproxy-test.cert.$$ -y /tmp/myproxy-test.key.$$ -v -S", $passphrase . "\n");print "MyProxy Test 29 (retrieve stored credential from master): ";if ($exitstatus == 0) { ($exitstatus, $output) = &verifycert("/tmp/myproxy-test.cert.$$", "/tmp/myproxy-test.key.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}unlink( "/tmp/myproxy-test.cert.$$" );unlink( "/tmp/myproxy-test.key.$$" );#### Test 30##($exitstatus, $output) = &runtest("myproxy-replicate -c /tmp/myproxy-test.serverconf.$mport.master.$$ -r /tmp/myproxy-test.serverdir.$mport.master.$$", undef);print "MyProxy Test 30 (Replicate to all slaves): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 31#($exitstatus, $output) = &runtest("myproxy-get-delegation -s localhost -p $s1port -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n");print "MyProxy Test 31 (create proxy from stored credential on slave): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 32#($exitstatus, $output) = &runtest("myproxy-retrieve -s localhost -p $s2port -c /tmp/myproxy-test-cert.$$ -y /tmp/myproxy-test-key.$$ -v -S", $passphrase . "\n");print "MyProxy Test 32 (retrieve stored credential from slave): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}unlink( "/tmp/myproxy-test.cert.$$" );unlink( "/tmp/myproxy-test.key.$$" );## Test 33#($exitstatus, $output) = &runtest("myproxy-destroy -s localhost -p $mport -v", undef);print "MyProxy Test 33 (remove credential from master repository): ";if ($exitstatus == 0 && $output =~ /was successfully removed/) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}## Test 34#($exitstatus, $output) = &runtest("myproxy-info -v", undef);print "MyProxy Test 34 (verify credentials are removed from master): ";if (!($output =~ /default credential/)) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}#### Test 35##($exitstatus, $output) = &runtest("myproxy-replicate -c /tmp/myproxy-test.serverconf.$mport.master.$$ -r /tmp/myproxy-test.serverdir.$mport.master.$$", undef);print "MyProxy Test 35 (Replicate to all slaves): ";if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}#### Test 36##($exitstatus, $output) = &runtest("myproxy-get-delegation -s localhost -p $s3port -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n");print "MyProxy Test 36 (verify destroy has been replicated to slaves): ";if ($exitstatus != 0 && $output =~ /Credentials do not exist/) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$");}if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++;} else { print "FAILED\n"; $FAILURES++; print STDERR $output;}end_of_store_tests:&runtest("myproxy-destroy -v -k 'mine' -d", undef);&runtest("myproxy-destroy -v -k 'nobody' -d", undef);`rm -f /tmp/myproxy-test.*.12.*.$$`;unlink("/tmp/myproxy-test.$$.key");# Back to unencrypted private key for CoG tests$ENV{'X509_USER_KEY'} = $ENV{'X509_USER_PROXY'};## END TESTS#&docleanup();print "MyProxy Tests Complete: ", $SUCCESSES, " tests passed, ";print $FAILURES, " tests failed\n";exit $FAILURES;## SUBROUTINES#sub runtest { local($command, $input) = @_; $pid = open3(*Writer, *Reader, 0, "exec $command") || die "failed to run $command"; print Writer $input if (defined($input)); close(Writer); @output = <Reader>; close(Reader); waitpid($pid, 0); $exitstatus = $?; $output = join('', @output); return ($exitstatus, $output);}## verify_proxy## Check to see if user has a valid proxy, and verify proxy is usable## Dependencies: (-x grid-proxy-info)## grid-proxy-info -timeleft# die if no output, or output is less than 60 seconds# $proxy = grid-proxy-info -path# grid-proxy-init -debug -verify -cert $proxy -key $proxy# if $? == 0 then proxy is valid# if $? != 0, die, b/c proxy is invalid and won't work#sub verifyproxy { local($proxyfile) = @_; chomp (my $timeleft = `$grid_proxy_info -file $proxyfile -timeleft`); if (!defined($timeleft) || $timeleft eq "") { $output = "failed to verify proxy\n"; $output .= "'grid-proxy-info -timeleft' failed\n"; return (1, $output); } if ($timeleft < 1) { $output = "proxy is expired\n"; return (1, $output); } chomp (my $proxytype = `$grid_proxy_info -file $proxyfile -type`); local($oldproxy) = ""; if ($proxytype =~ /legacy/) { $oldproxy = "-old"; } local($output) = '$grid_proxy_init $oldproxy -debug -verify -cert $proxyfile -key $proxyfile -valid 0:1 -out /tmp/tmpproxy.$$'; if ($? != 0) { $output = "failed to verify proxy\n" . $output; unlink("/tmp/tmpproxy.$$"); return (1, $output); } # remove the new proxy we created for validation # NOTE: this does not affect the user's original proxy in any way unlink("/tmp/tmpproxy.$$"); return (0, "");}## verifycert## Check to see if user has a valid usable certificate## Dependencies: (-x grid-proxy-int)## grid-proxy-init -debug -verify -cert $certfile -key $keyfile# if $? == 0 then proxy is valid# if $? != 0, die, b/c proxy is invalid and won't work#sub verifycert { local($certfile, $keyfile) = @_; local($output) = '$grid_proxy_init $oldproxy -debug -verify -cert $certfile -key $keyfile -valid 0:1 -out /tmp/tmpproxy.$$'; if ($? != 0) { $output = "failed to verify certificate from: $certfile and $keyfile\n" . $output; unlink("/tmp/tmpproxy.$$"); return (1, $output); } # remove the new proxy we created for validation # NOTE: this does not affect the user's original proxy in any way unlink("/tmp/tmpproxy.$$"); return (0, "");}sub debug { print STDERR join('', @_), "\n" if ($verbose);}sub docleanup { unlink("/tmp/myproxy-test.$$"); unlink("/tmp/myproxy-test-cert.$$"); unlink("/tmp/myproxy-test-key.$$"); # Kill off servers... kill('TERM', $masterpid) if (defined($masterpid)); kill('TERM', $sl1pid) if (defined($sl1pid)); kill('TERM', $sl2pid) if (defined($sl2pid)); kill('TERM', $sl3pid) if (defined($sl3pid)); # Get rid of pid files... unlink($masterpidfile) if (defined($masterpidfile)); unlink($sl1pidfile) if (defined($sl1pidfile)); unlink($sl2pidfile) if (defined($sl2pidfile)); unlink($sl3pidfile) if (defined($sl3pidfile)); # Remove configuration files... unlink($masterconf) if (defined($masterconf)); unlink($slconf) if (defined($slconf)); # Get rid of left over creds and dirs... `rm -rf $masterdir` if (defined($masterdir)); `rm -rf $sl1dir` if (defined($sl1dir)); `rm -rf $sl2dir` if (defined($sl2dir)); `rm -rf $sl3dir` if (defined($sl3dir));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -