[autotest] Start containers in the pool.
Previous code created the containers in the pool but omitted to actually
start them. This ensures containers are actually started before handing
them to clients.
BUG=chromium:720219
TEST=pool_unittest.py
Change-Id: If8496bd428ecbbfbe49cb699ab9f0350ccaf1c45
Reviewed-on: https://chromium-review.googlesource.com/804238
Commit-Ready: Ben Kwa <kenobi@chromium.org>
Tested-by: Ben Kwa <kenobi@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/site_utils/lxc/container_pool/pool.py b/site_utils/lxc/container_pool/pool.py
index c94e12b..f0adb79 100644
--- a/site_utils/lxc/container_pool/pool.py
+++ b/site_utils/lxc/container_pool/pool.py
@@ -372,6 +372,7 @@
container = None
try:
container = self._factory.create_container()
+ container.start(wait_for_network=True)
except Exception as e:
logging.error('Worker error: %s', error.format_error())
self._error_cb(self, e)
diff --git a/site_utils/lxc/container_pool/pool_unittest.py b/site_utils/lxc/container_pool/pool_unittest.py
index 8018b56..9a7605d 100755
--- a/site_utils/lxc/container_pool/pool_unittest.py
+++ b/site_utils/lxc/container_pool/pool_unittest.py
@@ -251,7 +251,9 @@
# Block with timeout so that the test doesn't hang forever if
# something goes wrong. 1 second should be sufficient because the
# test factory is extremely lightweight.
- self.assertIsNotNone(self.pool.get(timeout=1))
+ pool = self.pool.get(timeout=1)
+ self.assertIsNotNone(pool)
+ self.assertTrue(pool.started)
def _verifyNoContainers(self):
@@ -558,6 +560,12 @@
def __init__(self, factory):
self._factory = factory
+ self.started = False
+
+
+ def start(self, wait_for_network=True):
+ """Simulates starting the container."""
+ self.started = True
def destroy(self, *_args, **_kwargs):