summaryrefslogtreecommitdiff
path: root/demoscript/IceDiscovery/hello.py
blob: 9f562a93c2b031286374835037a636aa61cfb5cf (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
#!/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
import Expect

def runtests(client, server, secure, datagram):
    sys.stdout.write("testing twoway ")
    sys.stdout.flush()
    client.sendline('t')
    server.expect('Hello World!')
    sys.stdout.write("oneway ")
    sys.stdout.flush()
    client.sendline('o')
    server.expect('Hello World!')
    if not secure and datagram:
        sys.stdout.write("datagram ")
        sys.stdout.flush()
        client.sendline('d')
        server.expect('Hello World!')
    print("... ok")

    sys.stdout.write("testing batch oneway ")
    sys.stdout.flush()
    client.sendline('O')
    try:
        server.expect('Hello World!', timeout=1)
    except Expect.TIMEOUT:
        pass
    client.sendline('O')
    client.sendline('f')
    server.expect('Hello World!')
    server.expect('Hello World!')
    if not secure and datagram:
        sys.stdout.write("datagram ")
        sys.stdout.flush()
        client.sendline('D')
        try:
            server.expect('Hello World!', timeout=1)
        except Expect.TIMEOUT:
            pass
        client.sendline('D')
        client.sendline('f')
        server.expect('Hello World!')
        server.expect('Hello World!')
    print("... ok")

    sys.stdout.write("testing timeout... ")
    sys.stdout.flush()
    client.sendline('T')
    client.sendline('P')
    client.expect('server delay is now set to 2500ms')
    client.sendline('t')
    client.expect('.*InvocationTimeoutException.*', timeout=10)
    server.expect('Hello World!')
    client.sendline('P')
    client.expect('server delay is now deactivated')
    client.sendline('t')
    server.expect('Hello World!')
    client.sendline('T')
    print("ok")

def run(client, server, sslSupport = True, datagramSupport = True):
    runtests(client, server, False, datagramSupport)

    if sslSupport:
        print("repeating tests with SSL")
        client.sendline('S')

        runtests(client, server, True, datagramSupport)

    client.sendline('s')
    server.waitTestSuccess()
    print("server shutdown");
    client.sendline('x')
    client.waitTestSuccess()
    print("client shutdown");