summaryrefslogtreecommitdiff
path: root/cpp/demo/IceGrid/secure/expect.py
blob: 0d74ba486e993450040190f26976a266d3dbc57b (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2014 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, signal

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 RuntimeError("can't find toplevel directory!")
sys.path.append(path[0])

from demoscript import Util

sys.stdout.write("cleaning databases... ")
sys.stdout.flush()
Util.cleanDbDir("db/master")
Util.cleanDbDir("db/slave")
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 = ''

sys.stdout.write("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.expect("Sign the certificate?")
makecerts.sendline("y")
makecerts.expect("1 out of 1 certificate requests certified, commit?")
makecerts.sendline("y")
makecerts.waitTestSuccess()
print("ok")

sys.stdout.write("starting icegrid... ")
sys.stdout.flush()
masterProps = " --Ice.PrintAdapterReady"
master = Util.spawn(Util.getIceGridRegistry() + ' --Ice.Config=config.master' + masterProps)
master.expect('IceGrid.Registry.Internal ready')
master.expect('IceGrid.Registry.Server ready')
master.expect('IceGrid.Registry.Client ready')

slaveProps = " --Ice.PrintAdapterReady"
slave = Util.spawn(Util.getIceGridRegistry() + ' --Ice.Config=config.slave' + slaveProps)
slave.expect('IceGrid.Registry.Internal ready')
slave.expect('IceGrid.Registry.Server ready')
slave.expect('IceGrid.Registry.Client ready')

node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.node --Ice.PrintAdapterReady %s' % (args))
node.expect('IceGrid.Node ready')
print("ok")

sys.stdout.write("starting glacier2... ")
sys.stdout.flush()

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

sys.stdout.write("deploying application... ")
sys.stdout.flush()
admin = Util.spawn(Util.getIceGridAdmin() + ' --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)

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

sys.stdout.write("completing shutdown... ")
sys.stdout.flush()

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

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

admin.sendline('registry shutdown Slave')
admin.expect('>>>')
slave.waitTestSuccess()

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

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

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

print("ok")