📄 myproxy-test
字号:
&docogtests();} else { print "\$COG_INSTALL_PATH undefined. Skipping Java CoG tests.\n";}## END TESTS#end_of_all_tests:&docleanup();print "MyProxy Tests Complete: ", $SUCCESSES, " tests passed, ";print $FAILURES, " tests failed\n";if (defined($valgrind)) { `cat /tmp/valgrind.log.$$* > valgrind.log.$$`; `rm -f /tmp/valgrind.log.$$*`; if (-s "valgrind.log.$$") { print "Valgrind errors in valgrind.log.$$.\n"; $FAILURES++; } else { print "Valgrind found no errors.\n"; unlink("valgrind.log.$$"); }}exit $FAILURES;## SUBROUTINES#sub runtest { local($command, $input) = @_; $command = $valgrind . $command if (defined($valgrind)); print STDERR "running: ", $command, "\n" if ($verbose); $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);}sub docogtests { $cogmyproxy = "$ENV{COG_INSTALL_PATH}/bin/myproxy -h $ENV{MYPROXY_SERVER}"; if (defined($ENV{"MYPROXY_SERVER_DN"})) { $cogmyproxy .= " -s \"$ENV{MYPROXY_SERVER_DN}\""; } if (defined($ENV{"MYPROXY_SERVER_PORT"})) { $cogmyproxy .= " -p $ENV{MYPROXY_SERVER_PORT}"; } $cogmyproxy .= " -l $ENV{'LOGNAME'}"; $ENV{"COG_OPTS"} = " -DX509_USER_PROXY=$ENV{X509_USER_PROXY}" . " -DX509_USER_CERT=$ENV{X509_USER_CERT}" . " -DX509_USER_KEY=$ENV{X509_USER_KEY}"; ($exitstatus, $output) = &runtest("myproxy-init -v -a -c 1 -t 1 -S", $passphrase . "\n"); print "MyProxy CoG Test 1 (anonget of myproxy-init credential): "; if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("$cogmyproxy anonget -o /tmp/myproxy-test.$$", $passphrase . "\n"); } if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$"); } if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR $output; } ($exitstatus, $output) = &runtest("myproxy-init -v -a -c 1 -t 1 -S", $passphrase . "\n"); print "MyProxy CoG Test 2 (get of myproxy-init credential): "; if ($exitstatus == 0) { ($exitstatus, $output) = &runtest("$cogmyproxy get -o /tmp/myproxy-test.$$", $passphrase . "\n"); } if ($exitstatus == 0) { ($exitstatus, $output) = &verifyproxy("/tmp/myproxy-test.$$"); } if ($exitstatus == 0) { print "SUCCEEDED\n"; $SUCCESSES++; } else { print "FAILED\n"; $FAILURES++; print STDERR $output; }# This test is disabled for now, pending new Java CoG release# with certificate chain support:# (http://bugzilla.globus.org/globus/show_bug.cgi?id=1914)## ($exitstatus, $output) =# &runtest("$cogmyproxy put -a -c 1 -t 1",# $passphrase . "\n");# print "MyProxy CoG Test 3 (store credential with default name): ";# if ($exitstatus == 0) {# print "SUCCEEDED\n"; $SUCCESSES++;# } else {# print "FAILED\n"; $FAILURES++; print STDERR $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, "");}## verifytrustroots## Check to see that trustroots were properly installed in# ~/.globus/certificates, then remove that directory.#sub verifytrustroots { return (1, "internal error: not supposed to test trustroots!") if (!$test_trustroots); $trustrootdir = "$ENV{HOME}/.globus/certificates"; if (!(-d $trustrootdir)) { return (1, "trust root directory $trustrootdir doesn't exist!"); } $diritems = 0; opendir(DIRHANDLE, $trustrootdir) or die "couldn't open $trustrootdir : $!"; while (defined($filename = readdir(DIRHANDLE))) { next if $filename =~ /^\.\.?$/; # skip . and .. $diritems++; } closedir(DIRHANDLE); if ($diritems == 0) { rmdir($trustrootdir); return (1, "trust root directory $trustrootdir is empty!"); } `rm -rf $trustrootdir`; return (0, "");}sub debug { print STDERR join('', @_), "\n" if ($verbose);}sub docleanup { unlink("/tmp/myproxy-test.$$"); kill('TERM', $serverpid) if (defined($serverpid)); unlink($SERVERPIDFILE) if (defined($SERVERPIDFILE)); unlink($serverconf) if (defined($serverconf)); `rm -rf $serverdir` if (defined($serverdir));}sub doperftests { &doinitperftest(); &dogetdelegperftest(); &doinfoperftest(); &docpperftest(); &dodbperftest() if ($dbperformance); &docleanup();}sub doinitperftest { $starttime = time(); $i = $perfclients; while ($i--) { $pid = fork(); last if ($pid == 0); } if ($pid == 0) { $i = $perfiters; while ($i--) { ($exitstatus, $output) = &runtest("myproxy-init -v -a -c 1 -t 1 -S -k $$", $passphrase . "\n"); if ($exitstatus != 0) { print "$$: myproxy-init FAILED with $i iters to go.\n"; print STDERR $output; exit($exitstatus>>8); } } &runtest("myproxy-destroy -v -k $$", undef); &debug("$$ is done."); exit 0; } $i = $perfclients; while ($i--) { wait(); if ($?) { printf "child failed. aborting.\n"; &docleanup(); exit 1; } } $endtime = time(); print $perfiters*$perfclients, " myproxy-inits in "; print $endtime-$starttime, " seconds.\n";}sub dogetdelegperftest { ($exitstatus, $output) = &runtest("myproxy-init -v -a -c 1 -t 1 -S", $passphrase . "\n"); if ($exitstatus != 0) { print "myproxy-init failed\n"; print STDERR $output; exit($exitstatus>>8); } $starttime = time(); $i = $perfclients; while ($i--) { $pid = fork(); last if ($pid == 0); } if ($pid == 0) { $i = $perfiters; while ($i--) { ($exitstatus, $output) = &runtest("myproxy-get-delegation -t 1 -o /tmp/myproxy-test.$$ -v -S", $passphrase . "\n"); if ($exitstatus != 0) { print "$$: myproxy-get-delegation FAILED with $i iters to go.\n"; print STDERR $output; exit($exitstatus>>8); } } unlink("/tmp/myproxy-test.$$"); &debug("$$ is done."); exit 0; } $i = $perfclients; while ($i--) { wait(); if ($?) { printf "child failed. aborting.\n"; &docleanup(); exit 1; } } $endtime = time(); print $perfiters*$perfclients, " myproxy-get-delegations in "; print $endtime-$starttime, " seconds.\n"; &runtest("myproxy-destroy -v", undef);}sub doinfoperftest { ($exitstatus, $output) = &runtest("myproxy-init -v -a -c 1 -t 1 -S", $passphrase . "\n"); if ($exitstatus != 0) { print "myproxy-init failed\n"; print STDERR $output; exit($exitstatus>>8); } $starttime = time(); $i = $perfclients; while ($i--) { $pid = fork(); last if ($pid == 0); } if ($pid == 0) { $i = $perfiters; while ($i--) { ($exitstatus, $output) = &runtest("myproxy-info -v", undef); if ($exitstatus != 0) { print "$$: myproxy-info FAILED with $i iters to go.\n"; print STDERR $output; exit($exitstatus>>8); } } &debug("$$ is done."); exit 0; } $i = $perfclients; while ($i--) { wait(); if ($?) { printf "child failed. aborting.\n"; &docleanup(); exit 1; } } $endtime = time(); print $perfiters*$perfclients, " myproxy-infos in "; print $endtime-$starttime, " seconds.\n"; &runtest("myproxy-destroy -v", undef);}sub docpperftest { $starttime = time(); $i = $perfclients; while ($i--) { $pid = fork(); last if ($pid == 0); } if ($pid == 0) { ($exitstatus, $output) = &runtest("myproxy-init -v -a -c 1 -t 1 -S -k $$", $passphrase . "\n"); if ($exitstatus != 0) { print "$$: myproxy-init FAILED with $i iters to go.\n"; print STDERR $output; exit($exitstatus>>8); } $i = $perfiters; while ($i--) { $old_passphrase = $passphrase; $passphrase = sprintf "%010.d", int(rand(0x7fffffff)); ($exitstatus, $output) = &runtest("myproxy-change-pass-phrase -v -S -k $$", "$old_passphrase\n$passphrase\n"); if ($exitstatus != 0) { print "$$: myproxy-change-pass-phrase FAILED with $i iters to go.\n"; print STDERR $output; exit($exitstatus>>8); } } &runtest("myproxy-destroy -v -k $$", undef); &debug("$$ is done."); exit 0; } $i = $perfclients; while ($i--) { wait(); if ($?) { printf "child failed. aborting.\n"; &docleanup(); exit 1; } } $endtime = time(); print $perfiters*$perfclients, " myproxy-change-pass-phrases in "; print $endtime-$starttime, " seconds.\n";}sub dodbperftest { foreach $dbsize (10,100,1000,10000) { $i = $dbsize; while ($i--) { ($exitstatus, $output) = &runtest("myproxy-admin-load-credential -v -d -l $i" . " -c $ENV{X509_USER_CERT} -y $ENV{X509_USER_KEY}" . (defined($serverdir) ? " -s $serverdir" : ""), undef); if ($exitstatus != 0) { print "myproxy-admin-load-credential FAILED.\n"; print STDERR $output; exit($exitstatus>>8); } } $starttime = time(); $i = $dbsize; while ($i--) { ($exitstatus, $output) = &runtest("myproxy-info -v -l $i", undef); if ($exitstatus != 0) { print "myproxy-info FAILED.\n"; print STDERR $output; exit($exitstatus>>8); } } $endtime = time(); print $dbsize, " myproxy-infos in ", $endtime-$starttime, " seconds.\n"; $starttime = $endtime; $i = $dbsize; while ($i--) { ($exitstatus, $output) = &runtest("myproxy-destroy -v -l $i", undef); if ($exitstatus != 0) { print "myproxy-destroy FAILED.\n"; print STDERR $output; exit($exitstatus>>8); } } $endtime = time(); print $dbsize, " myproxy-destroys in "; print $endtime-$starttime, " seconds.\n"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -