1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 use lib
"$ENV{ACE_ROOT}/bin";
8 use PerlACE
::TestTarget
;
12 $iorfname_prefix = "server";
14 $num_clients_per_servant=40;
18 $servant_cancellation_option="";
20 if ($ARGV[0] eq 'collocated') {
21 # 1 servant, 1 collocated client, 1 orb thread, 2 strategy working threads
22 $num_clients_per_servant=1;
26 elsif ($ARGV[0] eq 'multiple_servants') {
27 # multiple servants and single orb thread.
28 # 10 servant, 40 client, 1 orb thread, 10 strategy working threads
31 $num_clients_per_servant=4;
33 elsif ($ARGV[0] eq 'multiple_orb_threads') {
34 # multiple servants and multiple orb threads.
35 # 10 servant, 40 client, 4 orb thread, 10 strategy working threads
38 $num_clients_per_servant=4;
41 elsif ($ARGV[0] eq 'cancel_servant') {
42 # Cancel one servant and leave the other alive.
43 # 2 servant, 10 client, 5 orb thread, 1 strategy working threads
44 $num_clients_per_servant=5;
48 $servant_cancellation_option = " -d 1 ";
50 elsif ($ARGV[0] eq '') {
51 # default test - 1 servant, 40 clients , 1 orb thread, 1 csd thread
54 print STDERR
"ERROR: invalid parameter $ARGV[0] \n";
66 $num_clients = $num_servants * $num_clients_per_servant;
68 my $server = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
70 $SV = $server->CreateProcess("server_main",
71 "-p $iorfname_prefix -s $num_servants ".
72 "-c $num_clients -t $num_orb_threads -n $num_csd_threads ".
73 "-l $collocated_test $servant_cancellation_option");
76 for ($i = 0; $i < $num_clients; $i++) {
77 $clients[$i] = PerlACE
::TestTarget
::create_target
($i+1) || die "Create target $i+1 failed\n";
80 #Delete old ior files.
82 my @server_iorfiles = ();
83 for ($i = 0; $i < $num_servants; $i++) {
84 $servant_id = sprintf("%02d", ($i + 1));
85 $iorfiles[$i] = $iorfname_prefix . "_$servant_id.ior";
86 $server_iorfiles[$i] = $server->LocalFile($iorfiles[$i]);
87 $server->DeleteFile($iorfiles[$i]);
92 my @clients_iorfile = ();
94 for ($i = 0; $i < $num_servants; $i++) {
95 for ($j = 0; $j < $num_clients_per_servant; $j++) {
96 $clients_iorfile[$count] = $clients[$count]->LocalFile($iorfiles[$i]);
97 $clients[$count]->DeleteFile($iorfiles[$i]);
98 $CLS[$count] = $clients[$count]->CreateProcess ("client_main",
99 " -i file://$clients_iorfile[$count]");
104 $server_status = $SV->Spawn ();
106 if ($server_status != 0) {
107 print STDERR
"ERROR: server returned $server_status\n";
111 # Wait for the servant ior files created by server.
112 for ($i = 0; $i < $num_servants; $i++) {
113 if ($server->WaitForFileTimed ($iorfiles[$i],
114 $server->ProcessStartWaitInterval()) == -1) {
115 print STDERR
"ERROR: cannot find file <$server_iorfiles[$i]>\n";
116 $SV->Kill (); $SV->TimedWait (1);
121 for ($i = 0; $i < $num_servants; $i++) {
122 if ($server->GetFile ($iorfiles[$i]) == -1) {
123 print STDERR
"ERROR: cannot retrieve $i-th file <$server_iorfiles[$i]>\n";
124 $SV->Kill (); $SV->TimedWait (1);
130 for ($i = 0; $i < $num_servants; $i++) {
131 for ($j = 0; $j < $num_clients_per_servant; $j++) {
132 if ($clients[$count]->PutFile ($iorfiles[$i]) == -1) {
133 print STDERR
"ERROR: client $count cannot set file <$clients_iorfile[$count]>\n";
134 $SV->Kill (); $SV->TimedWait (1);
143 if ($collocated_test == 0) {
144 for ($i = 0; $i < $num_servants; $i++) {
145 for ($j = 0; $j < $num_clients_per_servant; $j++) {
146 my $client_status = $CLS[$count]->Spawn();
147 if ($client_status != 0) {
148 print STDERR
"ERROR: client $count Spawn returned $client_status\n";
155 for ($i = 0; $i < $num_clients; $i++) {
156 my $client_status = $CLS[$i]->WaitKill ($clients[$i]->ProcessStartWaitInterval() + 45);
158 if ($client_status != 0) {
159 print STDERR
"ERROR: client $i WaitKill returned $client_status\n";
165 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 45);
167 if ($server_status != 0) {
168 print STDERR
"ERROR: server returned $server_status\n";
173 #Delete ior files generated by this run.
174 for ($i = 0; $i < $num_servants; $i++) {
175 $server->DeleteFile($iorfiles[$i]);
179 for ($i = 0; $i < $num_servants; $i++) {
180 for ($j = 0; $j < $num_clients_per_servant; $j++) {
181 $clients[$count]->DeleteFile($iorfiles[$i]);