def RunDeployCloudTasks(args): """Perform a deployment using Cloud Tasks API based on the given args. Args: args: argparse.Namespace, An object that contains the values for the arguments specified in the ArgsDeploy() function. Returns: A list of config file identifiers, see yaml_parsing.ConfigYamlInfo. """ paths = [os.path.abspath(x) for x in args.deployables] configs = [] for path in paths: if not os.path.exists(path): raise exceptions.FileNotFoundError(path) config = yaml_parsing.ConfigYamlInfo.FromFile(path) if config: configs.append(config) if configs: # TODO(b/169069379): Confirm the same metric name can be used twice in the # same run. metrics.CustomTimedEvent(metric_names.UPDATE_CONFIG_START) # TODO(b/169069379): Upgrade to use GA once the relevant code is promoted tasks_api = tasks.GetApiAdapter(base.ReleaseTrack.BETA) queues_data = app_deploy_migration_util.FetchCurrrentQueuesData( tasks_api) for config in configs: app_deploy_migration_util.ValidateYamlFileConfig(config) app_deploy_migration_util.DeployQueuesYamlFile( tasks_api, config, queues_data) metrics.CustomTimedEvent(metric_names.UPDATE_CONFIG) return [c.name for c in configs]
def testPullQueueMaxConcurrentRequests(self): config = self.GetConfig( yaml_configs.BAD_YAML_PULLQ_MAX_CONCURRENT_REQUESTS) err_msg = ( 'Max concurrent requests must not be specified for pull-based queue' ) with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueNegativeMaxBackoff(self): config = self.GetConfig( yaml_configs.BAD_YAML_PUSHQ_NEGATIVE_MAX_BACKOFF) err_msg = 'Max backoff seconds must not be less than zero' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueNegativeTaskAgeLimit(self): config = self.GetConfig( yaml_configs.BAD_YAML_PUSHQ_ZERO_TASK_AGE_LIMIT) err_msg = 'Task age limit must be greater than zero' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueNegativeRetryLimit(self): config = self.GetConfig( yaml_configs.BAD_YAML_PUSHQ_NEGATIVE_RETRY_LIMIT) err_msg = 'Task retry limit must not be less than zero' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueHighRate(self): config = self.GetConfig(yaml_configs.BAD_YAML_PUSHQ_HIGH_RATE) err_msg = 'Refill rate must not exceed' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueNoRate(self): config = self.GetConfig(yaml_configs.BAD_YAML_PUSHQ_NO_RATE) err_msg = 'Refill rate must be specified for push-based queue' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testValidateYamlFile(self): config = self.GetConfig(yaml_configs.VALID_YAML) mig_util.ValidateYamlFileConfig(config)
def testPushQueueNegativeBucketSize(self): config = self.GetConfig( yaml_configs.BAD_YAML_PUSHQ_NEGATIVE_BUCKET_SIZE) err_msg = 'Error updating queue "processInput": The queue rate is invalid' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPullQueueBucketSize(self): config = self.GetConfig(yaml_configs.BAD_YAML_PULLQ_BUCKET_SIZE) err_msg = 'Bucket size must not be specified for pull-based queue' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPullQueueMaxDoublings(self): config = self.GetConfig(yaml_configs.BAD_YAML_PULLQ_MAX_DOUBLINGS) err_msg = "Can't specify max_doublings for a pull queue" with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPullQueueMaxBackoff(self): config = self.GetConfig(yaml_configs.BAD_YAML_PULLQ_MAX_BACKOFF) err_msg = "Can't specify max_backoff_seconds for a pull queue" with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPullQueueTaskAgeLimit(self): config = self.GetConfig(yaml_configs.BAD_YAML_PULLQ_TASK_AGE_LIMIT) err_msg = "Can't specify task_age_limit for a pull queue" with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueHighBucketSize(self): config = self.GetConfig(yaml_configs.BAD_YAML_PUSHQ_HIGH_BUCKET_SIZE) err_msg = 'Error updating queue "processInput": Maximum bucket size' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueNegativeMaxDoublings(self): config = self.GetConfig( yaml_configs.BAD_YAML_PUSHQ_NEGATIVE_MAX_DOUBLINGS) err_msg = 'Max doublings must not be less than zero' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPushQueueBadMinMaxBackoff(self): config = self.GetConfig( yaml_configs.BAD_YAML_PUSHQ_BAD_MIN_MAX_BACKOFF) err_msg = 'Min backoff sec must not be greater than than max backoff sec' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)
def testPullQueueTarget(self): config = self.GetConfig(yaml_configs.BAD_YAML_PULLQ_TARGET) err_msg = 'Target must not be specified for pull-based queue' with self.assertRaisesRegex(util.RPCError, err_msg): mig_util.ValidateYamlFileConfig(config)