def SetUp(self):
    self.track = calliope_base.ReleaseTrack.ALPHA

    self.network_name = next(e2e_utils.GetResourceNameGenerator(
        prefix='gcloud-compute-test-network'))
    self.target_vpn_gateway_name = next(e2e_utils.GetResourceNameGenerator(
        prefix='gcloud-compute-test-target-vpn-gateway'))
Exemplo n.º 2
0
 def SetUp(self):
     self.track = calliope_base.ReleaseTrack.ALPHA
     self.display_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='compute-security-policy-test'))
     self.description_generator = e2e_utils.GetResourceNameGenerator(
         prefix='compute-org-security-policy')
Exemplo n.º 3
0
  def SetUp(self):
    self.track = calliope_base.ReleaseTrack.BETA
    messages = core_apis.GetMessagesModule('dns', self.beta_version)
    self.test_zone = messages.ManagedZone(
        description='Zone!',
        dnsName=six.text_type(
            # Random name generation that ends in .com.
            # Example: kvtqfsqro8mo5.com.
            next(
                e2e_utils.GetResourceNameGenerator(
                    suffix='.com.',
                    hash_len=13,
                    delimiter='',
                    timestamp_format=None))),
        kind='dns#managedZone',
        name=six.text_type(
            next(e2e_utils.GetResourceNameGenerator(prefix='zone'))),
        nameServers=[])

    self.Run(('dns managed-zones create {0}'
              ' --dns-name {1} --labels foo=bar --description {2}').format(
                  self.test_zone.name, self.test_zone.dnsName,
                  self.test_zone.description))
    self.AssertErrContains("""\
Created [https://dns.googleapis.com/dns/{2}/projects/{0}/managedZones/{1}].
""".format(self.Project(), self.test_zone.name, self.beta_version))
Exemplo n.º 4
0
 def SetUp(self):
     self.storage_client = storage_api.StorageClient()
     self.files_to_upload = []
     self.object_path = next(
         e2e_utils.GetResourceNameGenerator(prefix='object'))
     self.bucket_name = next(
         e2e_utils.GetResourceNameGenerator(prefix=BUCKET_PREFIX))
Exemplo n.º 5
0
 def SetUp(self):
     super(StaticNatsTest, self).SetUp()
     self.address_name_1 = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='routers-test-address-1'))
     self.address_name_2 = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='routers-test-address-2'))
Exemplo n.º 6
0
 def SetUp(self):
     self.track = calliope_base.ReleaseTrack.GA
     self.network_name = next(
         e2e_utils.GetResourceNameGenerator(prefix='routers-test-network'))
     self.router_name = next(
         e2e_utils.GetResourceNameGenerator(prefix='routers-test-router'))
     self.nat_name = next(
         e2e_utils.GetResourceNameGenerator(prefix='routers-test-nat'))
Exemplo n.º 7
0
  def SetUp(self):
    self.track = calliope_base.ReleaseTrack.BETA

    self.forwarding_rule_name = next(
        e2e_utils.GetResourceNameGenerator(
            prefix='gcloud-compute-test-forwarding-rule'))
    self.target_pool_name = next(
        e2e_utils.GetResourceNameGenerator(
            prefix='gcloud-compute-test-target-pool'))
Exemplo n.º 8
0
 def SetUp(self):
   self.track = calliope_base.ReleaseTrack.GA
   self.local_vpn_gateway_name = next(e2e_utils.GetResourceNameGenerator(
       prefix='gcloud-compute-local-vpn-gateway'))
   self.peer_vpn_gateway_name = next(e2e_utils.GetResourceNameGenerator(
       prefix='gcloud-compute-peer-vpn-gateway'))
   self.router_name = next(e2e_utils.GetResourceNameGenerator(
       prefix='gcloud-compute-router'))
   self.tunnel_name = next(e2e_utils.GetResourceNameGenerator(
       prefix='gcloud-compute-vpn-tunnel'))
Exemplo n.º 9
0
 def SetUp(self):
     self.type_provider_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='type-registry-integ-tp'))
     self.composite_type_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='type-registry-integ-ct'))
     self.type_provider_options = self.FilePathFor(
         'type_providers/simple_dummy_config.yaml')
     self.composite_type_template = self.FilePathFor(
         'simple_configs/simple.jinja')
     self.type_provider_exists = False
     self.composite_type_exists = False
Exemplo n.º 10
0
 def PreSetUp(self):
     self.location = 'global'
     self.workload_identity_pool_id = next(
         e2e_utils.GetResourceNameGenerator(prefix='iam'))
     self.workload_identity_pool_name = 'projects/{0}/locations/{1}/workloadIdentityPools/{2}'.format(
         '462803083913', self.location, self.workload_identity_pool_id)
     self.aws_provider_id = next(
         e2e_utils.GetResourceNameGenerator(prefix='iam'))
     self.aws_provider_name = '{0}/providers/{1}'.format(
         self.workload_identity_pool_name, self.aws_provider_id)
     self.oidc_provider_id = next(
         e2e_utils.GetResourceNameGenerator(prefix='iam'))
     self.oidc_provider_name = '{0}/providers/{1}'.format(
         self.workload_identity_pool_name, self.oidc_provider_id)
Exemplo n.º 11
0
 def SetUp(self):
     self.track = calliope_base.ReleaseTrack.ALPHA
     self.interconnect_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='interconnects-test-interconnect'))
     self.attachment_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='interconnects-test-attachment'))
     self.network_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='interconnects-test-network'))
     self.router_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='interconnects-test-router'))
     self.location = 'sjc-zone1-6'
Exemplo n.º 12
0
    def SetUp(self):
        self.name_generator = e2e_utils.GetResourceNameGenerator('sdk-e2e')
        project_name = next(self.name_generator)
        self.project_id = command_lib_util.IdFromName(project_name)
        self.project_ref = command_lib_util.ParseProject(self.project_id)
        create_op = projects_api.Create(
            self.project_ref,
            parent=projects_api.ParentNameToResourceId(
                CLOUD_SDK_TESTING_FOLDER_ID))
        log.CreatedResource(self.project_ref, is_async=True)
        operations.WaitForOperation(create_op)

        log.debug('Enabling cloudapis.googleapis.com')
        services_enable_api.EnableService(self.project_ref.Name(),
                                          'cloudapis.googleapis.com')

        self.Run('services enable cloudbilling')
        self.Run(('alpha billing accounts projects link {project} '
                  '--account-id={billing}').format(project=self.project_id,
                                                   billing=self.BillingId()))
        self.Run('projects add-iam-policy-binding {project} '
                 '--member="group:[email protected]" '
                 '--role="roles/owner"'.format(project=self.project_id))

        properties.VALUES.core.disable_prompts.Set(True)
        # This is set to false by sdk_test_base.SdkBase.
        properties.VALUES.core.should_prompt_to_enable_api.Set(True)
        # The api enablement check will prompt, and this will inject a yes into that
        self.StartPatch(
            'googlecloudsdk.core.console.console_io.PromptContinue',
            return_value=True)
Exemplo n.º 13
0
 def CreateInstanceTemplate(self, machine_type='n1-standard-1'):
   name = next(e2e_utils.GetResourceNameGenerator(prefix=self.prefix))
   self.Run('compute instance-templates create {0} --machine-type {1}'
            .format(name, machine_type))
   self.instance_template_names.append(name)
   self.AssertNewOutputContains(name)
   return name
Exemplo n.º 14
0
    def testJobsSubmitTrainingCustomServer(self, module_name):
        job_id = next(
            e2e_utils.GetResourceNameGenerator(prefix='ml_job', delimiter='_'))
        package = self.Resource('tests', 'e2e', 'surface', 'ai_platform',
                                'testdata', 'trainer-0.0.0.tar.gz')

        with self.SubmitJob('training', job_id,
                            ('    --staging-bucket {bucket_url} '
                             '    --region us-central1 '
                             '    --runtime-version 1.12 '
                             '    --scale-tier CUSTOM  '
                             '    --master-machine-type n1-standard-16 '
                             '    --worker-machine-type n1-standard-16'
                             '    --worker-count 2'
                             '    --module-name trainer.task '
                             '    --packages {package} '
                             '    --async').format(
                                 bucket_url=self.BUCKET_REF.ToUrl(),
                                 package=package), module_name):
            # Cancel immediately so we don't do any real work
            self.Run('{} jobs cancel '.format(module_name) + job_id)
            # Check that the job was created
            self.ClearOutput()
            self.Run('{} jobs describe '.format(module_name) + job_id)
            self.AssertOutputContains('jobId: ' + job_id)
Exemplo n.º 15
0
    def SetUp(self):
        properties.VALUES.core.user_output_enabled.Set(False)

        self._name_generator = e2e_utils.GetResourceNameGenerator(
            prefix='trace', sequence_start=1)

        self._parents_and_flags = [('projects/{0}'.format(self.Project()), '')]
Exemplo n.º 16
0
 def SetUp(self):
     self.name_gen = e2e_utils.GetResourceNameGenerator(
         prefix='gcloud-kuberun-test-service', hash_len=4)
     self.cluster_args = ('--cluster crfa-productivity-kape-e2e '
                          '--cluster-location us-central1-a '
                          '--project cloud-sdk-integration-testing')
     self.test_image = 'gcr.io/cloudrun/hello'
Exemplo n.º 17
0
 def Execute(self, scenario_context):
     scenario_context.resource_ref_resolver.AddGeneratedResourceId(
         self._reference,
         next(
             e2e_utils.GetResourceNameGenerator(prefix=self._prefix,
                                                delimiter=self.delimiter)),
         requires_cleanup=self._requires_cleanup)
Exemplo n.º 18
0
 def GetInstanceName(self):
     # Make sure the name used is different on each retry, and make sure all
     # names used are cleaned up.
     name = next(
         e2e_utils.GetResourceNameGenerator(prefix='compute-suspend'))
     self.instance_names_used.append(name)
     return name
Exemplo n.º 19
0
 def CreateInstanceGroupManagerStateful(self,
                                        instance_template_name,
                                        size=0,
                                        stateful_disks=None):
     name = next(e2e_utils.GetResourceNameGenerator(prefix=self.prefix))
     instance_redistribution_flag = ''
     if self.scope == e2e_test_base.ZONAL:
         self.instance_group_manager_names.append(name)
     elif self.scope == e2e_test_base.REGIONAL:
         self.region_instance_group_manager_names.append(name)
         instance_redistribution_flag = '--instance-redistribution-type NONE'
     command = """\
   compute instance-groups managed create {group_name} \
     {scope_flag} \
     --base-instance-name {group_name} \
     --size {size} \
     {instance_redistribution_flag} \
     --template {template}""".format(
         group_name=name,
         scope_flag=self.GetScopeFlag(),
         size=size,
         instance_redistribution_flag=instance_redistribution_flag,
         template=instance_template_name)
     if stateful_disks:
         for device_name in stateful_disks:
             command += """\
       --stateful-disk device-name={0}""".format(device_name)
     self.Run(command)
     self.AssertNewOutputContains(name)
     if stateful_disks:
         self.stateful_igms.add(name)
     return name
Exemplo n.º 20
0
 def CreateTargetPool(self):
     name = next(e2e_utils.GetResourceNameGenerator(prefix=self.prefix))
     self.Run('compute target-pools create {0} --region {1}'.format(
         name, e2e_test_base.REGION))
     self.target_pool_names.append(name)
     self.AssertNewOutputContains(name)
     return name
Exemplo n.º 21
0
    def CreateDisk(self,
                   size=10,
                   zone=None,
                   image_family=None,
                   image_project=None):
        """Create a disk for use in the IGM.

    Args:
      size: Size (in GB) of the new disk.
      zone: Zone of the new disk.
      image_family: Image family to initialize the new disk from.
      image_project: Project ID of the image family specified.

    Returns:
      URI of the created disk.
    """
        name = next(e2e_utils.GetResourceNameGenerator(prefix=self.prefix))
        # Update seek position
        self.GetNewErr()
        command = ("""
        compute disks create {disk_name} \
          --zone {zone} \
          --size {size}GB""".format(size=size,
                                    disk_name=name,
                                    zone=zone or self.zone))
        if image_family:
            command += ' --image-family={0}'.format(image_family)
        if image_project:
            command += ' --image-project={0}'.format(image_project)
        self.Run(command)
        stderr = self.GetNewErr()
        # Return URI to the disk
        return re.search(r'Created \[(.*)\]', stderr).group(1)
Exemplo n.º 22
0
 def _GetInstanceName(self):
     # Make sure the name used is different on each retry, and make sure all
     # names used are cleaned up.
     self.instance_name = next(
         e2e_utils.GetResourceNameGenerator(
             prefix='gcloud-compute-test-windows'))
     self.instance_names_used.append(self.instance_name)
 def CreateInstance(self):
     name = next(e2e_utils.GetResourceNameGenerator(prefix=self.prefix))
     self.Run('compute instances create {0} --zone {1}'.format(
         name, self.zone))
     self.AssertNewOutputContains(name)
     self.instance_names.append(name)
     return name
Exemplo n.º 24
0
 def CreateInstance(self, tier):
     self.test_instance = next(
         e2e_utils.GetResourceNameGenerator(prefix='gcloud-sql-test'))
     self.instance_created = False
     operation = self.RunCreateInstanceCmd(tier)
     self.WaitOnOperation(operation.name)
     self.instance_created = True
Exemplo n.º 25
0
 def GetInstanceName(self):
   # Make sure a new name is used if the test is retried, and make sure all
   # used names get cleaned up
   name = next(
       e2e_utils.GetResourceNameGenerator(prefix='gcloud-compute-test'))
   self.instance_name = name
   self.instance_names_used.append(name)
   return name
Exemplo n.º 26
0
 def CreateHttpsHealthCheck(self):
     name = next(e2e_utils.GetResourceNameGenerator(prefix=self.prefix))
     self.Run('compute https-health-checks create {0} '
              '--port {1} --request-path {2}'.format(
                  name, 12345, '/healthz'))
     self.https_health_check_names.append(name)
     self.AssertNewOutputContains(name)
     return name
Exemplo n.º 27
0
 def _RuntimeConfig(self, prefix, description=''):
   name = next(e2e_utils.GetResourceNameGenerator(prefix))
   try:
     self.RunRuntimeConfig(
         'create {0} --description={1}'.format(name, description))
     yield name
   finally:
     self.RunRuntimeConfig('delete {0}'.format(name))
Exemplo n.º 28
0
  def SetUp(self):
    properties.VALUES.core.user_output_enabled.Set(False)
    self._name_generator = e2e_utils.GetResourceNameGenerator(
        prefix='logging', sequence_start=1)

    self._parents_and_flags = [
        ('projects/{0}'.format(self.Project()), ''),
        ('organizations/1054311078602', '--organization=1054311078602'),
        ('folders/571192892845', '--folder=571192892845')]
Exemplo n.º 29
0
  def deployExample(self, file_path, resource_count):
    """Helper method to deploy an example template.

    Checks that the template can be created and deleted without errors.

    Args:
       file_path: list of filename pieces that point to the config file under
           //cloud/sdk/deployment_manager/tests/resources/ to deploy.
       resource_count: number of resources expected in this deployment
    """
    # Generate deployment name with a random suffix to allow for multiple
    # simultaneous runs of the integration tests
    self.deployment_name = next(e2e_utils.GetResourceNameGenerator(
        prefix='dm'))
    deployed = False
    try:
      # Call deployments create, should return only after operation completion.
      # We still need to wait for create to finish because otherwise delete
      # will hit a 409 (conflicting operation). If that changes in the service,
      # then this test can be updated to issue only async calls.
      self.Run('deployment-manager deployments create '
               + self.deployment_name + ' --config '
               + self.getConfigFile(file_path))
      # Check that an operation was returned.
      self.AssertErrContains('operation-')
      self.ClearOutput()
      self.ClearErr()
      deployed = True

      # Deployments get on deployment
      self.Run('deployment-manager deployments describe '
               + self.deployment_name)
      self.AssertOutputContains(self.deployment_name)
      self.ClearOutput()
    finally:
      # This block should run before any AssertionErrors, HttpErrors,
      # ToolErrors, or DeploymentManagerExceptions are raised in the try block.
      # Call deployments delete (async) if a deployment was actually created.
      # Don't wait for this to finish, move on to the next test while the
      # delete is processed, since delete is a slow operation.
      if not deployed:
        print(('Deployment %s was not deployed.', self.deployment_name))
      else:
        self.ClearOutput()
        self.Run('deployment-manager deployments delete -q --async '
                 + self.deployment_name + ' --format=default')
        delete_output = self.GetOutput()
        self.ClearOutput()

        # Check that a delete operation was returned.
        delete_operation = re.search(
            r'operation-[\d\w\-]+', delete_output).group()
        self.Run('deployment-manager operations describe '
                 + delete_operation)
        self.AssertOutputContains('delete')
        self.AssertOutputContains(self.deployment_name)
        self.ClearOutput()
 def _MakeFileUploadTasks(self, bucket_ref):
   tasks = []
   name_generator = e2e_utils.GetResourceNameGenerator(prefix='storage-file')
   for remote_file in itertools.islice(name_generator, self.NUM_FILES):
     task = storage_parallel.FileUploadTask(
         self.file_path, storage_util.ObjectReference.FromBucketRef(
             bucket_ref, remote_file))
     tasks.append(task)
   return tasks