1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
8 # To test the FaultNotifier
10 # Command line options:
11 # --debug_build use exes from this directory
12 # if not specified use exes from ./release
13 # -v display test progress messages (repeating option increases verbosity
15 # Process being tested:
17 # implements FaultNotifier interface.
18 # Processes used in test:
20 # implements TestReplica interface.
21 # implements PullMonitorable.
23 # implements FaultDetectorFactory interface
24 # implements PullMonitorable interface
26 # client for TestReplica interface.
27 # client for PullMonitorable.
29 # Subscribes to Fault_Notfier
31 # Test Scenario (***Test: marks behavior being tested):
32 # Start two FT_Replicas
33 # FT_Replicas write TestReplica IORs (FR#1 and FR#2) to files
34 # Start the Fault_Detector
35 # Fault_Detector writes its IOR (FDF) to a file
36 # Start the Fault_Notifier
37 # Fault_Notifier writes its IOR (FN) to a file.
38 # Start the StubAnalyzer giving it IORS: FR#1, FR#2 FDF, FN
39 # StubAnalyzer calls FDF to create a FaultDetector
41 # StubAnalyzer subscribes to Fault_Notifier
42 # StubAnalyzer writes dummy message(READY) to a file.
44 # Start FT_Client giving it IORS: FR#1 and FR#2.
45 # FT_Client interacts with FR#1.
46 # FT_Client asks FR#1 to fault. It does so.
47 # FT_Client notices fault and switches to FR#2.
48 # FD#1 notices fault and notifies Fault_Notifier
50 # ***Test: Fault_Notifier forwards notification to StubAnalyzer
51 # StubAnalyzer prints notification.
52 # FT_Client interacts with FR#2.
53 # FT_Client asks FR#2 to shut down.
54 # FT_Client shuts down.
55 # FD#2 notices FR2 is gone, interprets this
56 # as a fault, and sends notification to Fault_Notifier
58 # ***Test: Fault_Notifier forwards notification to StubAnalyzer
59 # StubAnalyzer prints notification.
61 # All FaultDetectors have terminated so the FaultDetectorFactory
62 # honors the "quit-on-idle" option on it's command line and exits.
63 # StubAnalyzer compares # fault notifications to # replicas. When
64 # they match, it knows that the test is over, so it shuts down.
65 # As it does so, it disconnects its fault consumers from the FaultNotifier.
66 # FaultNotifier notices the last fault consumer disconnecting and exits because
67 # the "quit-on-idle" option was specified on the command line.
69 # Wait for all processes to terminate.
70 # Check termination status.
73 use lib
"$ENV{ACE_ROOT}/bin";
74 use PerlACE
::TestTarget
;
76 ########################
81 my($verbose) = 0; # 1: report perl actions before executing them
82 my($debug_builds) = 0; # 0: use exes from Release directories
83 my($simulated) = 1; # 1: use "client simulated" fault tolerance
86 # List of the proccess which must be killed before exit with error
91 @kill_list = (@kill_list, $goal);
95 foreach $goal (@kill_list){
96 $goal->Kill (); $goal->TimedWait (1);
102 if ($i eq "--debug_build"){
105 elsif ($i eq "--no_simulate"){ # reverse this once we have FT ORB support
114 my($build_directory) = "/Release";
115 if ( $debug_builds ) {
116 $build_directory = "";
120 print "verbose: $verbose\n";
121 print "debug_builds: $debug_builds -> $build_directory\n";
122 print "simulated: $simulated\n";
125 my $ft_replica1 = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
126 my $ft_replica2 = PerlACE
::TestTarget
::create_target
(2) || die "Create target 2 failed\n";
127 my $fault_detector = PerlACE
::TestTarget
::create_target
(3) || die "Create target 3 failed\n";
128 my $fault_notifier = PerlACE
::TestTarget
::create_target
(4) || die "Create target 4 failed\n";
129 my $fault_analyzer = PerlACE
::TestTarget
::create_target
(5) || die "Create target 5 failed\n";
130 my $client = PerlACE
::TestTarget
::create_target
(6) || die "Create target 6 failed\n";
134 my($factory1_ior) = "factory1.ior";
135 my($factory2_ior) = "factory2.ior";
136 my($replica1_ior) = "replica1.ior";
137 my($replica2_ior) = "replica2.ior";
138 my($detector_ior) = "detector.ior";
139 my($notifier_ior) = "notifier.ior";
140 my($client_data) = "persistent.dat";
141 my($ready_file) = "ready.file";
143 # Files for ft_replica1
144 my $ft_replica1_factory1_ior = $ft_replica1->LocalFile ($factory1_ior);
145 my $ft_replica1_replica1_ior = $ft_replica1->LocalFile ($replica1_ior);
146 my $ft_replica1_client_data = $ft_replica1->LocalFile ($client_data);
148 $ft_replica1->DeleteFile ($factory1_ior);
149 $ft_replica1->DeleteFile ($replica1_ior);
150 $ft_replica1->DeleteFile ($client_data);
152 # Files for ft_replica2
153 my $ft_replica2_factory2_ior = $ft_replica2->LocalFile ($factory2_ior);
154 my $ft_replica2_replica2_ior = $ft_replica2->LocalFile ($replica2_ior);
155 my $ft_replica2_client_data = $ft_replica2->LocalFile ($client_data);
157 $ft_replica2->DeleteFile ($factory2_ior);
158 $ft_replica2->DeleteFile ($replica2_ior);
159 $ft_replica2->DeleteFile ($client_data);
161 # Files for fault_detector
162 my $fault_detector_ior = $fault_detector->LocalFile ($detector_ior);
163 $fault_detector->DeleteFile ($detector_ior);
165 # Files for fault_notifier
166 my $fault_notifier_ior = $fault_notifier->LocalFile ($notifier_ior);
167 $fault_notifier->DeleteFile ($notifier_ior);
169 # Files for fault_analyzer
170 my $analyzer_replica1_ior = $fault_analyzer->LocalFile ($replica1_ior);
171 my $analyzer_replica2_ior = $fault_analyzer->LocalFile ($replica2_ior);
172 my $analyzer_notifier_ior = $fault_analyzer->LocalFile ($notifier_ior);
173 my $analyzer_detector_ior = $fault_analyzer->LocalFile ($detector_ior);
174 my $analyzer_ready_file = $fault_analyzer->LocalFile ($ready_file);
176 $fault_analyzer->DeleteFile ($replica1_ior);
177 $fault_analyzer->DeleteFile ($replica2_ior);
178 $fault_analyzer->DeleteFile ($notifier_ior);
179 $fault_analyzer->DeleteFile ($detector_ior);
180 $fault_analyzer->DeleteFile ($ready_file);
183 my $client_replica1_ior = $client->LocalFile ($replica1_ior);
184 my $client_replica2_ior = $client->LocalFile ($replica2_ior);
186 $client->DeleteFile ($replica1_ior);
187 $client->DeleteFile ($replica2_ior);
191 $REP1 = $ft_replica1->CreateProcess (".$build_directory/ft_replica" ,
192 "-o $ft_replica1_factory1_ior ".
193 "-f none -t $ft_replica1_replica1_ior " .
194 "-l loc1 -i type1 -q -p $ft_replica1_client_data");
196 $REP2 = $ft_replica2->CreateProcess (".$build_directory/ft_replica" ,
197 "-o $ft_replica2_factory2_ior ".
198 "-f none -t $ft_replica2_replica2_ior " .
199 "-l loc2 -i type1 -q -p $ft_replica2_client_data");
201 $DET = $fault_detector->CreateProcess ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Detector" .
202 "$build_directory/tao_fault_detector" ,
204 "-o $fault_detector_ior -q");
206 $NOT = $fault_notifier->CreateProcess ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Notifier" .
207 "$build_directory/tao_fault_notifier" ,
209 "-o $fault_notifier_ior -q");
211 $ANA = $fault_analyzer->CreateProcess (".$build_directory/ft_analyzer",
212 "-o $analyzer_ready_file " .
213 "-n file://$analyzer_notifier_ior " .
214 "-d file://$analyzer_detector_ior " .
215 "-r file://$analyzer_replica1_ior " .
216 "-r file://$analyzer_replica2_ior -q");
218 $CL = $client->CreateProcess (".$build_directory/ft_client",
219 "-f file://$client_replica1_ior " .
220 "-f file://$client_replica2_ior " .
225 print "\nTEST: starting replica1 " . $REP1->CommandLine . "\n" if ($verbose);
229 add_to_kills
($REP1);
231 print "TEST: waiting for replica 1's IOR\n" if ($verbose);
232 if ($ft_replica1->WaitForFileTimed ($replica1_ior,
233 $ft_replica1->ProcessStartWaitInterval()) == -1) {
234 print STDERR
"ERROR: cannot find file <$ft_replica1_replica1_ior>\n";
237 # Get/Put $replica1_ior: analyzer_replica1_ior $client_replica1_ior
238 if ($ft_replica1->GetFile ($replica1_ior) == -1) {
239 print STDERR
"ERROR: cannot retrieve file <$ft_replica1_replica1_ior>\n";
242 if ($fault_analyzer->PutFile ($replica1_ior) == -1) {
243 print STDERR
"ERROR: cannot set file <$analyzer_replica1_ior>\n";
246 if ($client->PutFile ($replica1_ior) == -1) {
247 print STDERR
"ERROR: cannot set file <$client_replica1_ior>\n";
253 print "\nTEST: starting replica2 " . $REP2->CommandLine . "\n" if ($verbose);
256 add_to_kills
($REP2);
258 print "TEST: waiting for replica 2's IOR\n" if ($verbose);
259 if ($ft_replica2->WaitForFileTimed ($replica2_ior,
260 $ft_replica2->ProcessStartWaitInterval()) == -1) {
261 print STDERR
"TEST ERROR: cannot find file <$ft_replica2_replica2_ior>\n";
265 # Get/Put $replica2_ior: analyzer_replica2_ior $client_replica2_ior
266 if ($ft_replica2->GetFile ($replica2_ior) == -1) {
267 print STDERR
"ERROR: cannot retrieve file <$ft_replica2_replica2_ior>\n";
270 if ($fault_analyzer->PutFile ($replica2_ior) == -1) {
271 print STDERR
"ERROR: cannot set file <$analyzer_replica2_ior>\n";
274 if ($client->PutFile ($replica2_ior) == -1) {
275 print STDERR
"ERROR: cannot set file <$client_replica2_ior>\n";
281 print "\nTEST: starting detector factory " . $DET->CommandLine . "\n" if ($verbose);
287 print "TEST: waiting for detector's IOR\n" if ($verbose);
288 if ($fault_detector->WaitForFileTimed ($detector_ior,
289 $fault_detector->ProcessStartWaitInterval()) == -1) {
290 print STDERR
"ERROR: cannot find file <$fault_detector_ior>\n";
294 # Get/Put $detector_ior: $analyzer_detector_ior
295 if ($fault_detector->GetFile ($detector_ior) == -1) {
296 print STDERR
"ERROR: cannot retrieve file <$fault_detector_ior>\n";
299 if ($fault_analyzer->PutFile ($detector_ior) == -1) {
300 print STDERR
"ERROR: cannot set file <$analyzer_detector_ior>\n";
306 print "\nTEST: starting notifier " . $NOT->CommandLine . "\n" if ($verbose);
311 print "TEST: waiting for notifier's IOR\n" if ($verbose);
312 if ($fault_notifier->WaitForFileTimed ($notifier_ior,
313 $fault_notifier->ProcessStartWaitInterval()) == -1) {
314 print STDERR
"ERROR: cannot find file <$fault_notifier_ior>\n";
317 # Get/Put $notifier_ior: $analyzer_notifier_ior
318 if ($fault_notifier->GetFile ($notifier_ior) == -1) {
319 print STDERR
"ERROR: cannot retrieve file <$fault_notifier_ior>\n";
322 if ($fault_analyzer->PutFile ($notifier_ior) == -1) {
323 print STDERR
"ERROR: cannot set file <$analyzer_notifier_ior>\n";
329 print "\nTEST: starting analyzer " . $ANA->CommandLine . "\n" if ($verbose);
334 print "TEST: waiting for READY.FILE from analyzer\n" if ($verbose);
336 if ($fault_analyzer->WaitForFileTimed ($ready_file,
337 $fault_analyzer->ProcessStartWaitInterval()) == -1) {
338 print STDERR
"TEST ERROR: cannot find file <$analyzer_ready_file>\n";
344 print "\nTEST: starting client " . $CL->CommandLine . "\n" if ($verbose);
346 $status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 45);
349 print STDERR
"TEST ERROR: client returned $status\n";
353 print "\nTEST: wait for replica 1.\n" if ($verbose);
355 $status = $REP1->WaitKill ($ft_replica1->ProcessStopWaitInterval());
357 print STDERR
"TEST ERROR: replica returned $status\n";
360 print "\nTEST: wait for replica 2.\n" if ($verbose);
362 $status = $REP2->WaitKill ($ft_replica2->ProcessStopWaitInterval());
364 print STDERR
"TEST ERROR: replica returned $status\n";
368 print "\nTEST: wait for detector factory to leave.\n" if ($verbose);
369 $status = $DET->WaitKill ($fault_detector->ProcessStopWaitInterval());
371 print STDERR
"TEST ERROR: detector returned $status\n";
375 print "\nTEST: wait for analyzer to leave.\n" if ($verbose);
376 $status = $ANA->WaitKill ($fault_analyzer->ProcessStopWaitInterval());
378 print STDERR
"TEST ERROR: analyzer returned $status\n";
382 print "\nTEST: wait for notifier to leave.\n" if ($verbose);
383 $status = $NOT->WaitKill ($fault_notifier->ProcessStopWaitInterval());
385 print STDERR
"TEST ERROR: notifier returned $status\n";
389 print "\nTEST: releasing scratch files.\n" if ($verbose);
391 # Files for ft_replica1
392 $ft_replica1->DeleteFile ($factory1_ior);
393 $ft_replica1->DeleteFile ($replica1_ior);
394 $ft_replica1->DeleteFile ($client_data);
396 # Files for ft_replica2
397 $ft_replica2->DeleteFile ($factory2_ior);
398 $ft_replica2->DeleteFile ($replica2_ior);
399 $ft_replica2->DeleteFile ($client_data);
401 # Files for fault_detector
402 $fault_detector->DeleteFile ($detector_ior);
404 # Files for fault_notifier
405 $fault_notifier->DeleteFile ($notifier_ior);
407 # Files for fault_analyzer
408 $fault_analyzer->DeleteFile ($replica1_ior);
409 $fault_analyzer->DeleteFile ($replica2_ior);
410 $fault_analyzer->DeleteFile ($notifier_ior);
411 $fault_analyzer->DeleteFile ($detector_ior);
412 $fault_analyzer->DeleteFile ($ready_file);
415 $client->DeleteFile ($replica1_ior);
416 $client->DeleteFile ($replica2_ior);