1+ use crate :: on_host:: tools:: oci_artifact:: REGISTRY_URL ;
12use crate :: on_host:: tools:: oci_package_manager:: TestDataHelper ;
23use crate :: on_host:: tools:: {
34 oci_artifact:: push_agent_package, oci_package_manager:: new_testing_oci_package_manager,
45} ;
56use newrelic_agent_control:: agent_control:: agent_id:: AgentID ;
67use newrelic_agent_control:: package:: manager:: { PackageData , PackageManager } ;
8+ use newrelic_agent_control:: package:: oci:: artifact_definitions:: PackageMediaType ;
79use newrelic_agent_control:: package:: oci:: package_manager:: get_package_path;
810use tempfile:: tempdir;
911
10- // Registry created in the make target executing oci-registry.sh
11- const REGISTRY_URL : & str = "localhost:5001" ;
12-
1312#[ test]
1413#[ ignore = "needs oci registry (use *with_oci_registry suffix), needs elevated privileges on Windows" ]
1514fn test_install_and_uninstall_with_oci_registry ( ) {
15+ const FILENAME : & str = "file1.txt" ;
1616 let dir = tempdir ( ) . unwrap ( ) ;
1717 let tmp_dir_to_compress = tempdir ( ) . unwrap ( ) ;
1818 let file_to_push = dir. path ( ) . join ( "layer_digest.tar.gz" ) ;
1919
20- TestDataHelper :: compress_tar_gz ( tmp_dir_to_compress. path ( ) , file_to_push. as_path ( ) ) ;
20+ TestDataHelper :: compress_tar_gz (
21+ tmp_dir_to_compress. path ( ) ,
22+ file_to_push. as_path ( ) ,
23+ "important content" ,
24+ FILENAME ,
25+ ) ;
2126
22- let ( _artifact_digest, reference) = push_agent_package ( & file_to_push, REGISTRY_URL ) ;
27+ let ( _artifact_digest, reference) = push_agent_package (
28+ & file_to_push,
29+ REGISTRY_URL ,
30+ PackageMediaType :: AgentPackageLayerTarGz ,
31+ ) ;
2332
2433 let temp_dir = tempdir ( ) . unwrap ( ) ;
2534 let base_path = temp_dir. path ( ) . to_path_buf ( ) ;
@@ -43,7 +52,10 @@ fn test_install_and_uninstall_with_oci_registry() {
4352 ) ;
4453
4554 let installed_package = installed_package_result. unwrap ( ) ;
46- TestDataHelper :: test_data_uncompressed ( installed_package. installation_path . as_path ( ) ) ;
55+ TestDataHelper :: test_tar_gz_uncompressed (
56+ installed_package. installation_path . as_path ( ) ,
57+ FILENAME ,
58+ ) ;
4759 // Verify location
4860 // The path should be base_path/agent_id/oci_registry__port__repo_tag
4961 let expected_path = get_package_path ( & base_path, & agent_id, & pkg_id, & reference) . unwrap ( ) ;
@@ -61,17 +73,25 @@ fn test_install_and_uninstall_with_oci_registry() {
6173#[ test]
6274#[ ignore = "needs oci registry, needs elevated privileges on Windows" ]
6375fn test_install_skips_download_if_exists_with_oci_registry ( ) {
76+ const FILENAME : & str = "payload.txt" ;
77+
6478 let dir = tempdir ( ) . unwrap ( ) ;
6579 let content_dir = tempdir ( ) . unwrap ( ) ;
6680
67- let payload_file_source = content_dir. path ( ) . join ( "payload.txt" ) ;
68- std:: fs:: write ( & payload_file_source, "ORIGINAL_CONTENT" ) . unwrap ( ) ;
69-
7081 let file_to_push = dir. path ( ) . join ( "layer_digest.tar.gz" ) ;
7182
72- TestDataHelper :: compress_tar_gz ( content_dir. path ( ) , file_to_push. as_path ( ) ) ;
83+ TestDataHelper :: compress_tar_gz (
84+ content_dir. path ( ) ,
85+ file_to_push. as_path ( ) ,
86+ "ORIGINAL_CONTENT" ,
87+ FILENAME ,
88+ ) ;
7389
74- let ( _artifact_digest, reference) = push_agent_package ( & file_to_push, REGISTRY_URL ) ;
90+ let ( _artifact_digest, reference) = push_agent_package (
91+ & file_to_push,
92+ REGISTRY_URL ,
93+ PackageMediaType :: AgentPackageLayerTarGz ,
94+ ) ;
7595
7696 let temp_dir = tempdir ( ) . unwrap ( ) ;
7797 let base_path = temp_dir. path ( ) . to_path_buf ( ) ;
@@ -89,7 +109,7 @@ fn test_install_skips_download_if_exists_with_oci_registry() {
89109 . install ( & agent_id, package_data. clone ( ) )
90110 . expect ( "First install failed" ) ;
91111
92- let installed_file_path = installed_1. installation_path . join ( "payload.txt" ) ;
112+ let installed_file_path = installed_1. installation_path . join ( FILENAME ) ;
93113 assert ! (
94114 installed_file_path. exists( ) ,
95115 "Payload file should exist after install"
0 commit comments