summaryrefslogtreecommitdiff
path: root/cpp/test/Yellow/basicYellow/run.py
blob: 1a7b88ef90fc0214c282cd683363d2b7979d56b9 (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2001
# ZeroC, Inc.
# Huntsville, AL, USA
#
# All Rights Reserved
#
# **********************************************************************

import os, sys, time

for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
    toplevel = os.path.normpath(toplevel)
    if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
        break
else:
    raise "can't find toplevel directory!"

sys.path.append(os.path.join(toplevel, "config"))
import TestUtil

name = os.path.join("Yellow", "basicYellow")
testdir = os.path.join(toplevel, "test", name)

IceBox = os.path.join(toplevel, "bin", "icebox")
IceBoxAdmin = os.path.join(toplevel, "bin", "iceboxadmin")

updatedServerOptions = TestUtil.serverOptions.replace("TOPLEVELDIR", toplevel)
updatedClientOptions = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)
updatedClientServerOptions = TestUtil.clientServerOptions.replace("TOPLEVELDIR", toplevel)

IceBoxEndpoints=' --IceBox.ServiceManager.Endpoints="default -p 12345"'
YellowService=" --IceBox.Service.Yellow=YellowService:create" + \
	      ' --Yellow.Query.Endpoints="default -p 12346" --Yellow.Admin.Endpoints="default -p 12347"' + \
	      ' --IceBox.PrintServicesReady=Yellow'

dbEnvName = os.path.join(testdir, "db")
TestUtil.cleanDbDir(dbEnvName)
YellowDBEnv=" --IceBox.DBEnvName.Yellow=" + dbEnvName

print "starting yellow service...",
command = IceBox + updatedClientServerOptions + IceBoxEndpoints + YellowService + YellowDBEnv
IceBoxPipe = os.popen(command)
TestUtil.getServerPid(IceBoxPipe)
TestUtil.waitServiceReady(IceBoxPipe, "Yellow")
print "ok"

client = os.path.join(testdir, "client")
#
# Start the client.
#
print "starting client...",
command = client + updatedClientOptions
clientPipe = os.popen(command)
print "ok"

for output in clientPipe.xreadlines():
    print output,
    
#
# Shutdown yellow.
#
print "shutting down yellow service...",
command = IceBoxAdmin + updatedClientOptions + IceBoxEndpoints + r' shutdown'
IceBoxAdminPipe = os.popen(command)
IceBoxAdminStatus = IceBoxAdminPipe.close()
if IceBoxAdminStatus:
    TestUtil.killServers()
    sys.exit(1)
print "ok"

YellowStatus = IceBoxPipe.close()
clientStatus = clientPipe.close();

if YellowStatus or clientStatus:
    TestUtil.killServers()
    sys.exit(1)

sys.exit(0)