@@ -331,3 +331,55 @@ def test_metadata_artifact_repair_endpoint(
331331 # Check deduplication
332332 assert len (main_artifact_hrefs ) == 4
333333 assert len (metadata_artifact_hrefs ) == 3
334+
335+
336+ def test_metadata_repair_batch_boundary (
337+ create_content_direct ,
338+ delete_orphans_pre ,
339+ download_python_file ,
340+ monitor_task ,
341+ move_to_repository ,
342+ python_bindings ,
343+ python_repo_factory ,
344+ ):
345+ """
346+ Test that repair_metadata correctly handles packages across batch boundaries.
347+
348+ Verifies that the batch flush (at BULK_SIZE) does not lose or corrupt metadata
349+ for packages processed before and after the flush point.
350+ """
351+ python_repo = python_repo_factory ()
352+
353+ # Create multiple wheel packages with wrong metadata
354+ wheel_files = [
355+ ("scipy-1.1.0-cp27-none-win32.whl" , "ME" ),
356+ ("scipy-1.1.0-cp27-none-win_amd64.whl" , "ME" ),
357+ ("scipy-1.1.0-cp27-cp27m-manylinux1_x86_64.whl" , "ME" ),
358+ ]
359+ content_hrefs = []
360+ for filename , author in wheel_files :
361+ url = urljoin (urljoin (PYTHON_FIXTURES_URL , "packages/" ), filename )
362+ file_path = download_python_file (filename , url )
363+ data = {
364+ "name" : "scipy" ,
365+ "version" : "1.1.0" ,
366+ "filename" : filename ,
367+ "author" : author ,
368+ "packagetype" : "bdist" ,
369+ }
370+ content = create_content_direct (file_path , data )
371+ assert content .author == "ME"
372+ content_hrefs .append (content .pulp_href )
373+
374+ move_to_repository (python_repo .pulp_href , content_hrefs )
375+
376+ # Repair
377+ response = python_bindings .RepositoriesPythonApi .repair_metadata (python_repo .pulp_href )
378+ monitor_task (response .task )
379+
380+ # All packages should have repaired metadata (author != "ME")
381+ for href in content_hrefs :
382+ content = python_bindings .ContentPackagesApi .read (href )
383+ assert content .author != "ME" , f"Package { content .filename } was not repaired"
384+ assert content .packagetype == "bdist_wheel"
385+ assert content .metadata_sha256 is not None
0 commit comments