1
1
import json
2
+ import logging
2
3
import os
3
4
import tempfile
4
5
from pathlib import Path
13
14
pytestmark = pytest .mark .order ("last" )
14
15
15
16
17
+ SKIPPED_GOLDEN_FILES = {
18
+ # skip because of missing structured property definitions
19
+ "datahub/metadata-ingestion/tests/unit/sdk_v2/dataset_golden/test_structured_properties_golden.json" ,
20
+ # skip because of missing structured property definitions
21
+ "datahub/metadata-ingestion/tests/integration/snowflake/snowflake_structured_properties_golden.json" ,
22
+ # skip because of missing structured property definitions
23
+ "datahub/metadata-ingestion/tests/unit/cli/dataset/test_resources/golden_test_dataset_sync_mpcs.json" ,
24
+ }
25
+
26
+ logger = logging .getLogger (__name__ )
27
+
28
+
16
29
@pytest .fixture (scope = "module" )
17
30
def golden_files ():
18
31
repo_root = Path (__file__ ).parents [5 ]
@@ -65,7 +78,7 @@ def cleanup_golden_files(auth_session, golden_files):
65
78
66
79
# after yield => teardown method
67
80
68
- print ("Collecting URNs from all golden files for batch deletion..." )
81
+ logger . info ("Collecting URNs from all golden files for batch deletion..." )
69
82
70
83
all_urns = set ()
71
84
@@ -94,10 +107,12 @@ def cleanup_golden_files(auth_session, golden_files):
94
107
all_urns .add (urn )
95
108
96
109
except Exception as e :
97
- print (f"Warning: Failed to extract URNs from { file_path } : { e } " )
110
+ logger .error (
111
+ f"Warning: Failed to extract URNs from { file_path } " , exc_info = e
112
+ )
98
113
99
114
if all_urns :
100
- print (
115
+ logger . info (
101
116
f"Creating temp file with { len (all_urns )} unique URNs for batch deletion..."
102
117
)
103
118
@@ -123,9 +138,9 @@ def cleanup_golden_files(auth_session, golden_files):
123
138
},
124
139
)
125
140
if result .exit_code == 0 :
126
- print ("✅ Batch deletion completed successfully" )
141
+ logger . info ("✅ Batch deletion completed successfully" )
127
142
else :
128
- print (f"⚠️ Batch deletion failed: { result .output } " )
143
+ logger . info (f"⚠️ Batch deletion failed: { result .output } " )
129
144
130
145
finally :
131
146
os .unlink (temp_file_path )
@@ -142,27 +157,20 @@ def test_golden_files_discovery(golden_files):
142
157
assert os .path .isabs (file_path ), f"Path should be absolute: { file_path } "
143
158
assert os .path .exists (file_path ), f"File should exist: { file_path } "
144
159
145
- print (f"Successfully discovered { len (golden_files )} golden files" )
160
+ logger . info (f"Successfully discovered { len (golden_files )} golden files" )
146
161
147
162
148
163
def test_ingest_golden_files (auth_session , golden_files ):
149
164
repo_root = Path (__file__ ).parents [5 ]
150
165
failed_files = []
151
166
152
- # TODO: Fix these failing golden files
153
- known_failing_files = {
154
- "datahub/metadata-ingestion/tests/unit/sdk_v2/dataset_golden/test_structured_properties_golden.json" ,
155
- "datahub/metadata-ingestion/tests/integration/snowflake/snowflake_structured_properties_golden.json" ,
156
- "datahub/metadata-ingestion/tests/unit/cli/dataset/test_resources/golden_test_dataset_sync_mpcs.json" ,
157
- }
158
-
159
167
for golden_file_path in golden_files :
160
168
relative_path = Path (golden_file_path ).relative_to (repo_root )
161
- print (f"Testing ingestion of golden file: { relative_path } " )
169
+ logger . info (f"Testing ingestion of golden file: { relative_path } " )
162
170
163
171
# Skip known failing files temporarily
164
- if str (relative_path ) in known_failing_files :
165
- print (f"Skipping known failing file: { relative_path } ⚠️" )
172
+ if str (relative_path ) in SKIPPED_GOLDEN_FILES :
173
+ logger . info (f"Skipping known failing file: { relative_path } ⚠️" )
166
174
continue
167
175
168
176
try :
@@ -173,9 +181,10 @@ def test_ingest_golden_files(auth_session, golden_files):
173
181
"DATAHUB_GMS_TOKEN" : auth_session .gms_token (),
174
182
},
175
183
)
176
- print (
177
- f"Ingestion of golden file { relative_path } : { '✅' if result .exit_code == 0 else '❌' } "
178
- )
184
+ if result .exit_code == 0 :
185
+ logger .info (f"Ingestion of golden file { relative_path } : ✅" )
186
+ else :
187
+ logger .warning (f"Ingestion of golden file { relative_path } : ❌" )
179
188
180
189
if result .exit_code != 0 :
181
190
failed_files .append (f"{ relative_path } : { result .output } " )
0 commit comments