summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/DevGuideExamples/ImplRepo/run_test.pl
blob: bed41037e938aa9f82d1cb59d8fd6b05feecb14b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# $Id$

eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;

$status = 0;
$debug_level = '0';

foreach $i (@ARGV) {
    if ($i eq '-debug') {
        $debug_level = '10';
    }
}

my $c1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
my $c2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
my $imr = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
my $act = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
my $ti = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
my $si = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
my $sdn = PerlACE::TestTarget::create_target (7) || die "Create target 7 failed\n";

my $implrepo_server = "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/ImplRepo_Service";
my $imr_activator = "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/ImR_Activator";
my $tao_imr = "$ENV{ACE_ROOT}/bin/tao_imr";

# The Tests
$implrepo_ior = "implrepo.ior";
$activator_ior = "activator.ior";
$messenger_ior = "Messenger.ior";

my $imr_imriorfile = $imr->LocalFile ($implrepo_ior);
my $act_imriorfile = $act->LocalFile ($implrepo_ior);
my $ti_imriorfile = $ti->LocalFile ($implrepo_ior);
my $si_imriorfile = $si->LocalFile ($implrepo_ior);
my $sdn_imriorfile = $sdn->LocalFile ($implrepo_ior);
my $act_actiorfile = $act->LocalFile ($activator_ior);
my $imr_srviorfile = $imr->LocalFile ($messenger_ior);
my $c1_srviorfile = $c1->LocalFile ($messenger_ior);
my $c2_srviorfile = $c2->LocalFile ($messenger_ior);
my $si_srviorfile = $si->LocalFile ($messenger_ior);

# Make sure the files are gone, so we can wait on them.
$imr->DeleteFile ($implrepo_ior);
$act->DeleteFile ($implrepo_ior);
$ti->DeleteFile ($implrepo_ior);
$si->DeleteFile ($implrepo_ior);
$sdn->DeleteFile ($implrepo_ior);
$act->DeleteFile ($activator_ior);
$imr->DeleteFile ($messenger_ior);
$c1->DeleteFile ($messenger_ior);
$c2->DeleteFile ($messenger_ior);
$si->DeleteFile ($messenger_ior);

# Note : We don't actually use SVR, but we need a way to get the 
#        path to the -ExeSubDir
$SVR = $imr->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level");
my $server = $SVR->Executable ();
my $srv_server = $imr->LocalFile ($server);

$IR = $imr->CreateProcess ($implrepo_server, "-d 1 ".
                                               "orbobjrefstyle url ".
                                               "-t 5 ".
                                               "-o $imr_imriorfile");
print ">>> " . $IR->CommandLine() . "\n";

$ACT = $act->CreateProcess ($imr_activator, "-d 1 ".
                                               "orbobjrefstyle url ".
                                               "-o $act_actiorfile ".
                                               "-ORBInitRef ImplRepoService=file://$act_imriorfile");

$TI = $ti->CreateProcess ($tao_imr, "-ORBInitRef ImplRepoService=file://$ti_imriorfile ".
                                               "add MessengerService ".
                                               "-c \"$srv_server -orbobjrefstyle url -ORBUseIMR 1 -ORBInitRef ImplRepoService=file://$imr_imriorfile\" ");



$SI = $si->CreateProcess ($tao_imr, "-ORBInitRef ImplRepoService=file://$si_imriorfile ".
                                               "ior MessengerService ".
                                               "-f $si_srviorfile ");

$C1 = $c1->CreateProcess ("MessengerClient", "-k file://$c1_srviorfile ");

$SDN = $sdn->CreateProcess ("$tao_imr", "-ORBInitRef ImplRepoService=file://$sdn_imriorfile ".
                                        "shutdown MessengerService");

$C2 = $c2->CreateProcess ("MessengerClient", "-k file://$c2_srviorfile ");


$IR_status = $IR->Spawn ();

if ($IR_status != 0) {
    print STDERR "ERROR: ImplRepo Service returned $IR_status\n";
    exit 1;
}

if ($imr->WaitForFileTimed ($implrepo_ior,$imr->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$imr_imriorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    exit 1;
}

if ($imr->GetFile ($implrepo_ior) == -1) {
    print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    exit 1;
}
if ($act->PutFile ($implrepo_ior) == -1) {
    print STDERR "ERROR: cannot set file <$act_imriorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    exit 1;
}
if ($ti->PutFile ($implrepo_ior) == -1) {
    print STDERR "ERROR: cannot set file <$ti_imriorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    exit 1;
}
if ($si->PutFile ($implrepo_ior) == -1) {
    print STDERR "ERROR: cannot set file <$si_imriorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    exit 1;
}
if ($sdn->PutFile ($implrepo_ior) == -1) {
    print STDERR "ERROR: cannot set file <$sdn_imriorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    exit 1;
}

print ">>> " . $ACT->CommandLine() . "\n";
$ACT_status = $ACT->Spawn ();

if ($ACT_status != 0) {
    print STDERR "ERROR: ImR_Activator returned $ACT_status\n";
    exit 1;
}

if ($act->WaitForFileTimed ($activator_ior,$act->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$act_actiorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}

print ">>> " . $TI->CommandLine() . "\n";
# We want the tao_imr executable to be found exactly in the path
# given, without being modified by the value of -ExeSubDir.
# So, we tell its Process object to ignore the setting of -ExeSubDir.

$TI->IgnoreExeSubDir (1);

## Note : Instead of using tao_imr to generate the ior, it's easy enough
## to just create one by hand. The ior is just a normal corbaloc ior with
## the poa_name of the server and ip address of the imr. 
## (ie corbaloc::localhost:8888/Messengerservice)
## Of course, to do this, you'd have to start the imr on port 8888.
## We use the "tao_imr ior" command, because we don't know which port was used.
$TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval());

if ($TI_status != 0) {
    print STDERR "ERROR: tao_imr returned $TI_status\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}

print ">>> " . $SI->CommandLine() . "\n";
$SI->IgnoreExeSubDir (1);


$SI_status = $SI->SpawnWaitKill ($si->ProcessStartWaitInterval());

if ($SI_status != 0) {
    print STDERR "ERROR: tao_imr returned $SI_status\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}

if ($si->WaitForFileTimed ($messenger_ior,$si->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$si_srviorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}

if ($si->GetFile ($messenger_ior) == -1) {
    print STDERR "ERROR: cannot retrieve file <$si_srviorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}
if ($c1->PutFile ($messenger_ior) == -1) {
    print STDERR "ERROR: cannot set file <$c1_srviorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}
if ($c2->PutFile ($messenger_ior) == -1) {
    print STDERR "ERROR: cannot set file <$c2_srviorfile>\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}


print ">>> " . $C1->CommandLine() . "\n";
$C1_status = $C1->SpawnWaitKill ($c1->ProcessStartWaitInterval());

if ($C1_status != 0) {
    print STDERR "ERROR: Client1 returned $C1_status\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}

$SDN->IgnoreExeSubDir (1);
$SDN_status = $SDN->SpawnWaitKill ($sdn->ProcessStartWaitInterval());

if ($SDN_status != 0) {
    print STDERR "ERROR: Shutdown returned $SDN_status\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}

$C2_status = $C2->SpawnWaitKill ($c2->ProcessStartWaitInterval());

if ($C2_status != 0) {
    print STDERR "ERROR: Client2 returned $C2_status\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}


$SDN_status = $SDN->SpawnWaitKill ($sdn->ProcessStartWaitInterval());

if ($SDN_status != 0) {
    print STDERR "ERROR: Shutdown returned $SDN_status\n";
    $IR->Kill (); $IR->TimedWait (1);
    $ACT->Kill (); $ACT->TimedWait (1);
    exit 1;
}


$IR_status = $IR->TerminateWaitKill ($imr->ProcessStopWaitInterval());

if ($IR_status != 0) {
    print STDERR "ERROR: ImplRepo Server returned $IR_status\n";
    $status = 1;
}

$ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval());

if ($ACT_status != 0) {
    print STDERR "ERROR: ImR_Activator returned $ACT_status\n";
    $status = 1;
}

$imr->DeleteFile ($implrepo_ior);
$act->DeleteFile ($implrepo_ior);
$ti->DeleteFile ($implrepo_ior);
$si->DeleteFile ($implrepo_ior);
$sdn->DeleteFile ($implrepo_ior);
$act->DeleteFile ($activator_ior);
$imr->DeleteFile ($messenger_ior);
$c1->DeleteFile ($messenger_ior);
$c2->DeleteFile ($messenger_ior);
$si->DeleteFile ($messenger_ior);

exit $status;