testing: add --refresh-reviewboard to |mozreview refresh| (bug 1264203) r=gps draft
authorbyron jones <glob@mozilla.com>
Wed, 27 Apr 2016 22:48:24 +0800
changeset 8101 d9646f12176702bed78922f6a822ca560fd19131
parent 8100 177bb51dfc5f99539a7ec45e0c52aed578bdcb40
child 8102 53b7e5710ee70d48f46a6fa3aa24c41019e5f869
push id821
push userbjones@mozilla.com
push dateThu, 12 May 2016 05:13:51 +0000
reviewersgps
bugs1264203
testing: add --refresh-reviewboard to |mozreview refresh| (bug 1264203) r=gps By default when running |mozreview refresh| changes to reviewboard-fork/ will not be reflected inside the development instance. Specifying --refresh-reviewboard when refreshing will also update Djblets and Review Board, at the cost of taking twice as long to refresh. MozReview-Commit-ID: 2y7J1CAIK14
ansible/roles/docker-rbweb/files/refresh
ansible/roles/docker-rbweb/tasks/main.yml
testing/vcttesting/mozreview.py
testing/vcttesting/mozreview_mach_commands.py
--- a/ansible/roles/docker-rbweb/files/refresh
+++ b/ansible/roles/docker-rbweb/files/refresh
@@ -4,15 +4,20 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 set -e
 
 /usr/bin/rsync -a --delete-after $1 /vct/
 chown -R root:root /vct
 /usr/bin/rsync -rlpt /vct/ /version-control-tools/
 
+TAGS='docker-refresh'
+if [ "$2" = "all" ]; then
+  TAGS="$TAGS,docker-reviewboard-refresh"
+fi
+
 cd /version-control-tools/ansible && /usr/bin/python -u \
-  /usr/bin/ansible-playbook docker-rbweb.yml -c local -t docker-refresh
+  /usr/bin/ansible-playbook docker-rbweb.yml -c local -t $TAGS
 
 # Need to kill WSGI processes to ensure Python code is current.
 /kill-wsgi-procs
 
 echo 'refreshed rbweb container successfully'
--- a/ansible/roles/docker-rbweb/tasks/main.yml
+++ b/ansible/roles/docker-rbweb/tasks/main.yml
@@ -16,16 +16,18 @@
   synchronize: src={{ vct }}/ dest=/version-control-tools/ recursive=yes delete=yes
 
 - name: Install Djblets and Review Board
   command: /venv/bin/python setup.py install
            chdir=/version-control-tools/reviewboard-fork/{{ item }}
   with_items:
     - djblets
     - reviewboard
+  tags:
+    - docker-reviewboard-refresh
 
 - name: Install python libraries
   command: /venv/bin/python setup.py install chdir=/version-control-tools/pylib/{{ item }}
   with_items:
     - mozautomation
 
 - name: Build mozreview extension
   command: /venv/bin/python setup.py bdist_egg chdir=/version-control-tools/pylib/mozreview
--- a/testing/vcttesting/mozreview.py
+++ b/testing/vcttesting/mozreview.py
@@ -348,17 +348,17 @@ class MozReview(object):
         self.started = False
 
         if WATCHMAN:
             with open(os.devnull, 'wb') as devnull:
                 subprocess.call([WATCHMAN, 'trigger-del', ROOT,
                                  'mozreview-%s' % os.path.basename(self._path)],
                                 stdout=devnull, stderr=subprocess.STDOUT)
 
-    def refresh(self, verbose=False):
+    def refresh(self, verbose=False, refresh_reviewboard=False):
         """Refresh a running cluster with latest version of code.
 
         This only updates code from the v-c-t repo. Not all containers
         are currently updated.
         """
         with self._docker.vct_container(verbose=verbose) as vct_state:
             # We update rbweb by rsyncing state and running the refresh script.
             rsync_port = vct_state['NetworkSettings']['Ports']['873/tcp'][0]['HostPort']
@@ -371,17 +371,18 @@ class MozReview(object):
                 for msg in res:
                     if verbose:
                         msg = msg.rstrip().lstrip('\n')
                         for line in msg.splitlines():
                             if line != '':
                                 print('%s> %s' % (name, line))
 
             def refresh(name, cid):
-                execute(name, cid, ['/refresh', url])
+                execute(name, cid, ['/refresh', url,
+                                    'all' if refresh_reviewboard else ''])
 
             with futures.ThreadPoolExecutor(4) as e:
                 e.submit(refresh, 'rbweb', self.rbweb_id)
                 e.submit(refresh, 'hgrb', self.hgrb_id)
                 # TODO add hgweb support for refreshing.
                 e.submit(execute, 'bmoweb', self.bmoweb_id,
                          ['/usr/bin/supervisorctl', 'restart', 'httpd'])
 
--- a/testing/vcttesting/mozreview_mach_commands.py
+++ b/testing/vcttesting/mozreview_mach_commands.py
@@ -87,16 +87,18 @@ class MozReviewCommands(object):
         print('LDAP URI: %s' % mr.ldap_uri)
         print('HG Push URL: ssh://%s:%d/' % (mr.ssh_hostname, mr.ssh_port))
         print('')
         print('Run the following to use this instance with all future commands:')
         print('  export MOZREVIEW_HOME=%s' % mr._path)
         print('')
         print('Refresh code in the cluster by running:')
         print('  ./mozreview refresh')
+        print('  or, if you have changed reviewboard-fork/:')
+        print('  ./mozreview refresh --refresh-reviewboard')
         print('')
         print('Perform refreshing automatically by running:')
         print('  ./mozreview autorefresh')
         print('')
         print('(autorefresh requires `watchman`)')
         print('')
         print('Obtain a shell in a container by running:')
         print('  ./mozreview shell <container>')
@@ -131,19 +133,21 @@ class MozReviewCommands(object):
     def stop(self, where):
         mr = self._get_mozreview(where)
         mr.stop()
 
     @Command('refresh', category='mozreview',
              description='Refresh a running MozReview cluster with latest code')
     @CommandArgument('where', nargs='?',
                      help='Directory of MozReview instance')
-    def refresh(self, where):
+    @CommandArgument('--refresh-reviewboard', action='store_true',
+                     help='Refresh changes from reviewboard-fork')
+    def refresh(self, where, refresh_reviewboard):
         mr = self._get_mozreview(where)
-        mr.refresh(verbose=True)
+        mr.refresh(verbose=True, refresh_reviewboard=refresh_reviewboard)
 
     @Command('autorefresh', category='mozreview',
              description='Automatically refresh containers when files change')
     @CommandArgument('where', nargs='?',
                      help='Directory of MozReview instance')
     def autorefresh(self, where):
         mr = self._get_mozreview(where)
         mr.start_autorefresh()