~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to test/probe/common.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from httplib import HTTPConnection
17
17
from os import kill
18
18
from signal import SIGTERM
19
 
from subprocess import call, Popen
 
19
from subprocess import Popen, PIPE, STDOUT
20
20
from time import sleep, time
21
21
 
22
22
from swiftclient import get_auth, head_account
23
23
 
24
24
from swift.common.ring import Ring
25
25
 
 
26
from test.probe import CHECK_SERVER_TIMEOUT
 
27
 
26
28
 
27
29
def start_server(port, port2server, pids, check=True):
28
30
    server = port2server[port]
40
42
    return None
41
43
 
42
44
 
43
 
def check_server(port, port2server, pids):
 
45
def check_server(port, port2server, pids, timeout=CHECK_SERVER_TIMEOUT):
44
46
    server = port2server[port]
45
47
    if server[:-1] in ('account', 'container', 'object'):
46
48
        path = '/connect/1/2'
48
50
            path += '/3'
49
51
        elif server[:-1] == 'object':
50
52
            path += '/3/4'
51
 
        try_until = time() + 30
 
53
        try_until = time() + timeout
52
54
        while True:
53
55
            try:
54
56
                conn = HTTPConnection('127.0.0.1', port)
61
63
            except Exception, err:
62
64
                if time() > try_until:
63
65
                    print err
64
 
                    print 'Giving up on %s:%s after 30 seconds.' % (
65
 
                        server, port)
 
66
                    print 'Giving up on %s:%s after %s seconds.' % (
 
67
                        server, port, timeout)
66
68
                    raise err
67
69
                sleep(0.1)
68
70
    else:
69
 
        try_until = time() + 30
 
71
        try_until = time() + timeout
70
72
        while True:
71
73
            try:
72
74
                url, token = get_auth('http://127.0.0.1:8080/auth/v1.0',
122
124
 
123
125
 
124
126
def reset_environment():
125
 
    call(['resetswift'])
 
127
    p = Popen("resetswift 2>&1", shell=True, stdout=PIPE)
 
128
    stdout, _stderr = p.communicate()
 
129
    print stdout
126
130
    pids = {}
127
131
    try:
128
132
        port2server = {}