コード例 #1
0
ファイル: clusters.py プロジェクト: bopopescu/facerec-1
def ArgsForClusterRef(parser, beta=False):
    """Register flags for creating a dataproc cluster.

  Args:
    parser: The argparse.ArgParser to configure with dataproc cluster arguments.
    beta: whether or not this is a beta command (may affect flag visibility)
  """
    labels_util.AddCreateLabelsFlags(parser)
    instances_flags.AddTagsArgs(parser)
    # 30m is backend timeout + 5m for safety buffer.
    flags.AddTimeoutFlag(parser, default='35m')
    flags.AddZoneFlag(parser)

    parser.add_argument(
        '--metadata',
        type=arg_parsers.ArgDict(min_length=1),
        action='append',
        default=None,
        help=('Metadata to be made available to the guest operating system '
              'running on the instances'),
        metavar='KEY=VALUE')

    # Either allow creating a single node cluster (--single-node), or specifying
    # the number of workers in the multi-node cluster (--num-workers and
    # --num-preemptible-workers)
    node_group = parser.add_argument_group(mutex=True)  # Mutually exclusive
    node_group.add_argument('--single-node',
                            action='store_true',
                            help="""\
      Create a single node cluster.

      A single node cluster has all master and worker components.
      It cannot have any separate worker nodes. If this flag is not
      specified, a cluster with separate workers is created.
      """)
    # Not mutually exclusive
    worker_group = node_group.add_argument_group(
        help='Multi-node cluster flags')
    worker_group.add_argument(
        '--num-workers',
        type=int,
        help='The number of worker nodes in the cluster. Defaults to '
        'server-specified.')
    worker_group.add_argument(
        '--num-preemptible-workers',
        type=int,
        help='The number of preemptible worker nodes in the cluster.')

    parser.add_argument(
        '--master-machine-type',
        help='The type of machine to use for the master. Defaults to '
        'server-specified.')
    parser.add_argument(
        '--worker-machine-type',
        help='The type of machine to use for workers. Defaults to '
        'server-specified.')
    if beta:
        image_parser = parser.add_mutually_exclusive_group()
        # TODO(b/73291743): Add external doc link to --image
        image_parser.add_argument(
            '--image',
            metavar='IMAGE',
            help='The full custom image URI or the custom image name that '
            'will be used to create a cluster.')
        image_parser.add_argument(
            '--image-version',
            metavar='VERSION',
            help='The image version to use for the cluster. Defaults to the '
            'latest version.')
    else:
        parser.add_argument(
            '--image',
            hidden=True,
            help='The full image URI to use with the cluster. Overrides '
            '--image-version.')
        parser.add_argument(
            '--image-version',
            metavar='VERSION',
            help='The image version to use for the cluster. Defaults to the '
            'latest version.')

    parser.add_argument(
        '--bucket',
        help='The Google Cloud Storage bucket to use with the Google Cloud '
        'Storage connector. A bucket is auto created when this parameter is '
        'not specified.')

    netparser = parser.add_mutually_exclusive_group()
    netparser.add_argument('--network',
                           help="""\
      The Compute Engine network that the VM instances of the cluster will be
      part of. This is mutually exclusive with --subnet. If neither is
      specified, this defaults to the "default" network.
      """)
    netparser.add_argument('--subnet',
                           help="""\
      Specifies the subnet that the cluster will be part of. This is mutally
      exclusive with --network.
      """)
    parser.add_argument(
        '--num-worker-local-ssds',
        type=int,
        help='The number of local SSDs to attach to each worker in a cluster.')
    parser.add_argument(
        '--num-master-local-ssds',
        type=int,
        help='The number of local SSDs to attach to the master in a cluster.')
    parser.add_argument(
        '--initialization-actions',
        type=arg_parsers.ArgList(min_length=1),
        metavar='CLOUD_STORAGE_URI',
        help=('A list of Google Cloud Storage URIs of '
              'executables to run on each node in the cluster.'))
    parser.add_argument(
        '--initialization-action-timeout',
        type=arg_parsers.Duration(),
        metavar='TIMEOUT',
        default='10m',
        help=('The maximum duration of each initialization action. See '
              '$ gcloud topic datetimes for information on duration formats.'))
    parser.add_argument(
        '--num-masters',
        type=arg_parsers.CustomFunctionValidator(
            lambda n: int(n) in [1, 3],
            'Number of masters must be 1 (Standard) or 3 (High Availability)',
            parser=arg_parsers.BoundedInt(1, 3)),
        help="""\
      The number of master nodes in the cluster.

      [format="csv",options="header"]
      |========
      Number of Masters,Cluster Mode
      1,Standard
      3,High Availability
      |========
      """)
    parser.add_argument('--properties',
                        type=arg_parsers.ArgDict(),
                        metavar='PREFIX:PROPERTY=VALUE',
                        default={},
                        help="""\
Specifies configuration properties for installed packages, such as Hadoop
and Spark.

Properties are mapped to configuration files by specifying a prefix, such as
"core:io.serializations". The following are supported prefixes and their
mappings:

[format="csv",options="header"]
|========
Prefix,File,Purpose of file
capacity-scheduler,capacity-scheduler.xml,Hadoop YARN Capacity Scheduler configuration
core,core-site.xml,Hadoop general configuration
distcp,distcp-default.xml,Hadoop Distributed Copy configuration
hadoop-env,hadoop-env.sh,Hadoop specific environment variables
hdfs,hdfs-site.xml,Hadoop HDFS configuration
hive,hive-site.xml,Hive configuration
mapred,mapred-site.xml,Hadoop MapReduce configuration
mapred-env,mapred-env.sh,Hadoop MapReduce specific environment variables
pig,pig.properties,Pig configuration
spark,spark-defaults.conf,Spark configuration
spark-env,spark-env.sh,Spark specific environment variables
yarn,yarn-site.xml,Hadoop YARN configuration
yarn-env,yarn-env.sh,Hadoop YARN specific environment variables
|========

See https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/cluster-properties
for more information.

""")
    parser.add_argument(
        '--service-account',
        help='The Google Cloud IAM service account to be authenticated as.')
    parser.add_argument('--scopes',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SCOPE',
                        help="""\
Specifies scopes for the node instances. The project's default service account
is used. Multiple SCOPEs can specified, separated by commas.
Examples:

  $ {{command}} example-cluster --scopes https://www.googleapis.com/auth/bigtable.admin

  $ {{command}} example-cluster --scopes sqlservice,bigquery

The following scopes necessary for the cluster to function properly are always
added, even if not explicitly specified:

[format="csv"]
|========
{minimum_scopes}
|========

If this flag is not specified the following default scopes are also included:

[format="csv"]
|========
{additional_scopes}
|========

If you want to enable all scopes use the 'cloud-platform' scope.

SCOPE can be either the full URI of the scope or an alias.
Available aliases are:

[format="csv",options="header"]
|========
Alias,URI
{aliases}
|========

{scope_deprecation_msg}
""".format(minimum_scopes='\n'.join(constants.MINIMUM_SCOPE_URIS),
           additional_scopes='\n'.join(
               constants.ADDITIONAL_DEFAULT_SCOPE_URIS),
           aliases=compute_helpers.SCOPE_ALIASES_FOR_HELP,
           scope_deprecation_msg=compute_constants.DEPRECATED_SCOPES_MESSAGES))

    master_boot_disk_size = parser.add_mutually_exclusive_group()
    worker_boot_disk_size = parser.add_mutually_exclusive_group()

    # Deprecated, to be removed at a future date.
    master_boot_disk_size.add_argument(
        '--master-boot-disk-size-gb',
        action=actions.DeprecationAction(
            '--master-boot-disk-size-gb',
            warn=(
                'The `--master-boot-disk-size-gb` flag is deprecated. '
                'Use `--master-boot-disk-size` flag with "GB" after value.')),
        type=int,
        hidden=True,
        help='Use `--master-boot-disk-size` flag with "GB" after value.')
    worker_boot_disk_size.add_argument(
        '--worker-boot-disk-size-gb',
        action=actions.DeprecationAction(
            '--worker-boot-disk-size-gb',
            warn=(
                'The `--worker-boot-disk-size-gb` flag is deprecated. '
                'Use `--worker-boot-disk-size` flag with "GB" after value.')),
        type=int,
        hidden=True,
        help='Use `--worker-boot-disk-size` flag with "GB" after value.')

    boot_disk_size_detailed_help = """\
      The size of the boot disk. The value must be a
      whole number followed by a size unit of ``KB'' for kilobyte, ``MB''
      for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For example,
      ``10GB'' will produce a 10 gigabyte disk. The minimum size a boot disk
      can have is 10 GB. Disk size must be a multiple of 1 GB.
      """
    master_boot_disk_size.add_argument(
        '--master-boot-disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help=boot_disk_size_detailed_help)
    worker_boot_disk_size.add_argument(
        '--worker-boot-disk-size',
        type=arg_parsers.BinarySize(lower_bound='10GB'),
        help=boot_disk_size_detailed_help)
    parser.add_argument('--preemptible-worker-boot-disk-size',
                        type=arg_parsers.BinarySize(lower_bound='10GB'),
                        help=boot_disk_size_detailed_help)

    # Args that are visible only in Beta track
    parser.add_argument('--no-address',
                        action='store_true',
                        help="""\
      If provided, the instances in the cluster will not be assigned external
      IP addresses.

      Note: Dataproc VMs need access to the Dataproc API. This can be achieved
      without external IP addresses using Private Google Access
      (https://cloud.google.com/compute/docs/private-google-access).
      """,
                        hidden=not beta)

    if beta:
        boot_disk_type_detailed_help = """\
        The type of the boot disk. The value must be ``pd-standard'' or
        ``pd-ssd''.
        """
        parser.add_argument('--master-boot-disk-type',
                            help=boot_disk_type_detailed_help)
        parser.add_argument('--worker-boot-disk-type',
                            help=boot_disk_type_detailed_help)
        parser.add_argument('--preemptible-worker-boot-disk-type',
                            help=boot_disk_type_detailed_help)
コード例 #2
0
def AddAndroidTestArgs(parser):
    """Register args which are specific to Android test commands.

  Args:
    parser: An argparse parser used to add arguments that follow a command in
        the CLI.
  """
    parser.add_argument(
        '--app',
        category=base.COMMONLY_USED_FLAGS,
        help='The path to the application binary file. The path may be in the '
        'local filesystem or in Google Cloud Storage using gs:// notation.')
    parser.add_argument(
        '--app-package',
        help=
        'The Java package of the application under test (default: extracted '
        'from the APK manifest).')
    parser.add_argument(
        '--auto-google-login',
        action='store_true',
        default=None,
        help='Automatically log into the test device using a preconfigured '
        'Google account before beginning the test. Enabled by default, use '
        '--no-auto-google-login to disable.')
    parser.add_argument(
        '--directories-to-pull',
        type=arg_parsers.ArgList(),
        metavar='DIR_TO_PULL',
        help='A list of paths that will be copied from the device\'s storage to '
        'the designated results bucket after the test is complete. These must be '
        'absolute paths under `/sdcard` or `/data/local/tmp` (for example, '
        '`--directories-to-pull /sdcard/tempDir1,/data/local/tmp/tempDir2`). '
        'Path names are restricted to the characters ```a-zA-Z0-9_-./+```. '
        'The paths `/sdcard` and `/data` will be made available and treated as '
        'implicit path substitutions. E.g. if `/sdcard` on a particular device '
        'does not map to external storage, the system will replace it with the '
        'external storage path prefix for that device.')
    parser.add_argument(
        '--environment-variables',
        type=arg_parsers.ArgDict(),
        metavar='KEY=VALUE',
        help='A comma-separated, key=value, map of environment variables and '
        'their desired values. The environment variables passed here will '
        'be mirrored on to the adb run command. For example, specify '
        '--environment-variables '
        'coverage=true,coverageFile="/sdcard/coverage.ec" to enable code '
        'coverage and provide a file path to store the coverage results.')
    parser.add_argument(
        '--obb-files',
        type=arg_parsers.ArgList(min_length=1, max_length=2),
        metavar='OBB_FILE',
        help='A list of one or two Android OBB file names which will be copied '
        'to each test device before the tests will run (default: None). Each '
        'OBB file name must conform to the format as specified by Android (e.g. '
        '[main|patch].0300110.com.example.android.obb) and will be installed '
        'into <shared-storage>/Android/obb/<package-name>/ on the test device.'
    )
    parser.add_argument(
        '--performance-metrics',
        action='store_true',
        default=None,
        help=
        'Monitor and record performance metrics: CPU, memory, network usage,'
        ' and FPS (game-loop only). Enabled by default, use '
        '--no-performance-metrics to disable.')
    parser.add_argument(
        '--results-history-name',
        help=
        'The history name for your test results (an arbitrary string label; '
        'default: the application\'s label from the APK manifest). All tests '
        'which use the same history name will have their results grouped '
        'together in the Firebase console in a time-ordered test history list.'
    )
    parser.add_argument('--type',
                        category=base.COMMONLY_USED_FLAGS,
                        choices=['instrumentation', 'robo', 'game-loop'],
                        help='The type of test to run.')

    # The following args are specific to Android instrumentation tests.

    parser.add_argument(
        '--test',
        category=base.COMMONLY_USED_FLAGS,
        help='The path to the binary file containing instrumentation tests. The '
        'given path may be in the local filesystem or in Google Cloud Storage '
        'using a URL beginning with `gs://`.')
    parser.add_argument(
        '--test-package',
        category=ANDROID_INSTRUMENTATION_TEST,
        help='The Java package name of the instrumentation test (default: '
        'extracted from the APK manifest).')
    parser.add_argument(
        '--test-runner-class',
        category=ANDROID_INSTRUMENTATION_TEST,
        help='The fully-qualified Java class name of the instrumentation test '
        'runner (default: the last name extracted from the APK manifest).')
    parser.add_argument(
        '--test-targets',
        category=ANDROID_INSTRUMENTATION_TEST,
        type=arg_parsers.ArgList(min_length=1),
        metavar='TEST_TARGET',
        help='A list of one or more instrumentation test targets to be run '
        '(default: all targets). Each target must be fully qualified with the '
        'package name or class name, in one of these formats:\n'
        '* "package package_name"\n'
        '* "class package_name.class_name"\n'
        '* "class package_name.class_name#method_name".')
    parser.add_argument(
        '--use-orchestrator',
        category=ANDROID_INSTRUMENTATION_TEST,
        action='store_true',
        default=None,
        help='Whether each test runs in its own Instrumentation instance with '
        'the Android Test Orchestrator (default: Orchestrator is not used, same '
        'as specifying --no-use-orchestrator). Orchestrator is only compatible '
        'with AndroidJUnitRunner v1.0 or higher. See '
        'https://developer.android.com/training/testing/junit-runner.html'
        '#using-android-test-orchestrator for more information about Android '
        'Test Orchestrator.')

    # The following args are specific to Android Robo tests.

    parser.add_argument(
        '--max-steps',
        action=actions.DeprecationAction(
            '--max-steps',
            warn=('The `--max-steps` flag is deprecated and no longer has any '
                  'effect on the Robo crawler. The `--timeout` flag may be '
                  'optionally used to limit the maximum length of a Robo test.'
                  )),
        metavar='int',
        category=ANDROID_ROBO_TEST,
        type=arg_validate.NONNEGATIVE_INT_PARSER,
        help='The maximum number of steps/actions a Robo test can execute '
        '(default: no limit).')
    parser.add_argument(
        '--max-depth',
        action=actions.DeprecationAction(
            '--max-depth',
            warn=('The `--max-depth` flag is deprecated and no longer has any '
                  'effect on the actions of the Robo crawler.')),
        metavar='int',
        category=ANDROID_ROBO_TEST,
        type=arg_validate.POSITIVE_INT_PARSER,
        help='The maximum depth of the traversal stack a Robo test can explore. '
        'Needs to be at least 2 to make Robo explore the app beyond the first '
        'activity (default: 50).')
    parser.add_argument(
        '--app-initial-activity',
        action=actions.DeprecationAction(
            '--app-initial-activity',
            warn=
            ('The `--app-initial-activity` flag is deprecated and no longer '
             'has any effect on the Robo crawler. Alternatively, the '
             '`--robo-script` flag (in beta) can be used to guide Robo to a '
             'specific part of your app before the Robo test begins.')),
        category=ANDROID_ROBO_TEST,
        help='The initial activity used to start the app during a Robo test.')
    parser.add_argument(
        '--robo-directives',
        metavar='TYPE:RESOURCE_NAME=INPUT',
        category=ANDROID_ROBO_TEST,
        type=arg_parsers.ArgDict(),
        help='A comma-separated (`<type>:<key>=<value>`) map of '
        '`robo_directives` that you can use to customize the behavior of Robo '
        'test. The `type` specifies the action type of the directive, which may '
        'take on values `click` or `text`. If no `type` is provided, `text` will '
        'be used by default. Each key should be the Android resource name of a '
        'target UI element and each value should be the text input for that '
        'element. Values are only permitted for `text` type elements, so no '
        'value should be specified for `click` type elements. For example, use'
        '\n\n'
        '    --robo-directives text:username_resource=username,'
        'text:password_resource=password'
        '\n\n'
        'to provide custom login credentials for your app, or'
        '\n\n'
        '    --robo-directives click:sign_in_button='
        '\n\n'
        'to instruct Robo to click on the sign in button. To learn more about '
        'Robo test and robo_directives, see '
        'https://firebase.google.com/docs/test-lab/command-line'
        '#custom_login_and_text_input_with_robo_test.'
        '\n\n'
        'Caution: You should only use credentials for test accounts that are not '
        'associated with real users.')

    # The following args are specific to Android game-loop tests.

    parser.add_argument(
        '--scenario-numbers',
        metavar='int',
        type=arg_parsers.ArgList(element_type=int,
                                 min_length=1,
                                 max_length=1024),
        category=ANDROID_GAME_LOOP_TEST,
        help='A list of game-loop scenario numbers which will be run as part of '
        'the test (default: all scenarios). A maximum of 1024 scenarios may be '
        'specified in one test matrix, but the maximum number may also be '
        'limited by the overall test *--timeout* setting.')

    parser.add_argument(
        '--scenario-labels',
        metavar='LABEL',
        type=arg_parsers.ArgList(min_length=1),
        category=ANDROID_GAME_LOOP_TEST,
        help='A list of game-loop scenario labels (default: None). '
        'Each game-loop scenario may be labeled in the APK manifest file with '
        'one or more arbitrary strings, creating logical groupings (e.g. '
        'GPU_COMPATIBILITY_TESTS). If *--scenario-numbers* and '
        '*--scenario-labels* are specified together, Firebase Test Lab will '
        'first execute each scenario from *--scenario-numbers*. It will then '
        'expand each given scenario label into a list of scenario numbers marked '
        'with that label, and execute those scenarios.')
コード例 #3
0
def _Args(parser):
  """Register flags for this command.

  Args:
    parser: An argparse.ArgumentParser-like object. It is mocked out in order to
      capture some information, but behaves like an ArgumentParser.
  """
  parser.add_argument(
      'name',
      help="""\
The name of the cluster to create.

The name may contain only lowercase alphanumerics and '-', must start with a
letter and end with an alphanumeric, and must be no longer than 40
characters.
""")
  # Timeout in seconds for operation
  parser.add_argument(
      '--timeout',
      type=int,
      default=1800,
      hidden=True,
      help='THIS ARGUMENT NEEDS HELP TEXT.')
  flags.AddAsyncFlag(parser)
  parser.add_argument(
      '--num-nodes',
      type=arg_parsers.BoundedInt(1),
      help='The number of nodes to be created in each of the cluster\'s zones.',
      default=3)
  flags.AddMachineTypeFlag(parser)
  parser.add_argument(
      '--subnetwork',
      help="""\
The Google Compute Engine subnetwork
(https://cloud.google.com/compute/docs/subnetworks) to which the cluster is
connected. The subnetwork must belong to the network specified by --network.

Cannot be used with the "--create-subnetwork" option.
""")
  parser.add_argument(
      '--network',
      help='The Compute Engine Network that the cluster will connect to. '
      'Google Kubernetes Engine will use this network when creating routes '
      'and firewalls for the clusters. Defaults to the \'default\' network.')
  parser.add_argument(
      '--cluster-ipv4-cidr',
      help='The IP address range for the pods in this cluster in CIDR '
      'notation (e.g. 10.0.0.0/14).  Prior to Kubernetes version 1.7.0 '
      'this must be a subset of 10.0.0.0/8; however, starting with version '
      '1.7.0 can be any RFC 1918 IP range.')
  parser.add_argument(
      '--enable-cloud-logging',
      action=actions.DeprecationAction(
          '--enable-cloud-logging',
          warn='From 1.14, legacy Stackdriver GKE logging is deprecated. Thus, '
          'flag `--enable-cloud-logging` is also deprecated. Please use '
          '`--enable-stackdriver-kubernetes` instead, to migrate to new '
          'Stackdriver Kubernetes Engine monitoring and logging. For more '
          'details, please read: '
          'https://cloud.google.com/monitoring/kubernetes-engine/migration.',
          action='store_true'),
      help='Automatically send logs from the cluster to the Google Cloud '
      'Logging API. This flag is deprecated, use '
      '`--enable-stackdriver-kubernetes` instead.')
  parser.add_argument(
      '--enable-cloud-monitoring',
      action=actions.DeprecationAction(
          '--enable-cloud-monitoring',
          warn='From 1.14, legacy Stackdriver GKE monitoring is deprecated. '
          'Thus, flag `--enable-cloud-monitoring` is also deprecated. Please '
          'use `--enable-stackdriver-kubernetes` instead, to migrate to new '
          'Stackdriver Kubernetes Engine monitoring and logging. For more '
          'details, please read: '
          'https://cloud.google.com/monitoring/kubernetes-engine/migration.',
          action='store_true'),
      help='Automatically send metrics from pods in the cluster to the Google '
      'Cloud Monitoring API. VM metrics will be collected by Google Compute '
      'Engine regardless of this setting. This flag is deprecated, use '
      '`--enable-stackdriver-kubernetes` instead.')
  parser.add_argument(
      '--disk-size',
      type=arg_parsers.BinarySize(lower_bound='10GB'),
      help='Size for node VM boot disks. Defaults to 100GB.')
  flags.AddBasicAuthFlags(parser)
  parser.add_argument(
      '--max-nodes-per-pool',
      type=arg_parsers.BoundedInt(100, api_adapter.MAX_NODES_PER_POOL),
      help='The maximum number of nodes to allocate per default initial node '
      'pool. Kubernetes Engine will automatically create enough nodes pools '
      'such that each node pool contains less than '
      '--max-nodes-per-pool nodes. Defaults to {nodes} nodes, but can be set '
      'as low as 100 nodes per pool on initial create.'.format(
          nodes=api_adapter.MAX_NODES_PER_POOL))
  flags.AddImageTypeFlag(parser, 'cluster')
  flags.AddImageFlag(parser, hidden=True)
  flags.AddImageProjectFlag(parser, hidden=True)
  flags.AddImageFamilyFlag(parser, hidden=True)
  flags.AddNodeLabelsFlag(parser)
  flags.AddTagsFlag(
      parser, """\
Applies the given Compute Engine tags (comma separated) on all nodes in the new
node-pool. Example:

  $ {command} example-cluster --tags=tag1,tag2

New nodes, including ones created by resize or recreate, will have these tags
on the Compute Engine API instance object and can be used in firewall rules.
See https://cloud.google.com/sdk/gcloud/reference/compute/firewall-rules/create
for examples.
""")
  parser.display_info.AddFormat(util.CLUSTERS_FORMAT)
  flags.AddIssueClientCertificateFlag(parser)
  flags.AddAcceleratorArgs(parser)
  flags.AddDiskTypeFlag(parser)
  flags.AddMetadataFlags(parser)
コード例 #4
0
def AddAndroidTestArgs(parser):
  """Register args which are specific to Android test commands.

  Args:
    parser: An argparse parser used to add arguments that follow a command in
        the CLI.
  """
  parser.add_argument(
      '--app',
      category=base.COMMONLY_USED_FLAGS,
      help='The path to the application binary file. The path may be in the '
      'local filesystem or in Google Cloud Storage using gs:// notation. '
      'Android App Bundles are specified as .aab, all other files are assumed '
      'to be APKs.')
  parser.add_argument(
      '--app-package',
      action=actions.DeprecationAction(
          '--app-package',
          warn=('The `--app-package` flag is deprecated and should no longer '
                'be used. By default, the correct application package name is '
                'parsed from the APK manifest.')),
      help='The Java package of the application under test (default: extracted '
      'from the APK manifest).')
  parser.add_argument(
      '--auto-google-login',
      action='store_true',
      default=None,
      help='Automatically log into the test device using a preconfigured '
      'Google account before beginning the test. Enabled by default, use '
      '--no-auto-google-login to disable.')
  parser.add_argument(
      '--directories-to-pull',
      type=arg_parsers.ArgList(),
      metavar='DIR_TO_PULL',
      help='A list of paths that will be copied from the device\'s storage to '
      'the designated results bucket after the test is complete. These must be '
      'absolute paths under `/sdcard` or `/data/local/tmp` (for example, '
      '`--directories-to-pull /sdcard/tempDir1,/data/local/tmp/tempDir2`). '
      'Path names are restricted to the characters ```a-zA-Z0-9_-./+```. '
      'The paths `/sdcard` and `/data` will be made available and treated as '
      'implicit path substitutions. E.g. if `/sdcard` on a particular device '
      'does not map to external storage, the system will replace it with the '
      'external storage path prefix for that device.')
  parser.add_argument(
      '--environment-variables',
      type=arg_parsers.ArgDict(),
      metavar='KEY=VALUE',
      help="""\
      A comma-separated, key=value map of environment variables and their
      desired values. The environment variables are mirrored as extra options to
      the `am instrument -e KEY1 VALUE1 ...` command and passed to your test
      runner (typically AndroidJUnitRunner). Examples:

      Break test cases into four shards and run only the first shard:

      ```
      --environment-variables numShards=4,shardIndex=0
      ```

      Enable code coverage and provide a directory to store the coverage
      results when using Android Test Orchestrator (`--use-orchestrator`):

      ```
      --environment-variables clearPackageData=true,coverage=true,coverageFilePath=/sdcard/
      ```

      Enable code coverage and provide a file path to store the coverage
      results when *not* using Android Test Orchestrator
      (`--no-use-orchestrator`):

      ```
      --environment-variables coverage=true,coverageFile=/sdcard/coverage.ec
      ```

      Note: If you need to embed a comma into a `VALUE` string, please refer to
      `gcloud topic escaping` for ways to change the default list delimiter.
      """)
  parser.add_argument(
      '--obb-files',
      type=arg_parsers.ArgList(min_length=1, max_length=2),
      metavar='OBB_FILE',
      help='A list of one or two Android OBB file names which will be copied '
      'to each test device before the tests will run (default: None). Each '
      'OBB file name must conform to the format as specified by Android (e.g. '
      '[main|patch].0300110.com.example.android.obb) and will be installed '
      'into <shared-storage>/Android/obb/<package-name>/ on the test device.')
  parser.add_argument(
      '--performance-metrics',
      action='store_true',
      default=None,
      help='Monitor and record performance metrics: CPU, memory, network usage,'
      ' and FPS (game-loop only). Enabled by default, use '
      '--no-performance-metrics to disable.')
  parser.add_argument(
      '--results-history-name',
      help='The history name for your test results (an arbitrary string label; '
      'default: the application\'s label from the APK manifest). All tests '
      'which use the same history name will have their results grouped '
      'together in the Firebase console in a time-ordered test history list.')
  parser.add_argument(
      '--type',
      category=base.COMMONLY_USED_FLAGS,
      choices=['instrumentation', 'robo', 'game-loop'],
      help='The type of test to run.')

  # The following args are specific to Android instrumentation tests.

  parser.add_argument(
      '--test',
      category=base.COMMONLY_USED_FLAGS,
      help='The path to the binary file containing instrumentation tests. The '
      'given path may be in the local filesystem or in Google Cloud Storage '
      'using a URL beginning with `gs://`.')
  parser.add_argument(
      '--test-package',
      action=actions.DeprecationAction(
          '--test-package',
          warn=('The `--test-package` flag is deprecated and should no longer '
                'be used. By default, the correct test package name is '
                'parsed from the APK manifest.')),
      category=ANDROID_INSTRUMENTATION_TEST,
      help='The Java package name of the instrumentation test (default: '
      'extracted from the APK manifest).')
  parser.add_argument(
      '--test-runner-class',
      category=ANDROID_INSTRUMENTATION_TEST,
      help='The fully-qualified Java class name of the instrumentation test '
      'runner (default: the last name extracted from the APK manifest).')
  parser.add_argument(
      '--test-targets',
      category=ANDROID_INSTRUMENTATION_TEST,
      type=arg_parsers.ArgList(min_length=1),
      metavar='TEST_TARGET',
      help="""\
      A list of one or more test target filters to apply (default: run all test
      targets). Each target filter must be fully qualified with the package
      name, class name, or test annotation desired. Any test filter supported by
      `am instrument -e ...` is supported. See
       https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner
       for more information. Examples:

         * `--test-targets "package com.my.package.name"`
         * `--test-targets "notPackage com.package.to.skip"`
         * `--test-targets "class com.foo.ClassName"`
         * `--test-targets "notClass com.foo.ClassName#testMethodToSkip"`
         * `--test-targets "annotation com.foo.AnnotationToRun"`
         * `--test-targets "size large notAnnotation com.foo.AnnotationToSkip"`
      """)
  parser.add_argument(
      '--use-orchestrator',
      category=ANDROID_INSTRUMENTATION_TEST,
      action='store_true',
      default=None,
      help='Whether each test runs in its own Instrumentation instance with '
      'the Android Test Orchestrator (default: Orchestrator is not used, same '
      'as specifying --no-use-orchestrator). Orchestrator is only compatible '
      'with AndroidJUnitRunner v1.0 or higher. See '
      'https://developer.android.com/training/testing/junit-runner.html'
      '#using-android-test-orchestrator for more information about Android '
      'Test Orchestrator.')

  # The following args are specific to Android Robo tests.

  parser.add_argument(
      '--robo-directives',
      metavar='TYPE:RESOURCE_NAME=INPUT',
      category=ANDROID_ROBO_TEST,
      type=arg_parsers.ArgDict(),
      help='A comma-separated (`<type>:<key>=<value>`) map of '
      '`robo_directives` that you can use to customize the behavior of Robo '
      'test. The `type` specifies the action type of the directive, which may '
      'take on values `click`, `text` or `ignore`. If no `type` is provided, '
      '`text` will be used by default. Each key should be the Android resource '
      'name of a target UI element and each value should be the text input for '
      'that element. Values are only permitted for `text` type elements, so no '
      'value should be specified for `click` and `ignore` type elements.'
      '\n\n'
      'To provide custom login credentials for your app, use'
      '\n\n'
      '    --robo-directives text:username_resource=username,'
      'text:password_resource=password'
      '\n\n'
      'To instruct Robo to click on the sign-in button, use'
      '\n\n'
      '    --robo-directives click:sign_in_button='
      '\n\n'
      'To instruct Robo to ignore any UI elements with resource names which '
      'equal or start with the user-defined value, use'
      '\n\n'
      '  --robo-directives ignore:ignored_ui_element_resource_name='
      '\n\n'
      'To learn more about Robo test and robo_directives, see '
      'https://firebase.google.com/docs/test-lab/android/command-line#custom_login_and_text_input_with_robo_test.'
      '\n\n'
      'Caution: You should only use credentials for test accounts that are not '
      'associated with real users.')

  # The following args are specific to Android game-loop tests.

  parser.add_argument(
      '--scenario-numbers',
      metavar='int',
      type=arg_parsers.ArgList(element_type=int, min_length=1, max_length=1024),
      category=ANDROID_GAME_LOOP_TEST,
      help='A list of game-loop scenario numbers which will be run as part of '
      'the test (default: all scenarios). A maximum of 1024 scenarios may be '
      'specified in one test matrix, but the maximum number may also be '
      'limited by the overall test *--timeout* setting.')

  parser.add_argument(
      '--scenario-labels',
      metavar='LABEL',
      type=arg_parsers.ArgList(min_length=1),
      category=ANDROID_GAME_LOOP_TEST,
      help='A list of game-loop scenario labels (default: None). '
      'Each game-loop scenario may be labeled in the APK manifest file with '
      'one or more arbitrary strings, creating logical groupings (e.g. '
      'GPU_COMPATIBILITY_TESTS). If *--scenario-numbers* and '
      '*--scenario-labels* are specified together, Firebase Test Lab will '
      'first execute each scenario from *--scenario-numbers*. It will then '
      'expand each given scenario label into a list of scenario numbers marked '
      'with that label, and execute those scenarios.')
コード例 #5
0
ファイル: deploy.py プロジェクト: bopopescu/surround-sound
def _SourceCodeArgs(parser):
    """Add arguments specyfying functions source code to the parser."""
    path_group = parser.add_mutually_exclusive_group()

    path_group.add_argument(
        '--local-path',
        help=(
            'Path to local directory with source code. Required with '
            '--stage-bucket flag. Size of uncompressed files to deploy must be '
            'no more than 512MB.'),
        action=actions.DeprecationAction(
            '--local-path',
            warn='The {flag_name} flag is deprecated; use --source instead.',
            removed=False,
        ),
    )
    path_group.add_argument(
        '--source-path',
        help=(
            'Path to directory with source code in Cloud Source '
            'Repositories, when you specify this parameter --source-url flag '
            'is required.'),
        action=actions.DeprecationAction(
            '--source-path',
            warn='The {flag_name} flag is deprecated; use --source instead.',
            removed=False,
        ),
    )
    path_group.add_argument('--source',
                            help="""\
      Location of source code to deploy.

      Location of the source can be one of the following:

      * Source code in Google Cloud Storage,
      * Reference to source repository or,
      * Local filesystem path.

      Value of the flag will be interpreted as Google Cloud Storage location if
      it starts with `gs://`.

      The value will be interpreted as reference to source repository if it
      starts with `https://`..

      Otherwise it will be interpeted as local filesystem path.

      If you provide reference to source repository it should be in one of the
      following formats:

      * https://source.developers.google.com/projects/([^/]+)/repos/([^/]+)/revisions/([^/]+)/paths/(.+)
        * Unlike other patterns this can include slashes in last group.
      * https://source.developers.google.com/projects/([^/]+)/repos/([^/]+)/moveable-aliases/([^/]+)
      * https://source.developers.google.com/projects/([^/]+)/repos/([^/]+)/fixed-aliases/([^/]+)
      * https://source.developers.google.com/projects/([^/]+)/repos/([^/]+)

      If source location is not explicitly set new functions deploy current
      directory. Existing functions keep their old source.
      """)

    source_group = parser.add_mutually_exclusive_group()
    source_group.add_argument(
        '--stage-bucket',
        help=('Name of Google Cloud Storage bucket in which source code will '
              'be stored. Required if a function is deployed from a local '
              'directory.'),
        type=util.ValidateAndStandarizeBucketUriOrRaise)
    source_group.add_argument(
        '--source-url',
        help=(
            'The Url of a remote repository that holds the function being '
            'deployed. It is of the form: '
            'https://source.developers.google.com/p/{project_id}/'
            'r/{repo_name}/, where you should substitute your data for '
            'values inside the curly brackets. You can omit "r/{repo_name}/" '
            'in which case the "default" repository is taken. '
            'One of the parameters --source-revision, --source-branch, '
            'or --source-tag can be given to specify the version in the '
            'repository. If none of them are provided, the last revision '
            'from the master branch is used. If this parameter is given, '
            'the parameter --source is required and describes the path '
            'inside the repository.'),
        action=actions.DeprecationAction(
            '--source-url',
            warn='The {flag_name} flag is deprecated; use --source instead.',
            removed=False,
        ),
    )
    source_version_group = parser.add_mutually_exclusive_group()
    source_version_group.add_argument(
        '--source-revision',
        help=('The revision ID (for instance, git commit hash) that will be '
              'used to get the source code of the function. Can be specified '
              'only together with --source-url parameter.'),
        action=actions.DeprecationAction(
            '--source-revision',
            warn='The {flag_name} flag is deprecated; use --source instead.',
            removed=False,
        ),
    )
    source_version_group.add_argument(
        '--source-branch',
        help=('The branch that will be used to get the source code of the '
              'function.  The most recent revision on this branch will be '
              'used. Can be specified only together with --source-url '
              'parameter. If not specified defaults to `master`.'),
        action=actions.DeprecationAction(
            '--source-branch',
            warn='The {flag_name} flag is deprecated; use --source instead.',
            removed=False,
        ),
    )
    source_version_group.add_argument(
        '--source-tag',
        help="""\
      The revision tag for the source that will be used as the source
      code of the function. Can be specified only together with
      --source-url parameter.""",
        action=actions.DeprecationAction(
            '--source-tag',
            warn='The {flag_name} flag is deprecated; use --source instead.',
            removed=False,
        ),
    )
    parser.add_argument('--entry-point',
                        type=util.ValidateEntryPointNameOrRaise,
                        help="""\
      By default when a Google Cloud Function is triggered, it executes a
      JavaScript function with the same name. Or, if it cannot find a
      function with the same name, it executes a function named `function`.
      You can use this flag to override the default behavior, by specifying
      the name of a JavaScript function that will be executed when the
      Google Cloud Function is triggered.""")
    parser.add_argument(
        '--include-ignored-files',
        help=('Deploy sources together with files which are normally ignored '
              '(contents of node_modules directory). This flag has an effect '
              'only if a function is deployed from a local directory.'),
        default=False,
        action='store_true')