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

# -*- perl -*-

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

@test_configs = ( "reactive.conf", "lookup.conf", "listener.conf");

my $nm_service = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
my $test = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
my $nt_service = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";

$test->AddLibPath ('../../lib');

my $notify_ior = "notify.ior";
my $naming_ior = "naming.ior";

my $nm_service_nmiorfile = $nm_service->LocalFile ($naming_ior);
my $nt_service_ntiorfile = $nt_service->LocalFile ($notify_ior);
my $nt_service_nmiorfile = $nt_service->LocalFile ($naming_ior);
my $test_nmiorfile = $test->LocalFile ($naming_ior);

$nm_service->DeleteFile ($naming_ior);
$nt_service->DeleteFile ($notify_ior);
$nt_service->DeleteFile ($naming_ior);
$test->DeleteFile ($naming_ior);

$NM_SV = $nm_service->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming", "-o $nm_service_nmiorfile");
$T = $test->CreateProcess ("RedGreen_Test", "-ORBInitRef NameService=file://$test_nmiorfile");
$NT_SV = $nt_service->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Notify_Service/tao_cosnotification", "");

$nm_service_status = $NM_SV->Spawn ();

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

if ($nm_service->WaitForFileTimed ($naming_ior,
                                   $nm_service->ProcessStartWaitInterval() + 45) == -1) {
    print STDERR "ERROR: cannot find file <$nm_service_nmiorfile>\n";
    $NM_SV->Kill (); $NM_SV->TimedWait (1);
    exit 1;
}

sleep (10);

if ($nm_service->GetFile ($naming_ior) == -1) {
    print STDERR "ERROR: cannot retrieve file <$nm_service_nmiorfile>\n";
    $NM_SV->Kill (); $NM_SV->TimedWait (1);
    exit 1;
}

if ($test->PutFile ($naming_ior) == -1) {
    print STDERR "ERROR: cannot set file <$test_nmiorfile>\n";
    $NM_SV->Kill (); $NM_SV->TimedWait (1);
    exit 1;
}

if ($nt_service->PutFile ($naming_ior) == -1) {
    print STDERR "ERROR: cannot set file <$nt_service_nmiorfile>\n";
    $NM_SV->Kill (); $NM_SV->TimedWait (1);
    exit 1;
}

for $config (@test_configs) {
    print STDERR "\nTesting Notification Service with config file = $config ....\n\n";

    $NT_SV->Arguments("-ORBInitRef NameService=file://$nt_service_nmiorfile " .
                      "-IORoutput $nt_service_ntiorfile -ORBSvcConf $config");

    $nt_service_status = $NT_SV->Spawn ();

    if ($nt_service_status != 0) {
        print STDERR "ERROR: Notify service returned $nt_service_status\n";
        $NM_SV->Kill (); $NM_SV->TimedWait (1);
        exit 1;
    }

    if ($nt_service->WaitForFileTimed ($notify_ior,
                                       $nt_service->ProcessStartWaitInterval() + 45) == -1) {
        print STDERR "ERROR: cannot find file <$nt_service_ntiorfile>\n";
        $NT_SV->Kill (); $NT_SV->TimedWait (1);
        $NM_SV->Kill (); $NM_SV->TimedWait (1);
        exit 1;
    }

    sleep(10);

    $test_status = $T->SpawnWaitKill ($test->ProcessStartWaitInterval() + 45);

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

    $NT_SV->Kill ();
}

$NT_SV->Kill ();
$NM_SV->Kill ();

$nm_service->DeleteFile ($naming_ior);
$nt_service->DeleteFile ($notify_ior);
$nt_service->DeleteFile ($naming_ior);
$test->DeleteFile ($naming_ior);

exit $status;