def __init__(self, method_name, gcp_key, project_extra=None): super(BaseGcpSystemTestCase, self).__init__(methodName=method_name) self.gcp_authenticator = GcpAuthenticator(gcp_key=gcp_key, project_extra=project_extra) self.setup_called = False
class TestBaseGcpSystem(unittest.TestCase, LoggingMixin): def __init__(self, method_name, gcp_key, project_extra=None): super().__init__(methodName=method_name) self.gcp_authenticator = GcpAuthenticator(gcp_key=gcp_key, project_extra=project_extra) self.setup_called = False @staticmethod def skip_check(key_name): return GcpAuthenticator(key_name).full_key_path is None @staticmethod def skip_long(key_name): if os.environ.get('GCP_ENABLE_LONG_TESTS') == 'True': return GcpAuthenticator(key_name).full_key_path is None return True def setUp(self): self.gcp_authenticator.gcp_store_authentication() self.gcp_authenticator.gcp_authenticate() # We checked that authentication works. Ne we revoke it to make # sure we are not relying on the default authentication self.gcp_authenticator.gcp_revoke_authentication() self.setup_called = True # noinspection PyPep8Naming def tearDown(self): self.gcp_authenticator.gcp_restore_authentication()
class BaseGcpSystemTestCase(unittest.TestCase, LoggingMixin): def __init__(self, method_name, gcp_key, project_extra=None): super(BaseGcpSystemTestCase, self).__init__(methodName=method_name) self.gcp_authenticator = GcpAuthenticator(gcp_key=gcp_key, project_extra=project_extra) self.setup_called = False @staticmethod def skip_check(key_name): return GcpAuthenticator(key_name).full_key_path is None def setUp(self): self.gcp_authenticator.gcp_store_authentication() self.gcp_authenticator.gcp_authenticate() # We checked that authentication works. Ne we revoke it to make # sure we are not relying on the default authentication self.gcp_authenticator.gcp_revoke_authentication() self.setup_called = True # noinspection PyPep8Naming def tearDown(self): self.gcp_authenticator.gcp_restore_authentication()
def skip_check(key_name): return GcpAuthenticator(key_name).full_key_path is None
def delete_bucket(self): self.execute_cmd(["gsutil", "rm", "-r", "gs://%s/" % GCP_BUCKET_NAME]) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Create or delete bucket with test file for system tests.") parser.add_argument( "--action", dest="action", required=True, choices=("create-bucket", "delete-bucket", "before-tests", "after-tests"), ) action = parser.parse_args().action helper = GCPVideoIntelligenceHelper() gcp_authenticator = GcpAuthenticator(GCP_AI_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-bucket": helper.create_bucket() elif action == "delete-bucket": helper.delete_bucket() else: raise Exception("Unknown action: {}".format(action))
def delete_bucket(self): self.execute_cmd(['gsutil', 'rm', '-r', "gs://%s/" % GCP_BUCKET_NAME]) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Create and remove a bucket for system tests.') parser.add_argument( '--action', dest='action', required=True, choices=('create-bucket', 'delete-bucket', 'before-tests', 'after-tests'), ) action = parser.parse_args().action helper = GCPVisionTestHelper() gcp_authenticator = GcpAuthenticator(GCP_AI_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-bucket': helper.create_bucket() elif action == 'delete-bucket': helper.delete_bucket() else: raise Exception("Unknown action: {}".format(action))
def skip_long(key_name): if os.environ.get('GCP_ENABLE_LONG_TESTS') == 'True': return GcpAuthenticator(key_name).full_key_path is None return True
'--action', dest='action', required=True, choices=( 'create-s3-bucket', 'delete-s3-bucket', 'create-gcs-buckets', 'delete-gcs-buckets', 'before-tests', 'after-tests', ), ) action = parser.parse_args().action helper = GCPTransferTestHelper() gcp_authenticator = GcpAuthenticator(GCP_GCS_TRANSFER_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-s3-bucket': helper.create_s3_bucket() elif action == 'delete-s3-bucket': helper.delete_s3_bucket() elif action == 'create-gcs-buckets': helper.create_gcs_buckets()
from tests.contrib.operators.test_gcp_sql_operator_system_helper \ import CloudSqlQueryTestHelper from tests.contrib.utils.gcp_authenticator import GCP_CLOUDSQL_KEY, GcpAuthenticator QUERY_SUFFIX = "_QUERY" 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', 'before-tests', 'after-tests')) action = parser.parse_args().action helper = CloudSqlQueryTestHelper() gcp_authenticator = GcpAuthenticator(gcp_key=GCP_CLOUDSQL_KEY) helper.log.info('Starting action: {}'.format(action)) gcp_authenticator.gcp_store_authentication() try: gcp_authenticator.gcp_authenticate() if action == 'before-tests': helper.create_instances(instance_suffix=QUERY_SUFFIX) helper.setup_instances(instance_suffix=QUERY_SUFFIX) elif action == 'after-tests': helper.delete_instances(instance_suffix=QUERY_SUFFIX) elif action == 'create': helper.create_instances(instance_suffix=QUERY_SUFFIX) elif action == 'delete': helper.delete_instances(instance_suffix=QUERY_SUFFIX) elif action == 'setup-instances': helper.setup_instances(instance_suffix=QUERY_SUFFIX)
if __name__ == "__main__": parser = argparse.ArgumentParser( description="Create and delete bucket for system tests.") parser.add_argument( "--action", dest="action", required=True, choices=("create-bucket", "delete-bucket", "before-tests", "after-tests"), ) action = parser.parse_args().action helper = GCPBigQueryTestHelper() gcp_authenticator = GcpAuthenticator(GCP_CLOUD_BUILD_KEY) helper.log.info("Starting action: %s", action) gcp_authenticator.gcp_store_authentication() try: gcp_authenticator.gcp_authenticate() if action == "before-tests": pass elif action == "after-tests": pass elif action == "create-bucket": helper.create_repository_and_bucket() elif action == "delete-bucket": helper.delete_bucket() else: raise Exception("Unknown action: {}".format(action))
if __name__ == "__main__": parser = argparse.ArgumentParser( description="Create and delete bucket for system tests.") parser.add_argument( "--action", dest="action", required=True, choices=("create-bucket", "delete-bucket", "before-tests", "after-tests"), ) action = parser.parse_args().action helper = GCPBigQueryTestHelper() gcp_authenticator = GcpAuthenticator(GCP_BIGQUERY_KEY) helper.log.info("Starting action: %s", action) gcp_authenticator.gcp_store_authentication() try: gcp_authenticator.gcp_authenticate() if action == "before-tests": pass elif action == "after-tests": pass elif action == "create-bucket": helper.create_repository_and_bucket() elif action == "delete-bucket": helper.delete_bucket() else: raise Exception("Unknown action: {}".format(action))