-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_nameserver_start_stop.py
102 lines (82 loc) · 2.83 KB
/
test_nameserver_start_stop.py
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
'''
Copyright (c) 2016, Baidu.com, Inc. All Rights Reserved
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
'''
import subprocess
import time
import os
import nose.tools
import common
from conf import const
def setUp():
common.bfs_clear()
print "clear data and status is ok"
common.bfs_deploy()
print "deploy nameserver, chunkserver and status is ok"
def tearDown():
ret = common.check_core()
nose.tools.assert_equal(ret, 0)
common.bfs_stop_all()
print "stop nameserver, chunkserver and status is ok"
'''
test nameserver start method
'''
def test_nameserver_start_normal():
cmd = "cd %s/nameserver0 && ./bin/nameserver 1>nlog 2>&1 &" % const.work_dir
print time.strftime("%Y%m%d-%H%M%S") + " command: "+cmd
ret = os.system(cmd)
nose.tools.assert_equal(ret, 0)
time.sleep(3)
'''
test nameserver stop method
'''
def test_nameserver_stop_normal():
cmd = "killall -9 nameserver"
print time.strftime("%Y%m%d-%H%M%S") + " command: "+cmd
(ret, out, err) = common.runcmd(cmd)
nose.tools.assert_equal(ret, 0)
time.sleep(3)
ret1 = common.check_process(type = "nameserver")
nose.tools.assert_equal(ret1, 1)
'''
test nameserver restart method
'''
def test_nameserver_restart_normal():
common.bfs_stop_all()
cmd = "cd %s/nameserver0 && ./bin/nameserver 1>nlog 2>&1 &" % const.work_dir
print time.strftime("%Y%m%d-%H%M%S") + " command: "+cmd
ret = os.system(cmd)
nose.tools.assert_equal(ret, 0)
time.sleep(3)
ret1 = common.check_process(type = "nameserver")
'''
test nameserver start twice method
'''
def test_nameserver_start_twice():
cmd = "cd %s/nameserver0 && ./bin/nameserver 1>nlog 2>&1 &" % const.work_dir
print time.strftime("%Y%m%d-%H%M%S") + " command: "+cmd
ret = os.system(cmd)
nose.tools.assert_not_equal(ret, 0)
time.sleep(3)
cmd = "%s/bfs_client touchz /test_nameserver_start_twice" % const.bfs_client_dir
(ret, out, err) = common.runcmd(cmd)
nose.tools.assert_equal(ret, 0)
ret1 = common.check_process(type = "nameserver")
nose.tools.assert_equal(ret1, 0)
'''
test nameserver start conf not exist method
'''
def test_nameserver_start_conf_not_exist():
common.bfs_stop_all()
(ret, out, err) = common.runcmd("cd nameserver0 && mv bfs.flag bfs.flag.bak")
assert(ret == 0)
cmd = "cd %s/nameserver0 && ./bin/nameserver 1>nlog 2>&1 &" % const.work_dir
print time.strftime("%Y%m%d-%H%M%S") + " command: "+cmd
ret = os.system(cmd)
nose.tools.assert_not_equal(ret, 0)
time.sleep(3)
ret1 = common.check_process(type = "nameserver")
nose.tools.assert_equal(ret1, 1)
(ret, out, err) = common.runcmd("cd nameserver0 && mv bfs.flag.bak bfs.flag")
assert(ret == 0)