Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
b51e41ed
Commit
b51e41ed
authored
Sep 17, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working DockerMixin for tests.
parent
5b4f9bd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
dev_requirements.txt
dev_requirements.txt
+1
-0
tests/testlib.py
tests/testlib.py
+43
-3
No files found.
dev_requirements.txt
0 → 100644
View file @
b51e41ed
docker
[tls]==2.5.1
tests/testlib.py
View file @
b51e41ed
import
os
import
os
import
random
import
sys
import
sys
import
unittest
import
unittest
import
urlparse
import
mock
import
mock
import
mitogen.master
import
mitogen.master
import
docker
DATA_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
)
DATA_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
)
...
@@ -21,14 +24,51 @@ def data_path(suffix):
...
@@ -21,14 +24,51 @@ def data_path(suffix):
return
os
.
path
.
join
(
DATA_DIR
,
suffix
)
return
os
.
path
.
join
(
DATA_DIR
,
suffix
)
class
BrokerMixin
(
object
):
class
DockerizedSshDaemon
(
object
):
def
__init__
(
self
):
self
.
docker
=
docker
.
from_env
()
self
.
container_name
=
'mitogen-test-%08x'
%
(
random
.
getrandbits
(
64
),)
self
.
container
=
self
.
docker
.
containers
.
run
(
image
=
'd2mw/mitogen-test'
,
detach
=
True
,
remove
=
True
,
publish_all_ports
=
True
,
)
self
.
container
.
reload
()
self
.
port
=
(
self
.
container
.
attrs
[
'NetworkSettings'
][
'Ports'
]
[
'22/tcp'
][
0
][
'HostPort'
])
self
.
host
=
self
.
get_host
()
def
get_host
(
self
):
parsed
=
urlparse
.
urlparse
(
self
.
docker
.
api
.
base_url
)
return
parsed
.
netloc
.
partition
(
':'
)[
0
]
def
close
(
self
):
self
.
container
.
stop
()
class
RouterMixin
(
object
):
broker_class
=
mitogen
.
master
.
Broker
broker_class
=
mitogen
.
master
.
Broker
router_class
=
mitogen
.
master
.
Router
def
setUp
(
self
):
def
setUp
(
self
):
super
(
Brok
erMixin
,
self
).
setUp
()
super
(
Rout
erMixin
,
self
).
setUp
()
self
.
broker
=
self
.
broker_class
()
self
.
broker
=
self
.
broker_class
()
self
.
router
=
self
.
router_class
(
self
.
broker
)
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
broker
.
shutdown
()
self
.
broker
.
shutdown
()
self
.
broker
.
join
()
self
.
broker
.
join
()
super
(
BrokerMixin
,
self
).
tearDown
()
super
(
RouterMixin
,
self
).
tearDown
()
class
DockerMixin
(
RouterMixin
):
@
classmethod
def
setUpClass
(
cls
):
super
(
DockerMixin
,
cls
).
setUpClass
()
cls
.
dockerized_ssh
=
DockerizedSshDaemon
()
@
classmethod
def
tearDownClass
(
cls
):
cls
.
dockerized_ssh
.
close
()
super
(
DockerMixin
,
cls
).
tearDownClass
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment