zotregistry.io/zot@v1.4.4-0.20231124084042-02a8ed785457/test/blackbox/scrub.bats (about) 1 # Note: Intended to be run as "make run-blackbox-tests" or "make run-blackbox-ci" 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_scrub 7 8 function verify_prerequisites() { 9 return 0 10 } 11 12 function setup_file(){ 13 skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/test-images/alpine:3.17.3 oci:${TEST_DATA_DIR}/alpine:3.17.3 14 } 15 16 function setup() { 17 # verify prerequisites are available 18 if ! $(verify_prerequisites); then 19 exit 1 20 fi 21 22 # Setup zot server 23 ZOT_ROOT_DIR=${BATS_FILE_TMPDIR}/zot 24 echo ${ZOT_ROOT_DIR} 25 ZOT_LOG_FILE=${ZOT_ROOT_DIR}/zot-log.json 26 ZOT_CONFIG_FILE=${BATS_FILE_TMPDIR}/zot_config.json 27 zot_port=$(get_free_port) 28 echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port 29 mkdir -p ${ZOT_ROOT_DIR} 30 touch ${ZOT_LOG_FILE} 31 cat >${ZOT_CONFIG_FILE} <<EOF 32 { 33 "distSpecVersion": "1.1.0-dev", 34 "storage": { 35 "rootDirectory": "${ZOT_ROOT_DIR}", 36 "dedupe": false 37 }, 38 "http": { 39 "address": "0.0.0.0", 40 "port": "${zot_port}" 41 }, 42 "log": { 43 "level": "debug", 44 "output": "${ZOT_LOG_FILE}" 45 }, 46 "extensions": { 47 "scrub": { 48 "enable": true, 49 "interval": "2h" 50 } 51 } 52 } 53 EOF 54 55 } 56 57 function teardown() { 58 cat ${BATS_FILE_TMPDIR}/zot/zot-log.json 59 zot_stop_all 60 } 61 62 @test "blobs/manifest integrity not affected" { 63 zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` 64 add_test_files 65 echo ${ZOT_CONFIG_FILE} 66 zot_serve ${ZOT_PATH} ${ZOT_CONFIG_FILE} 67 wait_zot_reachable ${zot_port} 68 69 # wait for scrub to be done and logs to get populated 70 run sleep 20s 71 run not_affected 72 [ "$status" -eq 0 ] 73 [ $(echo "${lines[0]}" ) = 'true' ] 74 } 75 76 @test "blobs/manifest integrity affected" { 77 zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` 78 add_test_files 79 delete_blob 80 echo ${ZOT_CONFIG_FILE} 81 zot_serve ${ZOT_PATH} ${ZOT_CONFIG_FILE} 82 wait_zot_reachable ${zot_port} 83 84 # wait for scrub to be done and logs to get populated 85 run sleep 20s 86 run affected 87 [ "$status" -eq 0 ] 88 [ $(echo "${lines[0]}" ) = 'true' ] 89 } 90