summaryrefslogtreecommitdiff
path: root/ACE/TAO/orbsvcs/tests/Bug_2800_Regression/run_test_federated.pl
blob: de736f305a251337c6cce9207feb4de6b7a822fd (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
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
     & eval 'exec perl -S $0 $argv:q'
     if 0;

# $Id$
# This is a Perl script that runs a Naming Service test.  It starts
# all the servers and clients as necessary.
# -*- perl -*-

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

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

if ($ARGV[0] eq '-q') {
    $quiet = 1;
}

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

# Variables for command-line arguments to client and server
# executables.
my $ns_orb_port1 = 9931;
my $ns_orb_port2 = 9932;
my $ns_endpoint1 = "iiop://localhost:$ns_orb_port1";
my $ns_endpoint2 = "iiop://localhost:$ns_orb_port2";
my $ns1_ior = "ns1.ior";
my $ns2_ior = "ns2.ior";
my $iorbase = "test.ior";

my $ns1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
my $ns2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
my $server = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
my $client = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";

my $server_iorfile = $server->LocalFile ($iorbase);
my $ns1_iorfile = $ns1->LocalFile ($ns1_ior);
my $ns2_iorfile = $ns2->LocalFile ($ns2_ior);
$server->DeleteFile ($iorbase);
$ns1->DeleteFile ($ns1_ior);
$ns2->DeleteFile ($ns2_ior);

$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile");
$CL = $client->CreateProcess ("client", "");

$NS1 = $ns1->CreateProcess("../../Naming_Service/Naming_Service",
                           "-ORBEndPoint $ns_endpoint1 -o $ns1_iorfile -m 0");
$NS2 = $ns2->CreateProcess("../../Naming_Service/Naming_Service",
                           "-ORBEndPoint $ns_endpoint2 -o $ns2_iorfile -m 0");

# Run two Naming Servers
$process_status = $NS1->Spawn ();

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

if ($ns1->WaitForFileTimed ($ns1_ior,
                            $ns1->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$ns1_iorfile>\n";
    $NS1->Kill (); $NS1->TimedWait (1);
    exit 1;
}

$process_status = $NS2->Spawn ();

if ($process_status != 0) {
    print STDERR "ERROR: ns2 returned $process_status\n";
    $NS1->Kill (); $NS1->TimedWait (1);
    exit 1;
}

if ($ns2->WaitForFileTimed ($ns2_ior,
                            $ns2->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$ns2_iorfile>\n";
    $NS2->Kill (); $NS2->TimedWait (1);
    $NS1->Kill (); $NS1->TimedWait (1);
    exit 1;
}

$process_status = $SV->Spawn ();

if ($process_status != 0) {
    print STDERR "ERROR: server returned $process_status\n";
    $NS2->Kill (); $NS2->TimedWait (1);
    $NS1->Kill (); $NS1->TimedWait (1);
    exit 1;
}

if ($server->WaitForFileTimed ($iorbase,
                               $server->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$server_iorfile>\n";
    $NS2->Kill (); $NS2->TimedWait (1);
    $NS1->Kill (); $NS1->TimedWait (1);
    $SV->Kill (); $SV->TimedWait (1);
    exit 1;
}

print STDERR "Killing second naming server\n";
$NS2->Kill ();

print STDERR "Starting client\n";
$process_status = $CL->Spawn ();

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

sleep (15);

$process_status = $SV->TerminateWaitKill ($server->ProcessStopWaitInterval());

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

$NS1->Kill ();

$process_status = $CL->TerminateWaitKill ($server->ProcessStopWaitInterval());

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

$server->DeleteFile ($iorbase);
$ns1->DeleteFile ($ns1_ior);
$ns2->DeleteFile ($ns2_ior);

exit $status;