Umpire: migrate: Avoid re-importing modules.

Currently migrate.py will fork a process and have the child-process run
'python migrate.py -r MIGRATION_ID' to run migration scripts each time.
This is very slow because migrate.py indirectly imports many unused
modules. In this change we re-use the spawned python child-process, this
avoids re-importing those previously imported modules and makes the
migration much faster.

BUG=b:72137389
TEST=manually && ~/cros_docker.sh umpire test

Change-Id: I931650317d088bc7ab1071dde66c0d125509d9d3
Reviewed-on: https://chromium-review.googlesource.com/873251
Commit-Ready: Youcheng Syu <youcheng@chromium.org>
Tested-by: Youcheng Syu <youcheng@chromium.org>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
diff --git a/py/umpire/server/migrate.py b/py/umpire/server/migrate.py
index fefa727..bce173e 100755
--- a/py/umpire/server/migrate.py
+++ b/py/umpire/server/migrate.py
@@ -11,11 +11,11 @@
 import logging
 import os
 import re
+import sys
 
 import factory_common  # pylint: disable=unused-import
 from cros.factory.umpire.server import umpire_env
 from cros.factory.utils import json_utils
-from cros.factory.utils import process_utils
 
 
 _ENV_DIR = os.path.join('/', umpire_env.DEFAULT_BASE_DIR)
@@ -104,8 +104,11 @@
     raise RuntimeError('Cannot downgrade Umpire version.')
   while version < latest:
     version += 1
-    process_utils.Spawn(
-        [__file__, '-r', str(version)], log=True, check_call=True)
+    if os.fork() == 0:
+      _RunMigration(version)
+      sys.exit()
+    if os.wait()[1] != 0:
+      raise RuntimeError('Stop running migrations.')
 
 
 def main():