Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1078)

Unified Diff: mojo/services/upload_service.py

Issue 904443003: Support network service apptests in the upload_service script (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: associated services -> associated apps Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/upload_service.py
diff --git a/mojo/services/upload_service.py b/mojo/services/upload_service.py
index 5666dea142a317c61fa99e7ae153861e8402a5e6..d83f17823fbe2439e18e02e16fa970283313d1a6 100755
--- a/mojo/services/upload_service.py
+++ b/mojo/services/upload_service.py
@@ -12,20 +12,29 @@ import tempfile
import time
import zipfile
-# A service's name is defined as the name of its subdirectory in the directory
-# containing this file.
-SERVICES = [ "network", "html_viewer" ]
+# Uploading a service (e.g. network_service) means uploading the app binary for
+# the service (network_service.mojo), possibly binaries for associated apps
+# (network_service_apptests.mojo) and a zip with the service mojoms.
blundell 2015/02/05 13:03:22 mojos if any.
ppi 2015/02/05 13:29:07 Done.
+SERVICES = [ "html_viewer", "network_service" ]
+
+# The script will look for the mojoms in the subdirectory indicated here.
+SERVICE_DIRECTORIES = {
+ "html_viewer": "html_viewer",
+ "network_service": "network"
+}
-SERVICE_BINARY_NAMES = {
- "network" : "network_service.mojo",
- "html_viewer" : "html_viewer.mojo"
+# Binaries for the associated apps are uploaded in lockstep with the primary
+# service (e.g. network service apptests with network service). TODO(ppi):
+# remove this once we have full apptest platform coverage in Chromium.
+ASSOCIATED_APPS = {
+ "network_service" : [ "network_service_apptests" ]
}
# The network service is downloaded out-of-band rather than dynamically by the
# shell and thus can be stored zipped in the cloud. Other services are intended
# to be downloaded dynamically by the shell, which doesn't currently understand
# zipped binaries.
-SERVICES_WITH_ZIPPED_BINARIES = [ "network" ]
+SERVICES_WITH_ZIPPED_BINARIES = [ "network_service" ]
if not sys.platform.startswith("linux"):
print "Only support linux for now"
@@ -56,7 +65,7 @@ def gsutil_cp(source, dest, dry_run):
def upload_mojoms(service, dry_run):
script_dir = os.path.dirname(os.path.realpath(__file__))
- service_dir = os.path.join(script_dir, service)
+ service_dir = os.path.join(script_dir, SERVICE_DIRECTORIES[service])
absolute_mojom_directory_path = os.path.join(
service_dir,
"public",
@@ -77,18 +86,26 @@ def upload_mojoms(service, dry_run):
gsutil_cp(mojom_zip_file.name, dest, dry_run)
-def upload_binary(service, binary_dir, platform, dry_run):
- binary_name = SERVICE_BINARY_NAMES[service]
- absolute_binary_path = os.path.join(root_path, binary_dir, binary_name)
- binary_dest_prefix = "gs://mojo/" + service + "/" + version + "/" + platform
+def upload_service(service, binary_dir, platform, dry_run):
blundell 2015/02/05 13:03:22 s/upload_service/upload_apps? I would expect a fun
ppi 2015/02/05 13:29:06 Done.
+ apps = [ service ] + ASSOCIATED_APPS.get(service, [])
+ should_zip = service in SERVICES_WITH_ZIPPED_BINARIES
+
+ for app in apps:
+ dest_dir = "gs://mojo/" + app + "/" + version + "/" + platform + "/"
+ binary_name = app + ".mojo"
+ absolute_binary_path = os.path.join(root_path, binary_dir, binary_name)
+ upload_binary(absolute_binary_path, binary_name, dest_dir, should_zip,
+ dry_run)
- if service not in SERVICES_WITH_ZIPPED_BINARIES:
- binary_dest = binary_dest_prefix + "/" + binary_name
- gsutil_cp(absolute_binary_path, binary_dest, dry_run)
+def upload_binary(absolute_binary_path, binary_name, dest_dir, should_zip,
+ dry_run):
+ if not should_zip:
+ dest = dest_dir + binary_name
+ gsutil_cp(absolute_binary_path, dest, dry_run)
return
# Zip the binary before uploading it to the cloud.
- binary_dest = binary_dest_prefix + ".zip"
+ dest = dest_dir + binary_name + ".zip"
with tempfile.NamedTemporaryFile() as binary_zip_file:
with zipfile.ZipFile(binary_zip_file, 'w') as z:
with open(absolute_binary_path) as service_binary:
@@ -97,7 +114,7 @@ def upload_binary(service, binary_dir, platform, dry_run):
zipinfo.compress_type = zipfile.ZIP_DEFLATED
zipinfo.date_time = time.gmtime(os.path.getmtime(absolute_binary_path))
z.writestr(zipinfo, service_binary.read())
- gsutil_cp(binary_zip_file.name, binary_dest, dry_run)
+ gsutil_cp(binary_zip_file.name, dest, dry_run)
def main():
@@ -124,11 +141,11 @@ def main():
upload_mojoms(args.service, args.dry_run)
if args.linux_x64_binary_dir:
- upload_binary(args.service, args.linux_x64_binary_dir,
- "linux-x64", args.dry_run)
+ upload_service(args.service, args.linux_x64_binary_dir,
+ "linux-x64", args.dry_run)
blundell 2015/02/05 13:03:22 nit: indentation, here and in the corresponding li
ppi 2015/02/05 13:29:07 Done.
if args.android_arm_binary_dir:
- upload_binary(args.service, args.android_arm_binary_dir,
- "android-arm", args.dry_run)
+ upload_service(args.service, args.android_arm_binary_dir,
+ "android-arm", args.dry_run)
if not args.dry_run:
print "Uploaded artifacts for version %s" % (version, )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698