#!/usr/local/bin/perl # -*-Fundamental-*- # # Copyright (c) 1996 Network Appliance, Inc. # # You may distribute under the terms of the Artistic License, as # specified in the README file included in the ttt distribution. # # $Id: //depot/tools/main/p4bench/p4bench#3 $ use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); my $t0; #my @t0; sub mark_time { my($msg, $init) = @_; if ($init eq "start") { &ttt_msg("mark_st", "$msg\n"); $t0 = [gettimeofday]; # @t0 = times; return; } $e = tv_interval ($t0); my @t1 = times; # my $u = $t1[2]-$t0[2]; # my $s = $t1[2]-$t0[2]; my $times = sprintf"%8.2f seconds", $e; &ttt_msg("mark_tm", "$times : $msg\n"); $t0 = [gettimeofday]; @t0 = @t1; } sub opts { &ttt_add_opt("cli_env", "^", "/usr/bin/env", "path to \\\"env\\\" on the client host"); &ttt_add_opt("user", "^", "$user", "user to run as"); &ttt_add_opt("srv_host", "[a-z-]+", "localhost", "host to run p4 server on"); &ttt_add_opt("srv_port", "[9-0]+", "1680", "port to run p4 server on"); &ttt_add_opt("cli_host", "[a-z-]+", "localhost", "host to run p4 clients on"); &ttt_add_opt("p4bench_db", ".*", "", "pathname for canned $P4ROOT"); &ttt_add_opt("xp_setup", "", 0, "whether we are setting up for xp $P4ROOT"); &ttt_add_opt("p4bench_root", ".*", "/u/rmg/p4bench_root", "pathname for $P4ROOT"); &ttt_add_opt("p4bench_cli", ".*", "/u/rmg/p4bench_cli", "dir tol hole client workspaces"); &ttt_add_opt("journal", ".*", "journal", "where to write the journal"); &ttt_add_opt("p4d", ".*", "/u/p4/dist/r00.2/bin.osf/p4d", "p4d to run"); &ttt_add_opt("p4", ".*", "/u/p4/dist/r00.2/bin.osf/p4", "p4 to run"); &ttt_add_opt("cli_1_tar", ".*", "", "test data files tar archive"); &ttt_add_opt("genfiles", ".*", "", "genfiles width & depth"); } sub prereqchk { 1; } ##### Begin ttt standard preamble - do not change this code! ##### $UNIX = 1; sub dirname { local($dir) = @_; $dir =~ s%^$%.%; $dir = "$dir/"; if ($dir =~ m"^/[^/]*//*$") { return "/"; } if ($dir =~ m"^.*[^/]//*[^/][^/]*//*$") { $dir =~ s"^(.*[^/])//*[^/][^/]*//*$"$1"; { return $dir; } } #" [for cpp] return "."; } $ttt_here = `/bin/pwd`; chop $ttt_here; chdir &dirname($0); $tttroot = `/bin/pwd`; chop $tttroot; chdir $ttt_here; require "$tttroot/tttLib.pl"; ##### End ttt standard preamble - do not change the above code! ##### if ($xp_setup) { &ttt_rexec($srv_host, "uname -a && rm -rf $p4bench_root && rm -rf $p4bench_db"); $xp = 0; } if ($p4bench_db && -d $p4bench_db) { &ttt_rexec($srv_host, "uname -a && rm -rf $p4bench_root && cp -rp $p4bench_db $p4bench_root"); $xp = 1; } else { &ttt_rexec($srv_host, "uname -a && rm -rf $p4bench_root && mkdir $p4bench_root"); $xp = 0; } if ($journal ne "journal") { &ttt_rexec($srv_host, "rm -f $journal"); } &ttt_rexec($cli_host, "uname -a && mkdir -p $p4bench_cli"); #===== record configuration information for posterity &ttt_msg("config", "srv_host $srv_host\n"); &ttt_msg("config", "cli_host $cli_host\n"); &ttt_msg("config", "p4bench_root $p4bench_root\n"); &ttt_msg("config", "p4bench_db $p4bench_db\n"); &ttt_msg("config", "xp_setup $xp_setup\n"); &ttt_msg("config", "journal $journal\n"); &ttt_msg("config", "cli_1_tar $cli_1_tar\n"); &ttt_msg("config", "genfiles $genfiles\n"); $igrep = "grep -v \\^info:"; #===== initialize a Perforce server $p4d_id = &ttt_start_agent($srv_host, "$p4d -r $p4bench_root -p $srv_port -J $journal -L log", 1, $user); $rbits_p4d = $agents{$p4d_id, "STDOUTt"} | $agents{$p4d_id, "STDERRt"}; &ttt_int_agent($p4d_id, $rbits_p4d, "", "Perforce Server starting..."); # Seems to be necessary so the first client op doesn't try to barge # in before the server is really fully initialized! # sleep 10; &ttt_rexec($cli_host, "$p4 -p $srv_host:$srv_port info && $p4 -p $srv_host:$srv_port clients"); $p4_c1 = "$p4 -p $srv_host:$srv_port -c cli_1"; if (! $xp) { #===== submit from first client # &ttt_rexec($cli_host, "mkdir $p4bench_cli/cli_1"); &ttt_rexec($cli_host, "cd $p4bench_cli/cli_1 && ". "$p4_c1 client -o | sed -e '/\\/\\/depot\\/.../s/\\.\\.\\./dir1\\/main\\/.../' | ". " $p4_c1 client -i"); &mark_time("initial_add", "start"); if ($cli_1_tar) { &ttt_rexec($cli_host, "cd $p4bench_cli/cli_1 && tar xf $cli_1_tar && ". "find . -type f -print | $p4_c1 -x - add"); } if ($genfiles) { my $gfdash = $genfiles; $gfdash =~ s/ +/-/g; &ttt_rprog($cli_host, "genfiles", "$p4bench_cli/cli_1/files $genfiles"); &ttt_rexec($cli_host, "cd $p4bench_cli/cli_1 && find $p4bench_cli/cli_1/files_$gfdash -type f -print | $p4_c1 -s -x - add | $igrep"); } &mark_time("initial_add"); &ttt_rexec($cli_host, "cd $p4bench_cli/cli_1 && $cli_env P4EDITOR='/u/rmg/bin/p4submit changes' $p4_c1 -s submit | $igrep "); &mark_time("submit"); } if (! $xp_setup) { &ttt_rexec($cli_host, "$p4_c1 have | wc"); &mark_time("client_delete", "start"); &ttt_rexec($cli_host, "$p4_c1 client -d cli_1"); &mark_time("client-delete"); } #===== sync second client # $p4_c2 = "$p4 -p $srv_host:$srv_port -c cli_2"; &ttt_rexec($cli_host, "mkdir $p4bench_cli/cli_2"); &ttt_rexec($cli_host, "cd $p4bench_cli/cli_2 && ". "$p4_c2 client -o | sed -e '/\\/\\/depot\\/.../s/\\.\\.\\./dir1\\/main\\/.../' | ". " $p4_c2 client -i"); #&mark_time("new_sync", "start"); # #&ttt_rexec($cli_host, "cd $p4bench_cli/cli_2 && $p4_c2 -s sync | $igrep"); # #&mark_time("new_sync"); # #&ttt_rexec($cli_host, "cd $p4bench_cli/cli_2 && $p4_c2 -s files ... | $igrep"); # ##===== flush first client to ...#none ## #&mark_time("flush_to_#none", "start"); # #&ttt_rexec($cli_host, "cd $p4bench_cli/cli_1 && $cli_env $p4_c1 -s flush ...#none | $igrep"); # #&mark_time("flush_to_#none"); # ##===== ...and now back to the head revs... ## # #&ttt_rexec($cli_host, "cd $p4bench_cli/cli_1 && $cli_env $p4_c1 -s flush ... | $igrep"); # #&mark_time("flush_to_head"); # #===== shutdown & cleanup # &ttt_rexec($cli_host, "$p4_c2 admin checkpoint"); &ttt_rexec($cli_host, "$p4_c2 admin stop"); &ttt_read_agents($rbits_p4d, $timeo); $status = &ttt_close_agent($p4d_id); &ttt_msg($p4d_id, "exit status = $status\n"); if ($xp_setup) { &ttt_rexec($srv_host, "mkdir -p $p4bench_db && cp -rp $p4bench_root/db.* $p4bench_db"); } &ttt_exit("notest"); #$rbits = ""; # #$cli_id = &ttt_start_agent($cli_host, "rm -rf $p4bench_cli", 1, $user); #$rbits = $rbits | $agents{$cli_id,"STDOUTt"} | $agents{$cli_id,"STDERRt"}; #$srv_id = &ttt_start_agent($srv_host, "rm -rf $p4bench_root", 1, $user); #$rbits = $rbits | $agents{$srv_id,"STDOUTt"} | $agents{$srv_id,"STDERRt"}; # #&ttt_read_agents($rbits, $timeo); # #$cli_status = &ttt_close_agent($cli_id); #$srv_status = &ttt_close_agent($srv_id); # #&ttt_msg($cli_id, "exit status = $cli_status\n"); #&ttt_msg($srv_id, "exit status = $srv_status\n");