Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / examples / LoadBalancing / run_test.pl
blob8a86516e6c91d17cd110af8d87639e3d90d16967
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
7 use lib "$ENV{ACE_ROOT}/bin";
8 use PerlACE::TestTarget;
10 $status = 0;
11 $debug_level = '0';
13 foreach $i (@ARGV) {
14 if ($i eq '-debug') {
15 $debug_level = '10';
19 my $lm = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $ns = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
21 my $sv = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $sr = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 my $cl = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 my $cr = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
26 $srviorfile = "obj.ior";
27 $lmiorfile = "lm.ior";
28 $nsiorfile = "ns.ior";
30 my $lm_lmiorfile = $lm->LocalFile ($lmiorfile);
31 my $sv_lmiorfile = $sv->LocalFile ($lmiorfile);
32 my $sr_lmiorfile = $sr->LocalFile ($lmiorfile);
33 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
34 my $sv_nsiorfile = $sv->LocalFile ($nsiorfile);
35 my $sr_nsiorfile = $sr->LocalFile ($nsiorfile);
36 my $cl_nsiorfile = $cl->LocalFile ($nsiorfile);
37 my $cr_nsiorfile = $cr->LocalFile ($nsiorfile);
38 my $sv_srviorfile = $sv->LocalFile ($srviorfile);
39 my $cl_srviorfile = $cl->LocalFile ($srviorfile);
40 my $sr_srviorfile = $sr->LocalFile ($srviorfile);
41 my $cr_srviorfile = $cr->LocalFile ($srviorfile);
42 $lm->DeleteFile ($lmiorfile);
43 $sv->DeleteFile ($lmiorfile);
44 $sr->DeleteFile ($lmiorfile);
45 $ns->DeleteFile ($nsiorfile);
46 $sv->DeleteFile ($nsiorfile);
47 $sr->DeleteFile ($nsiorfile);
48 $cl->DeleteFile ($nsiorfile);
49 $cr->DeleteFile ($nsiorfile);
50 $sv->DeleteFile ($srviorfile);
51 $cl->DeleteFile ($srviorfile);
52 $sr->DeleteFile ($srviorfile);
53 $cr->DeleteFile ($srviorfile);
55 $LM = $lm->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/LoadBalancer/tao_loadmanager",
56 " -o $lm_lmiorfile");
57 $NS = $ns->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
58 " -o $ns_nsiorfile");
59 $SV = $sv->CreateProcess ("server",
60 "-o $sv_srviorfile ".
61 " -ORBInitRef LoadManager=file://$sv_lmiorfile ".
62 " -n 1 ".
63 "-ORBInitRef NameService=file://$sv_nsiorfile ".
64 " -s LeastLoaded ".
65 " -r 9000 -c 10300 -d 0.1 ");
66 $SR = $sr->CreateProcess ("server",
67 "-o $sr_srviorfile ".
68 "-ORBInitRef LoadManager=file://$sr_lmiorfile ".
69 " -n 2 ".
70 "-ORBInitRef NameService=file://sr_nsiorfile ".
71 " -s LeastLoaded ".
72 "-r 9000 -c 10300 -d 0.1 ");
73 $CL = $cl->CreateProcess ("client",
74 "-k file://$cl_srviorfile ".
75 " -i 5 -n 1 ".
76 "-ORBInitRef NameService=file://cl_nsiorfile ");
77 $CR = $cr->CreateProcess ("client",
78 "-k file://$cr_srviorfile ".
79 "-i 5 -n 2 ".
80 "-ORBInitRef NameService=file://cr_nsiorfile ");
82 $LM_status = $LM->Spawn ();
84 if ($LM_status != 0) {
85 print STDERR "ERROR: Load Manager returned $LM_status\n";
86 exit 1;
89 if ($lm->WaitForFileTimed ($lmiorfile,$lm->ProcessStartWaitInterval()) == -1) {
90 print STDERR "ERROR: cannot find file <$lm_lmiorfile>\n";
91 $LM->Kill (); $LM->TimedWait (1);
92 exit 1;
95 if ($lm->GetFile ($lmiorfile) == -1) {
96 print STDERR "ERROR: cannot retrieve file <$lm_lmiorfile>\n";
97 $LM->Kill (); $LM->TimedWait (1);
98 exit 1;
100 if ($sv->PutFile ($lmiorfile) == -1) {
101 print STDERR "ERROR: cannot set file <$sv_lmiorfile>\n";
102 $LM->Kill (); $LM->TimedWait (1);
103 exit 1;
105 if ($sr->PutFile ($lmiorfile) == -1) {
106 print STDERR "ERROR: cannot set file <$sr_lmiorfile>\n";
107 $LM->Kill (); $LM->TimedWait (1);
108 exit 1;
112 $NS_status = $NS->Spawn ();
114 if ($NS_status != 0) {
115 print STDERR "ERROR: Name Service returned $NS_status\n";
116 exit 1;
119 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
120 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
121 $NS->Kill (); $NS->TimedWait (1);
122 exit 1;
125 if ($ns->GetFile ($nsiorfile) == -1) {
126 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
127 $NS->Kill (); $NS->TimedWait (1);
128 exit 1;
130 if ($sv->PutFile ($nsiorfile) == -1) {
131 print STDERR "ERROR: cannot set file <$sv_nsiorfile>\n";
132 $NS->Kill (); $NS->TimedWait (1);
133 exit 1;
135 if ($sr->PutFile ($nsiorfile) == -1) {
136 print STDERR "ERROR: cannot set file <$sr_nsiorfile>\n";
137 $NS->Kill (); $NS->TimedWait (1);
138 exit 1;
140 if ($cl->PutFile ($nsiorfile) == -1) {
141 print STDERR "ERROR: cannot set file <$cl_nsiorfile>\n";
142 $NS->Kill (); $NS->TimedWait (1);
143 exit 1;
145 if ($cr->PutFile ($nsiorfile) == -1) {
146 print STDERR "ERROR: cannot set file <$cr_nsiorfile>\n";
147 $NS->Kill (); $NS->TimedWait (1);
148 exit 1;
152 $SV_status = $SV->Spawn ();
154 if ($SV_status != 0) {
155 print STDERR "ERROR: Server returned $SV_status\n";
156 exit 1;
159 if ($sv->WaitForFileTimed ($srviorfile,$sv->ProcessStartWaitInterval()) == -1) {
160 print STDERR "ERROR: cannot find file <$sv_srviorfile>\n";
161 $SV->Kill (); $SV->TimedWait (1);
162 exit 1;
165 if ($sv->GetFile ($srviorfile) == -1) {
166 print STDERR "ERROR: cannot retrieve file <$sv_srviorfile>\n";
167 $SV->Kill (); $SV->TimedWait (1);
168 exit 1;
170 if ($cl->PutFile ($srviorfile) == -1) {
171 print STDERR "ERROR: cannot set file <$cl_srviorfile>\n";
172 $SV->Kill (); $SV->TimedWait (1);
173 exit 1;
175 $sv->DeleteFile ($srviorfile);
177 $SR_status = $SR->Spawn ();
179 if ($SR_status != 0) {
180 print STDERR "ERROR: Server returned $SR_status\n";
181 exit 1;
184 if ($sr->WaitForFileTimed ($srviorfile,$sr->ProcessStartWaitInterval()) == -1) {
185 print STDERR "ERROR: cannot find file <$sr_srviorfile>\n";
186 $SR->Kill (); $SR->TimedWait (1);
187 exit 1;
190 if ($sr->GetFile ($srviorfile) == -1) {
191 print STDERR "ERROR: cannot retrieve file <$sr_srviorfile>\n";
192 $SR->Kill (); $SR->TimedWait (1);
193 exit 1;
195 if ($cr->PutFile ($srviorfile) == -1) {
196 print STDERR "ERROR: cannot set file <$cr_srviorfile>\n";
197 $SR->Kill (); $SR->TimedWait (1);
198 exit 1;
200 $sr->DeleteFile ($srviorfile);
203 $CL_status = $CL->SpawnWaitKill ($cl->ProcessStartWaitInterval()+85);
204 if ($CL_status != 0) {
205 print STDERR "ERROR: client returned $CL_status\n";
206 $status = 1;
209 $CR_status = $CR->SpawnWaitKill ($cr->ProcessStartWaitInterval()+85);
210 if ($CR_status != 0) {
211 print STDERR "ERROR: client returned $CR_status\n";
212 $status = 1;
215 $SV_status = $SV->WaitKill ($sv->ProcessStartWaitInterval());
216 if ($SV_status != 0) {
217 print STDERR "ERROR: server returned $SV_status\n";
218 $status = 1;
221 $LM_status = $LM->TerminateWaitKill ($lm->ProcessStopWaitInterval());
223 if ($LM_status != 0) {
224 print STDERR "ERROR: LoadManager returned $LM_status\n";
225 $status = 1;
228 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
230 if ($NS_status != 0) {
231 print STDERR "ERROR: Name Service returned $NS_status\n";
232 $status = 1;
235 $lm->DeleteFile ($lmiorfile);
236 $sv->DeleteFile ($lmiorfile);
237 $sr->DeleteFile ($lmiorfile);
238 $ns->DeleteFile ($nsiorfile);
239 $sv->DeleteFile ($nsiorfile);
240 $sr->DeleteFile ($nsiorfile);
241 $cl->DeleteFile ($nsiorfile);
242 $cr->DeleteFile ($nsiorfile);
243 $sv->DeleteFile ($srviorfile);
244 $cl->DeleteFile ($srviorfile);
245 $sr->DeleteFile ($srviorfile);
246 $cr->DeleteFile ($srviorfile);
248 exit $status;