def setUpClass(cls):
     SQL_QUERY_TEST_HELPER.set_ip_addresses_in_env()
     if os.path.exists(TEARDOWN_LOCK_FILE_QUERY):
         print("Skip creating and setting up instances as they were created manually "
               "(helps to iterate on tests)")
     else:
         helper = CloudSqlQueryTestHelper()
         gcp_authenticator = GcpAuthenticator(gcp_key=GCP_CLOUDSQL_KEY)
         gcp_authenticator.gcp_store_authentication()
         try:
             gcp_authenticator.gcp_authenticate()
             helper.create_instances(instance_suffix=QUERY_SUFFIX)
             helper.setup_instances(instance_suffix=QUERY_SUFFIX)
         finally:
             gcp_authenticator.gcp_restore_authentication()
Beispiel #2
0
    helper = CloudSqlQueryTestHelper()
    gcp_authenticator = GcpAuthenticator(GCP_CLOUDSQL_KEY)
    helper.log.info('Starting action: {}'.format(action))

    gcp_authenticator.gcp_store_authentication()
    try:
        gcp_authenticator.gcp_authenticate()
        if action == 'before-tests':
            pass
        elif action == 'after-tests':
            pass
        elif action == 'create':
            helper.create_instances()
        elif action == 'delete':
            helper.delete_instances()
        elif action == 'create2':
            helper.create_instances(instance_suffix="2")
        elif action == 'delete2':
            helper.delete_instances(instance_suffix="2")
        elif action == 'setup-instances':
            helper.setup_instances()
        elif action == 'setup-instances2':
            helper.setup_instances(instance_suffix="2")
        elif action == 'delete-service-accounts-acls':
            helper.delete_service_account_acls()
        else:
            raise Exception("Unknown action: {}".format(action))
    finally:
        gcp_authenticator.gcp_restore_authentication()
    helper.log.info('Finishing action: {}'.format(action))