1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 ###############################################################################
8 use lib
"$ENV{ACE_ROOT}/bin";
9 use PerlACE
::TestTarget
;
20 my $imr = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
21 my $act = PerlACE
::TestTarget
::create_target
(2) || die "Create target 2 failed\n";
22 my $ti = PerlACE
::TestTarget
::create_target
(3) || die "Create target 3 failed\n";
23 my $srv = PerlACE
::TestTarget
::create_target
(4) || die "Create target 4 failed\n";
24 my $cli = PerlACE
::TestTarget
::create_target
(5) || die "Create target 5 failed\n";
26 my $refstyle = " -ORBobjrefstyle URL";
27 my $servers_count = 1;
29 my $use_activator = 0;
32 my $objprefix = "TstObj";
33 my $client_wait_time = 10;
35 $imriorfile = "imr_locator.ior";
36 $actiorfile = "imr_activator.ior";
37 $persistxml = "persist.xml";
38 $persistdat = "persist.dat";
40 my $imr_imriorfile = $imr->LocalFile ($imriorfile);
41 my $act_imriorfile = $act->LocalFile ($imriorfile);
42 my $ti_imriorfile = $ti->LocalFile ($imriorfile);
43 my $srv_imriorfile = $srv->LocalFile ($imriorfile);
44 my $act_actiorfile = $act->LocalFile ($actiorfile);
45 my $imr_persistxml = $imr->LocalFile ($persistxml);
46 my $imr_persistdat = $imr->LocalFile ($persistdat);
48 $IMR = $imr->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_locator");
49 $ACT = $act->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_activator");
50 $TI = $ti->CreateProcess ("$ENV{ACE_ROOT}/bin/tao_imr");
51 $SRV = $srv->CreateProcess ("server");
52 $CLI = $cli->CreateProcess ("client");
54 my $server_cmd = $SRV->Executable();
55 my $srv_server_cmd = $imr->LocalFile ($server_cmd);
57 # Make sure the files are gone, so we can wait on them.
58 $imr->DeleteFile ($imriorfile);
59 $act->DeleteFile ($imriorfile);
60 $ti->DeleteFile ($imriorfile);
61 $srv->DeleteFile ($imriorfile);
62 $act->DeleteFile ($actiorfile);
63 $imr->DeleteFile ($persistxml);
64 $imr->DeleteFile ($persistdat);
68 print "Running scale test with $servers_count servers and $obj_count objects.\n";
71 my $start_time = time();
73 $IMR->Arguments ("-d 1 -o $imr_imriorfile -orbendpoint iiop://:$port");
74 $IMR_status = $IMR->Spawn ();
75 if ($IMR_status != 0) {
76 print STDERR
"ERROR: ImplRepo Service returned $IMR_status\n";
79 if ($imr->WaitForFileTimed ($imriorfile,$imr->ProcessStartWaitInterval()) == -1) {
80 print STDERR
"ERROR: cannot find file <$imr_imriorfile>\n";
81 $IMR->Kill (); $IMR->TimedWait (1);
84 if ($imr->GetFile ($imriorfile) == -1) {
85 print STDERR
"ERROR: cannot retrieve file <$imr_imriorfile>\n";
86 $IMR->Kill (); $IMR->TimedWait (1);
89 if ($act->PutFile ($imriorfile) == -1) {
90 print STDERR
"ERROR: cannot set file <$act_imriorfile>\n";
91 $IMR->Kill (); $IMR->TimedWait (1);
94 if ($ti->PutFile ($imriorfile) == -1) {
95 print STDERR
"ERROR: cannot set file <$ti_imriorfile>\n";
96 $IMR->Kill (); $IMR->TimedWait (1);
99 if ($srv->PutFile ($imriorfile) == -1) {
100 print STDERR
"ERROR: cannot set file <$srv_imriorfile>\n";
101 $IMR->Kill (); $IMR->TimedWait (1);
105 if ($use_activator) {
107 $ACT->Arguments ("-d 1 -o $act_actiorfile -ORBInitRef ImplRepoService=file://$act_imriorfile");
108 $ACT_status = $ACT->Spawn ();
109 if ($ACT_status != 0) {
110 print STDERR
"ERROR: ImR Activator returned $ACT_status\n";
113 if ($act->WaitForFileTimed ($actiorfile,$act->ProcessStartWaitInterval()) == -1) {
114 print STDERR
"ERROR: cannot find file <$act_imriorfile>\n";
115 $ACT->Kill (); $ACT->TimedWait (1);
116 $IMR->Kill (); $IMR->TimedWait (1);
120 for(my $i = 0; $i < $servers_count; $i++) {
121 for (my $j = 0; $j < $obj_count; $j++) {
122 $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ".
123 "add $objprefix" . '_' . $i . "_" . $j . " -c \"".
125 " -ORBUseIMR 1 -p $objprefix" . '_' . "$i -c $obj_count ".
126 "-ORBInitRef ImplRepoService=file://$imr_imriorfile\"");
128 $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval());
129 if ($TI_status != 0) {
130 print STDERR
"ERROR: tao_imr returned $TI_status\n";
131 $ACT->Kill (); $ACT->TimedWait (1);
132 $IMR->Kill (); $IMR->TimedWait (1);
138 $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile list");
139 $result = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval());
140 if ($TI_status != 0) {
141 print STDERR
"ERROR: tao_imr returned $TI_status\n";
142 $ACT->Kill (); $ACT->TimedWait (1);
143 $IMR->Kill (); $IMR->TimedWait (1);
148 for(my $i = 0; $i < $servers_count; $i++ ) {
150 my $startfile = $objprefix . "_$i.status";
151 my $srv_startfile = $srv->LocalFile ($startfile);
152 $srv->DeleteFile ($objprefix . "_$i.status");
154 if (! $use_activator) {
155 $SRV->Arguments ("-ORBUseIMR 1 -p $objprefix" . '_' . "$i -c $obj_count -ORBInitRef ".
156 "ImplRepoService=file://$srv_imriorfile");
157 $SRV_status = $SRV->Spawn ();
158 if ($SRV_status != 0) {
159 print STDERR
"ERROR: server returned $SRV_status\n";
160 $SRV->Kill (); $SRV->TimedWait (1);
161 $ACT->Kill (); $ACT->TimedWait (1);
162 $IMR->Kill (); $IMR->TimedWait (1);
165 if ($srv->WaitForFileTimed ($startfile,$srv->ProcessStartWaitInterval()) == -1) {
166 print STDERR
"ERROR: cannot find file <$srv_startfile>\n";
167 $SRV->Kill (); $SRV->TimedWait (1);
168 $ACT->Kill (); $ACT->TimedWait (1);
169 $IMR->Kill (); $IMR->TimedWait (1);
173 # For some reason the servers take forever to spawn when using the activator
174 $client_wait_time *= $obj_count;
176 $srv->DeleteFile ($objprefix . "_$i.status");
178 for (my $j = 0; $j < $obj_count; $j++) {
179 $CLI->Arguments ("-orbinitref Test=corbaloc::localhost:$port/$objprefix" . '_' . $i . '_' . $j);
180 $CLI_status = $CLI->SpawnWaitKill ($client_wait_time);
181 if ($CLI_status != 0) {
182 print STDERR
"ERROR: client returned $CLI_status\n";
188 # Shutting down any server object within the server will shutdown the whole server
189 $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ".
190 "shutdown $objprefix" . '_' . $i . "_0");
191 $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval());
192 if ($TI_status != 0) {
193 print STDERR
"ERROR: tao_imr shutdown returned $TI_status\n";
197 if (! $use_activator) {
198 $SRV_status = $SRV->WaitKill($srv->ProcessStopWaitInterval());
199 if ($SRV_status != 0) {
200 print STDERR
"ERROR: server not shutdown correctly. It returned $SRV_status\n";
211 if ($use_activator) {
212 my $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval());
213 if ($ACT_status != 0) {
214 print STDERR
"ERROR: IMR Activator returned $ACT_status\n";
219 my $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval());
220 if ($IMR_status != 0) {
221 print STDERR
"ERROR: IMR returned $IMR_status\n";
225 my $test_time = time() - $start_time;
226 my $total_objs = $obj_count * $servers_count;
228 print "\nFinished. The test took $test_time seconds for $total_objs imr-ified objects.\n";
234 print "Usage: run_test.pl [-servers <num=1>] [-objects <num=1>] [-use_activator]\n";
237 ###############################################################################
238 ###############################################################################
241 for (my $i = 0; $i <= $#ARGV; $i++) {
242 if ($ARGV[$i] eq "-servers") {
244 $servers_count = $ARGV[$i];
246 elsif ($ARGV[$i] eq "-objects") {
248 $obj_count = $ARGV[$i];
250 elsif ($ARGV[$i] eq "-use_activator") {
260 my $ret = scale_test
();
262 $imr->DeleteFile ($imriorfile);
263 $act->DeleteFile ($imriorfile);
264 $ti->DeleteFile ($imriorfile);
265 $srv->DeleteFile ($imriorfile);
266 $act->DeleteFile ($actiorfile);
267 $imr->DeleteFile ($persistxml);
268 $imr->DeleteFile ($persistdat);