Bug 1304323 - Add the support of staged rollout in the push_apk script r?jlorenzo
MozReview-Commit-ID: 8Xgd4DEQzlE
--- a/testing/mozharness/scripts/push_apk.py
+++ b/testing/mozharness/scripts/push_apk.py
@@ -57,16 +57,21 @@ class PushAPK(BaseScript, GooglePlayMixi
[["--apk-x86"], {
"dest": "apk_file_x86",
"help": "The path to the x86 APK file",
}],
[["--apk-armv7-v15"], {
"dest": "apk_file_armv7_v15",
"help": "The path to the ARM v7 API v15 APK file",
}],
+ [["--rollout-percentage"], {
+ "dest": "rollout_percentage",
+ "help": "The rollout percentage (update percentage)",
+ "default": "None"
+ }],
]
# Google play has currently 3 tracks. Rollout deploys
# to a limited percentage of users
track_values = ("production", "beta", "alpha", "rollout")
# We have 3 apps. Make sure that their names are correct
@@ -104,23 +109,34 @@ class PushAPK(BaseScript, GooglePlayMixi
)
self.translationMgmt = storel10n(config, {})
def check_argument(self):
""" Check that the given values are correct,
files exists, etc
"""
+ if "package_name" not in self.config:
+ self.fatal("--package-name is mandatory")
+
if self.config['track'] not in self.track_values:
self.fatal("Unknown track value " + self.config['track'])
if self.config['package_name'] not in self.package_name_values:
self.fatal("Unknown package name value " +
self.config['package_name'])
+ if self.config['track'] == "rollout" and self.config["rollout_percentage"] is "None":
+ self.fatal("When using track='rollout', --rollout-percentage must be provided too")
+
+ if self.config["rollout_percentage"] is not "None":
+ self.percentage = float(self.config["rollout_percentage"])
+ if self.percentage < 0 or self.percentage > 100:
+ self.fatal("Percentage should be between 0 and 100")
+
if not os.path.isfile(self.config['apk_file_x86']):
self.fatal("Could not find " + self.config['apk_file_x86'])
if not os.path.isfile(self.config['apk_file_armv7_v15']):
self.fatal("Could not find " + self.config['apk_file_armv7_v15'])
if not os.path.isfile(self.config['google_play_credentials_file']):
self.fatal("Could not find " + self.config['google_play_credentials_file'])
@@ -161,22 +177,26 @@ class PushAPK(BaseScript, GooglePlayMixi
self.warning('Aurora is not supported by store_l10n. Skipping what\'s new.')
else:
self._push_whats_new(package_code, service, edit_id, apk_response)
except client.AccessTokenRefreshError:
self.log('The credentials have been revoked or expired,'
'please re-run the application to re-authorize')
+ upload_body = {u'versionCodes': versions}
+ if self.config["rollout_percentage"] is not "None":
+ upload_body[u'userFraction'] = self.percentage/100
+
# Set the track for all apk
service.edits().tracks().update(
editId=edit_id,
track=self.config['track'],
packageName=self.config['package_name'],
- body={u'versionCodes': versions}).execute()
+ body=upload_body).execute()
self.log('Application "%s" set to track "%s" for versions %s' %
(self.config['package_name'], self.config['track'], versions))
# Commit our changes
commit_request = service.edits().commit(
editId=edit_id, packageName=self.config['package_name']).execute()
self.log('Edit "%s" has been committed' % (commit_request['id']))