def generate_task_payload(self, flavor, properties): """Generate the task payload data for the given type of test and properties. :param flavor: Type of test to run (functional or update). :param properties: Task properties for template rendering """ template_file = os.path.join(os.path.dirname(__file__), 'tasks', '{}.yml'.format(flavor)) if not os.path.isfile(template_file): raise errors.NotSupportedException('Test type "{}" not supported.'.format(flavor)) with open(template_file) as f: template = jinja2.Template(f.read(), undefined=jinja2.StrictUndefined) template_vars = copy.deepcopy(properties) template_vars.update({ 'stableSlugId': taskcluster.stableSlugId(), 'now': taskcluster.stringDate(datetime.datetime.utcnow()), 'fromNow': taskcluster.fromNow, 'docker_task_id': self.get_docker_task_id(properties), }) rendered = template.render(**template_vars) return yaml.safe_load(rendered)
def generate_task_payload(self, flavor, properties): """Generate the task payload data for the given type of test and properties. :param flavor: Type of test to run (functional or update). :param properties: Task properties for template rendering """ template_file = os.path.join(os.path.dirname(__file__), 'tasks', '{}.yml'.format(flavor)) if not os.path.isfile(template_file): raise errors.NotSupportedException( 'Test type "{}" not supported.'.format(flavor)) with open(template_file) as f: template = jinja2.Template(f.read(), undefined=jinja2.StrictUndefined) template_vars = copy.deepcopy(properties) template_vars.update({ 'stableSlugId': taskcluster.stableSlugId(), 'now': taskcluster.stringDate(datetime.datetime.utcnow()), 'fromNow': taskcluster.fromNow, 'docker_task_id': self.get_docker_task_id(properties), }) rendered = template.render(**template_vars) return yaml.safe_load(rendered)
def createTestTask(self, flavor, payload): """Create task in Taskcluster for given type of test flavor. :param flavor: Type of test to run (functional or update). :param payload: Properties of the build and necessary resources. """ queue = taskcluster.Queue({'credentials': {'clientId': self.client_id, 'accessToken': self.authentication}}) slugid = taskcluster.stableSlugId()('fx-ui-{}'.format(flavor)) return queue.createTask(slugid, payload)
def createTestTask(self, flavor, payload): """Create task in Taskcluster for given type of test flavor. :param flavor: Type of test to run (functional or update). :param payload: Properties of the build and necessary resources. """ queue = taskcluster.Queue({ 'credentials': { 'clientId': self.client_id, 'accessToken': self.authentication } }) slugid = taskcluster.stableSlugId()('fx-ui-{}'.format(flavor)) return queue.createTask(slugid, payload)
def from_template(self, platform, revision, branch, update_number, chunk_name, subchunk, extra): """Reads and populates graph template. :param platform: buildbot platform (linux, macosx64) :param locale: en-US, de, ka, etc. :param from_mar: "from" MAR URL :param to_mar: "to" MAR URL :return: graph definition dictionary """ template_file = os.path.join(os.path.dirname(__file__), "tasks", "funsize.yml") extra_balrog_submitter_params = None if branch in STAGING_BRANCHES: extra_balrog_submitter_params = "--dummy" template_vars = { # Stable slugId "stableSlugId": stableSlugId(), # Now in ISO format "now": stringDate(datetime.datetime.utcnow()), # Now in ms "now_ms": time.time() * 1000, "fromNow": fromNow, "platform": platform, "s3_bucket": self.s3_info["s3_bucket"], "aws_access_key_id": self.s3_info["aws_access_key_id"], "aws_secret_access_key": self.s3_info["aws_secret_access_key"], "balrog_api_root": self.balrog_worker_api_root, "balrog_username": self.balrog_client.auth[0], "balrog_password": self.balrog_client.auth[1], "encryptEnvVar": encryptEnvVar_wrapper, "revision": revision, "branch": branch, "treeherder_platform": buildbot_to_treeherder(platform), "revision_hash": revision_to_revision_hash(self.th_api_root, branch, revision), "update_number": update_number, "extra_balrog_submitter_params": extra_balrog_submitter_params, "extra": extra, "chunk_name": chunk_name, "subchunk": subchunk, "sign_task": partial(sign_task, pvt_key=self.pvt_key), } with open(template_file) as f: template = Template(f.read(), undefined=StrictUndefined) rendered = template.render(**template_vars) return yaml.safe_load(rendered)
async def run( root_url: str, queue_id: str = "proj-taskcluster/gw-ci-ubuntu-18-04", command: str = "/bin/echo 'hola mundo!'", task_source_url: str = "", deadline_seconds: int = 3 * 60 * 60, expires_seconds: int = 24 * 60 * 60, max_run_time: int = 10 * 60, client_id: str = "", access_token: str = "", certificate: str = "", ) -> CheckResult: # Build connection infos from parameters. options = tc_utils.options_from_params(root_url, client_id, access_token, certificate) queue = taskcluster.aio.Queue(options) name = "task-test" task_id = taskcluster.stableSlugId()(name) # type: ignore now = datetime.utcnow() deadline = now + timedelta(seconds=deadline_seconds) expires = now + timedelta(seconds=expires_seconds) payload = { "taskQueueId": queue_id, "created": now.isoformat(), "deadline": deadline.isoformat(), "expires": expires.isoformat(), "payload": { "command": [shlex.split(cmd) for cmd in command.splitlines()], "maxRunTime": max_run_time, }, "metadata": { **TASK_METADATA, "name": name, "source": task_source_url or config.SOURCE_URL, }, } status = await queue.createTask(task_id, payload) return True, status["status"]
claims = { "iat": iat, "exp": exp, "taskId": task_id, "version": "1", } return jws.sign(claims, pvt_key, algorithm=algorithm) config = json.load(open("secrets.json")) config["credentials"]["certificate"] = json.dumps(config["credentials"]["certificate"]) scheduler = taskcluster.Scheduler(config) # funsize scheduler key pvt_key = open("id_rsa").read() template_vars = { "stableSlugId": stableSlugId(), "now": stringDate(datetime.datetime.utcnow()), "now_ms": time.time() * 1000, "fromNow": fromNow, "sign_task": partial(sign_task, pvt_key=pvt_key), ### TODO: change these "url": "http://people.mozilla.org/~raliiev/bouncer.apk", "filename": "bouncer.apk", "signign_format": "jar", "hash": "8f4210c62cf533322b09237a3741bc3e9bb52582b8d0b88c52a0d78a6eabe08e29b636d5c9668e8db721c9dead36736db643c53231e966c86dbc28d86b9eb699", } template_file = os.path.join(os.path.dirname(__file__), "graph.yml") with open(template_file) as f: template = Template(f.read(), undefined=StrictUndefined) rendered = template.render(**template_vars)
def from_template(self, platform, revision, branch, update_number, locale_desc, extra, mar_signing_format, task_group_id, atomic_task_id): """Reads and populates graph template. :param platform: buildbot platform (linux, macosx64) :param locale: en-US, de, ka, etc. :param from_mar: "from" MAR URL :param to_mar: "to" MAR URL :return: graph definition dictionary """ template_file = os.path.join(os.path.dirname(__file__), "tasks", "funsize.yml") extra_balrog_submitter_params = None if branch in STAGING_BRANCHES: extra_balrog_submitter_params = "--dummy" template_vars = { # Stable slugId "stableSlugId": stableSlugId(), # Now in ISO format "now": stringDate(datetime.datetime.utcnow()), # Now in ms "now_ms": time.time() * 1000, "fromNow": fromNow, "platform": platform, "s3_bucket": self.s3_info["s3_bucket"], "aws_access_key_id": self.s3_info["aws_access_key_id"], "aws_secret_access_key": self.s3_info["aws_secret_access_key"], "balrog_api_root": self.balrog_worker_api_root, "balrog_username": self.balrog_client.auth[0], "balrog_password": self.balrog_client.auth[1], "encryptEnvVar": encryptEnvVar_wrapper, "revision": revision, "branch": branch, "locale_desc": locale_desc, "treeherder_platform": buildbot_to_treeherder(platform), "revision_hash": revision_to_revision_hash(self.th_api_root, branch, revision), "update_number": update_number, "extra_balrog_submitter_params": extra_balrog_submitter_params, "extra": extra, "sign_task": partial(sign_task, pvt_key=self.pvt_key), "mar_signing_format": mar_signing_format, "task_group_id": task_group_id, "atomic_task_id": atomic_task_id, } with open(template_file) as f: template = Template(f.read(), undefined=StrictUndefined) rendered = template.render(**template_vars) return yaml.safe_load(rendered)