summaryrefslogtreecommitdiff
path: root/cpp/demo/IceGrid/secure/expect.py
blob: da66cbcb03cdcbd0925bac384ddaa90134f5c236 (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

import sys, os

path = [ ".", "..", "../..", "../../..", "../../../.." ]
head = os.path.dirname(sys.argv[0])
if len(head) > 0:
    path = [os.path.join(head, p) for p in path]
path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ]
if len(path) == 0:
    raise "can't find toplevel directory!"
sys.path.append(path[0])

from demoscript import *
import signal

print "cleaning databases...",
sys.stdout.flush()
Util.cleanDbDir("db/registry")
Util.cleanDbDir("db/node")
Util.cleanDbDir("certs")
print "ok"

if Util.defaultHost:
    args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"'
else:
    args = ''

print "creating certificates...",
sys.stdout.flush()
makecerts = Util.spawn('python -u makecerts.py')
makecerts.expect("Do you want to keep this as the CA subject name?")
makecerts.sendline("y")
makecerts.expect("Enter the email address of the CA:")
makecerts.sendline("test@zeroc.com")
makecerts.expect("Sign the certificate?")
makecerts.sendline("y")
makecerts.expect("1 out of 1 certificate requests certified, commit?")
makecerts.sendline("y")
makecerts.expect("Sign the certificate?")
makecerts.sendline("y")
makecerts.expect("1 out of 1 certificate requests certified, commit?")
makecerts.sendline("y")
makecerts.expect("Sign the certificate?")
makecerts.sendline("y")
makecerts.expect("1 out of 1 certificate requests certified, commit?")
makecerts.sendline("y")
makecerts.expect("Sign the certificate?")
makecerts.sendline("y")
makecerts.expect("1 out of 1 certificate requests certified, commit?")
makecerts.sendline("y")
makecerts.waitTestSuccess()
print "ok"

print "starting icegrid...",
sys.stdout.flush()
registryProps = " --Ice.PrintAdapterReady"
registry = Util.spawn('icegridregistry --Ice.Config=config.registry' + registryProps)
registry.expect('IceGrid.Registry.Internal ready\nIceGrid.Registry.Server ready\nIceGrid.Registry.Client ready')
node = Util.spawn('icegridnode --Ice.Config=config.node --Ice.PrintAdapterReady %s' % (args))
node.expect('IceGrid.Node ready')
print "ok"

print "starting glacier2...",
sys.stdout.flush()

glacier2Props = " --Ice.PrintAdapterReady --Glacier2.SessionTimeout=5"
glacier2 = Util.spawn('glacier2router --Ice.Config=config.glacier2' + glacier2Props)
glacier2.expect('Glacier2.Client ready')
glacier2.expect('Glacier2.Server ready')
print "ok"

print "deploying application...",
sys.stdout.flush()
admin = Util.spawn('icegridadmin --Ice.Config=config.admin')
admin.expect('>>>')
admin.sendline("application add application.xml")
admin.expect('>>>')
admin.sendline('exit')
admin.waitTestSuccess(timeout=120)
print "ok"

def runtest():
    client = Util.spawn('./client')
    client.expect('==>')
    client.sendline('t')
    node.expect("SimpleServer says Hello World!")
    client.sendline('t')
    node.expect("SimpleServer says Hello World!")
    client.sendline('s')
    node.expect("detected termination of.*SimpleServer")
    client.sendline('x')

    client.waitTestSuccess(timeout=1)

print "testing client...", 
sys.stdout.flush()
runtest()
print "ok"

print "completing shutdown...", 
sys.stdout.flush()

admin = Util.spawn('icegridadmin --Ice.Config=config.admin')
admin.expect('>>>')

admin.sendline('node shutdown Node')
admin.expect('>>>')
node.waitTestSuccess(timeout=120)

admin.sendline('registry shutdown Master')
admin.expect('>>>')
registry.waitTestSuccess()

admin.sendline('exit')
admin.waitTestSuccess(timeout=120)

glacier2.kill(signal.SIGINT)
glacier2.waitTestSuccess()

print "ok"