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()
if __name__ == '__main__': parser = argparse.ArgumentParser( description='Create or delete Cloud SQL instances for system tests.') parser.add_argument('--action', required=True, choices=('create', 'delete', 'setup-instances', 'create2', 'delete2', 'setup-instances2', 'before-tests', 'after-tests', 'delete-service-accounts-acls')) action = parser.parse_args().action 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':