File tree Expand file tree Collapse file tree
packages/google-cloud-logging/tests/system Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,9 +105,24 @@ class Config(object):
105105
106106
107107def setUpModule ():
108- Config .CLIENT = client .Client ()
109- Config .HTTP_CLIENT = client .Client (_use_grpc = False )
108+ # Use GOOGLE_CLOUD_PROJECT
109+ project_id = os .environ .get ("GOOGLE_CLOUD_PROJECT" )
110+
111+ # Check if we have credentials (either via file or environment)
112+ # google.auth.default() will check GOOGLE_APPLICATION_CREDENTIALS
113+ has_creds = os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" ) is not None
114+
115+ # Guard: Skip the entire module if the environment is not ready
116+ if not project_id or not has_creds :
117+ raise unittest .SkipTest (
118+ "System tests skipped: GOOGLE_CLOUD_PROJECT and "
119+ "GOOGLE_APPLICATION_CREDENTIALS must be set."
120+ )
110121
122+ # Explicitly pass the project to the client
123+ # This prevents the client from attempting 'discovery' via the metadata server
124+ Config .CLIENT = client .Client (project = project_id )
125+ Config .HTTP_CLIENT = client .Client (_use_grpc = False , project = project_id )
111126
112127# Skip the test cases using bigquery, storage and pubsub clients for mTLS testing.
113128# Bigquery and storage uses http which doesn't have mTLS support, pubsub doesn't
You can’t perform that action at this time.
0 commit comments