Skip to content

Commit d60b09a

Browse files
committed
address some review comments
1 parent 5caa920 commit d60b09a

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

flocker/node/_docker.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,14 @@ def exists(unit_name):
208208
otherwise ``False``.
209209
"""
210210

211-
def remove(unit_name):
211+
def remove(unit_name, force):
212212
"""
213213
Stop and delete the given unit.
214214
215215
This can be done multiple times in a row for the same unit.
216216
217217
:param unicode unit_name: The name of the unit to stop.
218+
:param bool force: Force removal of the unit.
218219
219220
:return: ``Deferred`` that fires once the unit has been stopped
220221
and removed.
@@ -271,7 +272,7 @@ def add(self, unit_name, image_name, ports=frozenset(), environment=None,
271272
def exists(self, unit_name):
272273
return succeed(unit_name in self._units)
273274

274-
def remove(self, unit_name):
275+
def remove(self, unit_name, force=False):
275276
if unit_name in self._units:
276277
del self._units[unit_name]
277278
return succeed(None)

flocker/node/functional/test_docker.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_force_remove(self):
150150
expected_states = (u'active',)
151151
d = client.add(
152152
unit_name=unit_name,
153-
image_name=u'clusterhq/flask'
153+
image_name=u"openshift/busybox-http-app"
154154
)
155155
d.addCallback(
156156
lambda _: wait_for_unit_state(
@@ -162,7 +162,7 @@ def check_is_listed(_):
162162
listed = client.list()
163163

164164
def check_unit(results):
165-
self.assertTrue(unit_name in [unit.name for unit in results])
165+
self.assertIn(unit_name, [unit.name for unit in results])
166166
listed.addCallback(check_unit)
167167
return listed
168168

@@ -173,7 +173,7 @@ def check_is_removed(_):
173173
listed = client.list()
174174

175175
def check_unit(results):
176-
self.assertFalse(unit_name in [unit.name for unit in results])
176+
self.assertNotIn(unit_name, [unit.name for unit in results])
177177
listed.addCallback(check_unit)
178178
return listed
179179

flocker/node/test/test_docker.py

+25
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,31 @@ def test_removed_does_not_exist(self):
117117
d.addCallback(self.assertFalse)
118118
return d
119119

120+
def test_forced_removed_does_not_exist(self):
121+
"""
122+
A container removed with the ``force`` switch does not exist.
123+
"""
124+
client = fixture(self)
125+
name = random_name(self)
126+
image = u"openshift/busybox-http-app"
127+
d = client.add(name, image)
128+
d.addCallback(lambda _: client.list())
129+
expected = Unit(
130+
name=name, container_name=name, activation_state=u"active",
131+
container_image=image,
132+
)
133+
134+
def got_units(units):
135+
result = units.pop()
136+
result = result.set("container_name", name)
137+
self.assertEqual(expected, result)
138+
139+
d.addCallback(got_units)
140+
d.addCallback(lambda _: client.remove(name, force=True))
141+
d.addCallback(lambda _: client.exists(name))
142+
d.addCallback(self.assertFalse)
143+
return d
144+
120145
def test_added_is_listed(self):
121146
"""
122147
An added container is included in the output of ``list()``.

0 commit comments

Comments
 (0)