testing: support grabbing Docker images from environment
authorGregory Szorc <gps@mozilla.com>
Sat, 24 Jan 2015 14:03:18 -0800
changeset 360248 03af105e5b4ebb3be533244e7c67cd0174074a0a
parent 360247 3667a2edcb6cbefeab091fc010305598f6f9eb6d
child 360249 b6b821618fe13e819c8bef4c2c1c09655a33c5e0
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
testing: support grabbing Docker images from environment The mozreview command will now grab Docker images from environment variables. This is groundwork to enable the mozreview command to be used from tests.
testing/vcttesting/mozreview.py
testing/vcttesting/mozreview_mach_commands.py
--- a/testing/vcttesting/mozreview.py
+++ b/testing/vcttesting/mozreview.py
@@ -36,22 +36,26 @@ def kill(pid):
         time.sleep(0.1)
 
 class MozReview(object):
     """Interface to MozService service.
 
     This class can be used to create and control MozReview instances.
     """
 
-    def __init__(self, path):
+    def __init__(self, path, web_image=None, db_image=None, pulse_image=None):
         if not path:
             raise Exception('You must specify a path to create an instance')
         path = os.path.abspath(path)
         self._path = path
 
+        self.db_image = db_image
+        self.web_image = web_image
+        self.pulse_image = pulse_image
+
         self._name = os.path.dirname(path)
 
         if not os.path.exists(path):
             os.mkdir(path)
 
         self._state_path = os.path.join(path, 'state.json')
 
         docker_state = os.path.join(path, 'docker-state.json')
@@ -88,16 +92,20 @@ class MozReview(object):
             bugzilla_port = get_available_port()
         if not reviewboard_port:
             reviewboard_port = get_available_port()
         if not mercurial_port:
             mercurial_port = get_available_port()
         if not pulse_port:
             pulse_port = get_available_port()
 
+        db_image = db_image or self.db_image
+        web_image = web_image or self.web_image
+        pulse_image = pulse_image or self.pulse_image
+
         mr_info = self._docker.start_mozreview(cluster=self._name,
                 hostname=None, http_port=bugzilla_port, pulse_port=pulse_port,
                 db_image=db_image, web_image=web_image,
                 pulse_image=pulse_image, verbose=verbose)
 
         bugzilla_url = mr_info['bugzilla_url']
 
         self.bugzilla_url = bugzilla_url
--- a/testing/vcttesting/mozreview_mach_commands.py
+++ b/testing/vcttesting/mozreview_mach_commands.py
@@ -12,18 +12,23 @@ from mach.decorators import (
 )
 
 @CommandProvider
 class MozReviewCommands(object):
     def _get_mozreview(self, where):
         if not where and 'MOZREVIEW_HOME' in os.environ:
             where = os.environ['MOZREVIEW_HOME']
 
+        db_image = os.environ.get('DOCKER_BMO_DB_IMAGE', None)
+        web_image = os.environ.get('DOCKER_BMO_WEB_IMAGE', None)
+        pulse_image = os.environ.get('DOCKER_PULSE_IMAGE', None)
+
         from vcttesting.mozreview import MozReview
-        return MozReview(where)
+        return MozReview(where, db_image=db_image, web_image=web_image,
+                         pulse_image=pulse_image)
 
     @Command('start', category='mozreview',
         description='Start a MozReview instance')
     @CommandArgument('where', nargs='?',
         help='Directory of MozReview instance')
     @CommandArgument('--bugzilla-port', type=int,
         help='Port Bugzilla HTTP server should listen on.')
     @CommandArgument('--reviewboard-port', type=int,