Skip to content

Commit 1d30a14

Browse files
committed
update tests for a new docker-py library version
1 parent 0124e8e commit 1d30a14

File tree

5 files changed

+26
-29
lines changed

5 files changed

+26
-29
lines changed

tests2/lib/failure_injector.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
class FailureInjector(object):
44

55
def __init__(self):
6-
self.docker_api = docker.Client()
6+
self.docker_api = docker.from_env()
77

88
def container_exec(self, node, command):
9-
exec_id = self.docker_api.exec_create(node, command, user='root')
10-
output = self.docker_api.exec_start(exec_id)
9+
docker_node = self.docker_api.containers.get(node)
10+
docker_node.exec_run(command, user='root')
1111

1212
class NoFailure(FailureInjector):
1313

@@ -57,10 +57,10 @@ def __init__(self, node):
5757

5858
# XXX: Is it really a good idea to call cli.stop inside method called start?
5959
def start(self):
60-
self.docker_api.stop(self.node)
60+
self.docker_api.containers.get(self.node).stop()
6161

6262
def stop(self):
63-
self.docker_api.start(self.node)
63+
self.docker_api.containers.get(self.node).start()
6464

6565

6666
class CrashRecoverNode(FailureInjector):
@@ -70,10 +70,10 @@ def __init__(self, node):
7070
super().__init__()
7171

7272
def start(self):
73-
self.docker_api.kill(self.node)
73+
self.docker_api.containers.get(self.node).kill()
7474

7575
def stop(self):
76-
self.docker_api.start(self.node)
76+
self.docker_api.containers.get(self.node).start()
7777

7878

7979
class SkewTime(FailureInjector):
@@ -90,7 +90,7 @@ def __init__(self, node):
9090

9191
# XXX: Is it really a good idea to call cli.stop inside method called start?
9292
def start(self):
93-
self.docker_api.stop(self.node)
93+
self.docker_api.containers.get(self.node).stop()
9494

9595
def stop(self):
9696
return
@@ -107,4 +107,4 @@ def start(self):
107107
return
108108

109109
def stop(self):
110-
self.docker_api.start(self.node)
110+
self.docker_api.containers.get(self.node).start()

tests2/lib/test_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def assertCommits(self, aggs):
2424
commits = commits and 'commit' in agg['transfer']['finish']
2525
if not commits:
2626
print('No commits during aggregation interval')
27-
time.sleep(100000)
27+
# time.sleep(100000)
2828
raise AssertionError('No commits during aggregation interval')
2929

3030
def assertNoCommits(self, aggs):

tests2/requirements.txt

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
aiopg==0.12.0
2-
aioprocessing==0.0.1
3-
astroid==1.4.8
4-
docker-py==1.10.6
1+
aiopg==0.13.1
2+
aioprocessing==1.0.0
3+
cached-property==1.3.1
4+
docker==2.5.1
5+
docker-compose==1.16.1
56
docker-pycreds==0.2.1
6-
isort==4.2.5
7-
lazy-object-proxy==1.2.2
8-
mccabe==0.5.2
9-
pdb==0.1
10-
pi==0.1.2
11-
psycopg2==2.6.2
12-
pylint==1.6.4
13-
python-gnupg==0.3.9
7+
dockerpty==0.4.1
8+
docopt==0.6.2
9+
jsonschema==2.6.0
10+
psycopg2==2.7.3.1
1411
PyYAML==3.12
15-
requests==2.12.1
16-
six==1.10.0
17-
websocket-client==0.37.0
18-
wrapt==1.10.8
12+
requests==2.11.1
13+
six==1.11.0
14+
texttable==0.9.1
15+
websocket-client==0.44.0

tests2/test_recovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def assertCommits(self, aggs):
3333
commits = commits and 'commit' in agg['transfer']['finish']
3434
if not commits:
3535
print('No commits during aggregation interval')
36-
time.sleep(100000)
36+
# time.sleep(100000)
3737
raise AssertionError('No commits during aggregation interval')
3838

3939
def assertNoCommits(self, aggs):

tests2/test_referee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def test_winner_restart(self):
131131
self.assertIsolation(aggs)
132132

133133
# need to start node1 to perform consequent tests
134-
docker_api = docker.Client()
135-
docker_api.start('node1')
134+
docker_api = docker.from_env()
135+
docker_api.containers.get('node1').start()
136136
time.sleep(35)
137137

138138

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy