zotregistry.io/zot@v1.4.4-0.20231124084042-02a8ed785457/test/blackbox/sync_harness.bats (about) 1 # Note: Intended to be run as "make run-blackbox-tests" or "make run-blackbox-sync-nightly" 2 # Makefile target installs & checks all necessary tooling 3 # Extra tools that are not covered in Makefile target needs to be added in verify_prerequisites() 4 5 load helpers_zot 6 load helpers_wait 7 8 function verify_prerequisites() { 9 return 0 10 } 11 12 function setup_file() { 13 # Verify prerequisites are available 14 if ! $(verify_prerequisites); then 15 exit 1 16 fi 17 18 # Setup zot server 19 local zot_sync_per_root_dir=${BATS_FILE_TMPDIR}/zot-per 20 21 local zot_sync_per_config_file=${BATS_FILE_TMPDIR}/zot_sync_per_config.json 22 local zot_sync_ondemand_config_file=${BATS_FILE_TMPDIR}/zot_sync_ondemand_config.json 23 24 local zot_minimal_root_dir=${BATS_FILE_TMPDIR}/zot-minimal 25 local zot_minimal_config_file=${BATS_FILE_TMPDIR}/zot_minimal_config.json 26 27 local oci_data_dir=${BATS_FILE_TMPDIR}/oci 28 mkdir -p ${zot_sync_per_root_dir} 29 mkdir -p ${zot_minimal_root_dir} 30 mkdir -p ${oci_data_dir} 31 32 local ZOT_LOG_FILE=${zot_sync_per_root_dir}/zot.log 33 34 35 cat >${zot_sync_per_config_file} <<EOF 36 { 37 "distSpecVersion": "1.1.0-dev", 38 "storage": { 39 "rootDirectory": "${zot_sync_per_root_dir}" 40 }, 41 "http": { 42 "address": "0.0.0.0", 43 "port": "8081" 44 }, 45 "log": { 46 "level": "debug", 47 "output": "${ZOT_LOG_FILE}" 48 }, 49 "extensions": { 50 "sync": { 51 "registries": [ 52 { 53 "urls": [ 54 "http://localhost:8080" 55 ], 56 "onDemand": false, 57 "tlsVerify": false, 58 "PollInterval": "5m", 59 "content": [ 60 { 61 "prefix": "**" 62 } 63 ] 64 } 65 ] 66 } 67 } 68 } 69 EOF 70 71 cat >${zot_minimal_config_file} <<EOF 72 { 73 "distSpecVersion": "1.1.0-dev", 74 "storage": { 75 "rootDirectory": "${zot_minimal_root_dir}" 76 }, 77 "http": { 78 "address": "0.0.0.0", 79 "port": "8080" 80 }, 81 "log": { 82 "level": "debug", 83 "output": "${zot_minimal_root_dir}/zot.log" 84 } 85 } 86 EOF 87 zot_serve ${ZOT_MINIMAL_PATH} ${zot_minimal_config_file} 88 wait_zot_reachable 8080 89 } 90 91 function teardown_file() { 92 zot_stop_all 93 } 94 95 # sync zb images 96 @test "run zb benchmark and let zot sync all repos" { 97 local zot_sync_per_root_dir=${BATS_FILE_TMPDIR}/zot-per 98 local zot_sync_per_config_file=${BATS_FILE_TMPDIR}/zot_sync_per_config.json 99 local zot_minimal_root_dir=${BATS_FILE_TMPDIR}/zot-minimal 100 local ZOT_LOG_FILE=${zot_sync_per_root_dir}/zot.log 101 102 zb_run "http://127.0.0.1:8080" 103 104 # start zot sync server 105 zot_serve ${ZOT_PATH} ${zot_sync_per_config_file} 106 wait_zot_reachable 8081 107 108 start=`date +%s` 109 echo "waiting for sync to finish" >&3 110 111 run wait_for_string "sync: finished syncing all repos" ${ZOT_LOG_FILE} "5m" 112 [ "$status" -eq 0 ] 113 114 end=`date +%s` 115 116 runtime=$((end-start)) 117 echo "sync finished in $runtime sec" >&3 118 sleep 10 # wait a bit more because sync runs in background. 119 120 # diff, but exclude log files, .sync subdirs and cache.db 121 run diff -r -x "*.db" -x ".sync" -x "*.log" ${zot_sync_per_root_dir} ${zot_minimal_root_dir} 122 [ "$status" -eq 0 ] 123 }