summaryrefslogtreecommitdiff
path: root/orbsvcs/tests/Notify/Reconnecting/run_test.pl
blob: c480127704c35c4e4341fac526ad833a0cf9f01d (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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# -*- perl -*-

# ******************************************************************
# Pragma Section
# ******************************************************************

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 $nfs = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
my $sup = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
my $con = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";

$sup->AddLibPath ('../lib');
$con->AddLibPath ('../lib');


# ******************************************************************
# Data Section
# ******************************************************************

my $eventType = '-any'; # your choice of -any -structured or -sequence
my $notify_port = $nfs->RandomPort ();
my $notify_host = $nfs->HostName ();

my $st_topo = "ns_st_topo.conf";
my $st_both = "ns_st_both.conf";
# File used to detect notification service startup
$nfsiorfile = "notify.ior";
# Hard coded file name in Consumer.cpp (for now)
$conidsfile = "consumer.ids";
 # Hard coded file name in Supplier.cpp (for now)
$supidsfile = "supplier.ids";
# File used to communicate channel # from consumer to supplier
$channel_id = "channel_id";
# File used to save configuration for reconnect test
$save_xml = "reconnect_test.xml";
# File names comes from svc.conf (+.xml & .000)
$save_000 = "reconnect_test.000";
# File names comes from svc.conf (+.xml & .001)
$save_001 = "reconnect_test.001";
# Event persistent database file (from svc.conf)
$eventpersist = "event_persist.db";
# Hardcode filename written by the Supplier when it pauses.
$supplier_pause = "Supplier.paused";

my $nfs_nfsiorfile = $nfs->LocalFile ($nfsiorfile);
my $con_conidsfile = $con->LocalFile ($conidsfile);
my $sup_supidsfile = $sup->LocalFile ($supidsfile);
my $con_channel_id = $con->LocalFile ($channel_id);
my $sup_channel_id = $sup->LocalFile ($channel_id);
my $nfs_save_xml = $nfs->LocalFile ($save_xml);
my $nfs_save_000 = $nfs->LocalFile ($save_000);
my $nfs_save_001 = $nfs->LocalFile ($save_001);
my $nfs_eventpersist = $nfs->LocalFile ($eventpersist);
my $sup_supplier_pause = $sup->LocalFile ($supplier_pause);
my $nfs_svcconf = $nfs->LocalFile ($st_topo);
my $nfs_st_both = $nfs->LocalFile ($st_both);
$nfs->DeleteFile ($nfsiorfile);
$con->DeleteFile ($conidsfile);
$sup->DeleteFile ($supidsfile);
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);
$nfs->DeleteFile ($save_xml);
$nfs->DeleteFile ($save_000);
$nfs->DeleteFile ($save_001);
$nfs->DeleteFile ($eventpersist);
$sup->DeleteFile ($supplier_pause);

# ******************************************************************
# Main Section
# ******************************************************************

my $verbose = "";
my $discon  = "";

# Process command line arguments
foreach my $i (@ARGV) {
    if ($i eq '-any') {
        $eventType = '-any';
    }
    elsif ($i eq '-str' or $i eq '-structured') {
        $eventType = '-structured';
    }
    elsif ($i eq '-seq' or $i eq '-sequence') {
        $eventType = '-sequence';
    }
    elsif ($i eq '-mt') {
        $svcconf = 'ns_mt_topo.conf';
        $nfs_svcconf = $nfs->LocalFile ($svcconf);
    }
    elsif ($i eq '-disconnect') {
        $discon= '-disconnect';
    }
    elsif ($i eq '-v' or $i eq '-verbose') {
        $verbose = '-v';
    }
    else {
        print "TEST SCRIPT: unknown: $i\n";
        print "TEST SCRIPT: usage: [-any|-str|-seq] -mt -v\n";
        exit(-4);
    }
}

my $client_args = "$eventType $verbose -NoNameSvc -ORBInitRef " .
                   "NotifyEventChannelFactory=corbaloc::" .
                   "$notify_host:$notify_port/NotifyEventChannelFactory ";
my $ns_base_args = "-ORBObjRefStyle url -NoNameSvc -Boot " .
                    "-IORoutput $nfs_nfsiorfile " .
                    "-ORBEndpoint iiop://:$notify_port ";
my $ns_args = "-ORBSvcConf $nfs_svcconf $ns_base_args";

# Delete the all of the files used in the test

# Define the processes first
my $NFS = $nfs->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Notify_Service/tao_cosnotification");
my $CON = $con->CreateProcess ("Consumer");
my $SUP = $sup->CreateProcess ("Supplier");

################
# begin test 1
################

if ($verbose eq '-v') {
    print "TEST SCRIPT: Starting Notify Service on port $notify_port\n";
}
$NFS->Arguments($ns_args);
if ($verbose eq '-v') {print "TEST SCRIPT: " . $NFS->CommandLine() . "\n";}
$NFS_status = $NFS->Spawn ();
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# start the consumer,
# write the channel number to channel.id for use by Supplier
# expect to receive 20 events of type any
#
$CON->Arguments("-channel $con_channel_id " .
                "-expect 20 $discon $client_args");
print "TEST SCRIPT: ", $CON->CommandLine(), "\n" if ($verbose eq '-v');
$CON_status = $CON->Spawn ();
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->WaitForFileTimed ($channel_id,$con->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->GetFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot retrieve file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->PutFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot set file <$sup_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# send 10 Any's, picking up the channel# from channel.id
$SUP->Arguments("-channel $sup_channel_id -send 10 $client_args");
print "TEST SCRIPT: ", $SUP->CommandLine(), "\n" if ($verbose eq '-v');
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+45);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# forget the channel id, depend on the reconnect information
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);

$SUP->Arguments("-send 10 -serial_number 10 $discon $client_args");
if ($verbose eq '-v') {print "TEST SCRIPT: " . $SUP->CommandLine() . "\n";}
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+45);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$CON_status = $CON->WaitKill ($con->ProcessStopWaitInterval()+45);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

print "TEST SCRIPT: ****Passed: Supplier reconnect test.\n";

################
# end of test 1
################

################
# begin test 2
################
# Now start the consumer again.  Depending on reconnect this time
# Let it write the channel.id file so we know when it's up.

if ($verbose eq '-v') {print "TEST SCRIPT: " . $CON->CommandLine() . "\n";}
$CON_status = $CON->Spawn ();
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->WaitForFileTimed ($channel_id,$con->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->GetFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot retrieve file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->PutFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot set file <$sup_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# forget the channel id, depend on the supplier reconnect information
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);

$SUP->Arguments("-send 20 -serial_number 0 $client_args");
if ($verbose eq '-v') {print "TEST SCRIPT: " . $SUP->CommandLine() . "\n";}
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+45);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$CON_status = $CON->WaitKill ($con->ProcessStopWaitInterval()+45);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

print "TEST SCRIPT: ****Passed: Consumer reconnect test.\n";

################
# end of test 2
################

################
# begin test 3
################

if ($verbose eq '-v') {print "TEST SCRIPT: Stop the Notification Service\n";}
$NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
$nfs->DeleteFile ($nfsiorfile);

if ($verbose eq '-v') {
    print "TEST SCRIPT: Restarting Notify Service on port $notify_port\n",
          "TEST SCRIPT: It should load topology from $nfs_save_xml\n";
}

# sleep to avoid socket-related problems
sleep(10 * $nfs->ProcessStartWaitInterval());
$NFS->Arguments($ns_args);
if ($verbose eq '-v') {print "TEST SCRIPT: " . $NFS->CommandLine() . "\n";}
$NFS_status = $NFS->Spawn ();
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# Now start the consumer again.  It will use the reconnect info.
# Let it write the channel.id file so we know when it's up.
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);

if ($verbose eq '-v') {print "TEST SCRIPT: " . $CON->CommandLine() . "\n";}
$CON_status = $CON->Spawn ();
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->WaitForFileTimed ($channel_id,$con->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->GetFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot retrieve file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->PutFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot set file <$sup_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# forget the channel id, depend on the supplier reconnect information
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);

$SUP->Arguments("-send 20 -serial_number 0 $client_args");
if ($verbose eq '-v') {print "TEST SCRIPT: " . $SUP->CommandLine() . "\n";}
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+45);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$CON_status = $CON->WaitKill ($con->ProcessStopWaitInterval()+45);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

print "TEST SCRIPT: ****Passed: Topology Persistence Test.\n";

################
# end of test 3
################

################
# begin test 4
################

# Now start the consumer one more time
# Let it write the channel.id file so we know when it's up.
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);

if ($verbose eq '-v') {print "TEST SCRIPT: " . $CON->CommandLine() . "\n";}
$CON_status = $CON->Spawn ();
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->WaitForFileTimed ($channel_id,$con->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->GetFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot retrieve file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->PutFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot set file <$sup_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# forget the channel id, depend on the supplier reconnect information
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);

# Start the Supplier, tell it to send 10 messages,
# pause until it is reconnected then send another 10.
$SUP->Arguments("-send 20 -pause 10 -serial_number 0 $client_args");
if ($verbose eq '-v') {print "TEST SCRIPT: " . $SUP->CommandLine() . "\n";}
$SUP_status = $SUP->Spawn ();
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $SUP->Kill (); $SUP->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->WaitForFileTimed ($supplier_pause,$sup->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$sup_supplier_pause>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $SUP->Kill (); $SUP->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

if ($verbose eq '-v') {print "TEST SCRIPT: Stop the Notification Service\n";}
$NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
$nfs->DeleteFile ($nfsiorfile);

if ($verbose eq '-v') {
    print "TEST SCRIPT: Restarting Notify Service\n",
          "TEST SCRIPT: It should load topology from $nfs_save_xml\n",
          "TEST SCRIPT: and reconnect to registered clients.\n";
}

# sleep to avoid socket-related problems
sleep(10 * $nfs->ProcessStartWaitInterval());

if ($verbose eq '-v') {print "TEST SCRIPT: " . $NFS->CommandLine() . "\n";}
$NFS_status = $NFS->Spawn ();
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

# at this point, both the consumer and the supplier should reconnect
# and the remaining events should be delivered
# eventually the consumer will finish

$CON_status = $CON->WaitKill ($con->ProcessStopWaitInterval()+5);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $SUP->Kill (); $SUP->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$SUP_status = $SUP->TerminateWaitKill ($sup->ProcessStopWaitInterval());
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

print "TEST SCRIPT: ****Passed: Reconnection Factory test.\n";

################
# end of test 4
################

################
# begin test 5
################

if ($verbose eq '-v') {print "TEST SCRIPT: Stop the Notification Service\n";}
$NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
$nfs->DeleteFile ($nfsiorfile);
$con->DeleteFile ($conidsfile);
$sup->DeleteFile ($supidsfile);
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);
$nfs->DeleteFile ($save_xml);
$nfs->DeleteFile ($save_000);
$nfs->DeleteFile ($save_001);
$nfs->DeleteFile ($eventpersist);
$sup->DeleteFile ($supplier_pause);

sleep(10 * $nfs->ProcessStartWaitInterval()); ## avoid lingering sockets
# go back to normal ns args
$NFS->Arguments($ns_args);
if ($verbose eq '-v') {print "TEST SCRIPT: " . $NFS->CommandLine() . "\n";}
$NFS_status = $NFS->Spawn ();
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

#configure the consumer to expect 20 events, fail (throw an exception
# after 8 events) then continue to listen for remaining events.
#The Notification service should automatically retry (but may discard)
# the failed events.
$CON->Arguments("-channel $con_channel_id " .
                "-expect 20 -fail 8 $client_args");
if ($verbose eq '-v') {print "TEST SCRIPT: " . $CON->CommandLine() . "\n";}
$CON_status = $CON->Spawn ();
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->WaitForFileTimed ($channel_id,$con->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->GetFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot retrieve file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->PutFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot set file <$sup_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$SUP->Arguments("-channel $sup_channel_id -send 20 $client_args");
if ($verbose eq '-v') {print "TEST SCRIPT: " . $SUP->CommandLine() . "\n";}
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+5);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

## this is a slow test due to the reconnection
## time, so give it enough time...
$CON_status = $CON->WaitKill ($con->ProcessStopWaitInterval()+225);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

print "TEST SCRIPT: ****Passed: Consumer recoverable exception test.\n";

################
# end of test 5
################

################
# begin test 6
################

print "TEST SCRIPT: Stop the Notification Service\n" if ($verbose eq '-v');
$NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
$nfs->DeleteFile ($nfsiorfile);
$con->DeleteFile ($conidsfile);
$sup->DeleteFile ($supidsfile);
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);
$nfs->DeleteFile ($save_xml);
$nfs->DeleteFile ($save_000);
$nfs->DeleteFile ($save_001);
$nfs->DeleteFile ($eventpersist);
$sup->DeleteFile ($supplier_pause);

## Wait a bit to avoid lingering sockets from the previous tao_cosnotification
sleep(3);

$NFS->Arguments("-ORBSvcConf $nfs_st_both $ns_base_args");
print "TEST SCRIPT: ", $NFS->CommandLine(), "\n" if ($verbose eq '-v');
$NFS_status = $NFS->Spawn ();
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    exit 1;
}
if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

my $expected = 10;
$CON->Arguments("-channel $con_channel_id " .
                "-expect $expected $client_args");
print "TEST SCRIPT: ", $CON->CommandLine(), "\n" if ($verbose eq '-v');
$CON_status = $CON->Spawn ();
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->WaitForFileTimed ($channel_id,$con->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($con->GetFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot retrieve file <$con_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}
if ($sup->PutFile ($channel_id) == -1) {
    print STDERR "ERROR: cannot set file <$sup_channel_id>\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$SUP->Arguments("-channel $sup_channel_id -send $expected $client_args");
print "TEST SCRIPT: ", $SUP->CommandLine(), "\n" if ($verbose eq '-v');
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+45);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$CON_status = $CON->WaitKill ($con->ProcessStopWaitInterval()+15);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

my $next_expected = 3;
$SUP->Arguments("-channel $sup_channel_id -send 3 " .
                "-serial_number $expected $client_args");
print "TEST SCRIPT: ", $SUP->CommandLine(), "\n" if ($verbose eq '-v');
$SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+45);
if ($SUP_status != 0) {
    print STDERR "ERROR: Supplier returned $SUP_status\n";
    $CON->Kill (); $CON->TimedWait (1);
    $NFS->Kill (); $NFS->TimedWait (1);
    exit 1;
}

$CON->Arguments("-channel $con_channel_id -expect $next_expected " .
                "-serial_number $expected $client_args");
print "TEST SCRIPT: ", $CON->CommandLine(), "\n" if ($verbose eq '-v');
$CON_status = $CON->SpawnWaitKill ($con->ProcessStartWaitInterval()+15);
if ($CON_status != 0) {
    print STDERR "ERROR: Consumer returned $CON_status\n";
    $NFS->Kill (); $NFS->TimedWait (1);
    $status = 1;
}

$NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
if ($NFS_status != 0) {
    print STDERR "ERROR: Notify Service returned $NFS_status\n";
    $status = 1;
}

################
# end of test 6
################

$nfs->DeleteFile ($nfsiorfile);
$con->DeleteFile ($conidsfile);
$sup->DeleteFile ($supidsfile);
$con->DeleteFile ($channel_id);
$sup->DeleteFile ($channel_id);
$nfs->DeleteFile ($save_xml);
$nfs->DeleteFile ($save_000);
$nfs->DeleteFile ($save_001);
$nfs->DeleteFile ($eventpersist);
$sup->DeleteFile ($supplier_pause);

exit $status;