summaryrefslogtreecommitdiff
path: root/cpp/test/IceGrid/fileLock/run.py
blob: 52358f410f627b950394c46951de984a15a8b0df (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2016 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 os, sys

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, "scripts", "TestUtil.py")) ]
if len(path) == 0:
    raise RuntimeError("can't find toplevel directory!")
sys.path.append(os.path.join(path[0], "scripts"))
import TestUtil, IceGridAdmin

testdir = os.getcwd();

# No need to spawn replicas for this test.
IceGridAdmin.nreplicas = 0

def runIceGridRegistry():
    iceGrid = TestUtil.getIceGridRegistry()
    command = ' --nowarn ' + IceGridAdmin.registryOptions

    dataDir = os.path.join(testdir, "db", "registry")
    if not os.path.exists(dataDir):
        os.mkdir(dataDir)

    cmd = command + ' ' + \
            r' --Ice.ProgramName=registry' + \
            r' --IceGrid.Registry.Client.Endpoints="default -p ' + str(IceGridAdmin.iceGridPort) + '" ' + \
            r' --IceGrid.Registry.LMDB.MapSize=1 --IceGrid.Registry.LMDB.Path="' + dataDir + '"'

    driverConfig = TestUtil.DriverConfig("server")
    driverConfig.lang = "cpp"

    cmd = TestUtil.getCommandLine(iceGrid, driverConfig) + ' ' + cmd
    proc = TestUtil.spawn(cmd)
    return proc

registryProcs = IceGridAdmin.startIceGridRegistry(testdir)

sys.stdout.write("testing IceGrid file lock... ")
IceGridAdmin.iceGridPort = 12011
iceGrid = runIceGridRegistry()
iceGrid.expect(".*IceUtil::FileLockException.*")
iceGrid.wait()
IceGridAdmin.iceGridPort = 12010
print("ok")

IceGridAdmin.shutdownIceGridRegistry(registryProcs)