diff --git a/go.mod b/go.mod index 40242b0030..7562dd4c45 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/notaryproject/notation-go v1.1.0 github.com/opencontainers/distribution-spec/specs-go v0.0.0-20240201174943-0f98d91a0afe github.com/project-zot/mockoidc v0.0.0-20230307111146-f607b4b5fb97 - github.com/redis/go-redis/v9 v9.3.0 + github.com/redis/go-redis/v9 v9.5.1 github.com/sigstore/cosign/v2 v2.2.4 github.com/swaggo/http-swagger v1.3.4 github.com/zitadel/oidc v1.13.5 @@ -195,7 +195,6 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/rootless-containers/proto/go-proto v0.0.0-20210921234734-69430b6543fb // indirect github.com/rubenv/sql-migrate v1.5.2 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -203,7 +202,6 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/sigstore/timestamp-authority v1.2.2 // indirect - github.com/sigstore/cosign v1.13.1 // indirect github.com/skeema/knownhosts v1.2.1 // indirect github.com/smarty/assertions v1.15.0 // indirect github.com/sosodev/duration v1.2.0 // indirect @@ -215,6 +213,7 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xlab/treeprint v1.2.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/yuin/gopher-lua v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect diff --git a/go.sum b/go.sum index 5294687eed..49eb4e2216 100644 --- a/go.sum +++ b/go.sum @@ -254,6 +254,7 @@ github.com/CycloneDX/cyclonedx-go v0.8.0 h1:FyWVj6x6hoJrui5uRQdYZcSievw3Z32Z88uY github.com/CycloneDX/cyclonedx-go v0.8.0/go.mod h1:K2bA+324+Og0X84fA8HhN2X066K7Bxz4rpMQ4ZhjtSk= github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/DmitriyVTitov/size v1.5.0/go.mod h1:le6rNI4CoLQV1b9gzp1+3d7hMAD/uu2QcJ+aYbNgiU0= github.com/GoogleCloudPlatform/docker-credential-gcr v2.0.5+incompatible h1:juIaKLLVhqzP55d8x4cSVgwyQv76Z55/fRv/UBr2KkQ= github.com/GoogleCloudPlatform/docker-credential-gcr v2.0.5+incompatible/go.mod h1:BB1eHdMLYEFuFdBlRMb0N7YGVdM5s6Pt0njxgvfbGGs= github.com/Intevation/gval v1.3.0 h1:+Ze5sft5MmGbZrHj06NVUbcxCb67l9RaPTLMNr37mjw= @@ -1314,8 +1315,8 @@ github.com/protocolbuffers/txtpbfmt v0.0.0-20231025115547-084445ff1adf h1:014O62 github.com/protocolbuffers/txtpbfmt v0.0.0-20231025115547-084445ff1adf/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0= -github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= +github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= diff --git a/pkg/storage/cache/redis.go b/pkg/storage/cache/redis.go index 9fcc6da4a0..1331c75e00 100644 --- a/pkg/storage/cache/redis.go +++ b/pkg/storage/cache/redis.go @@ -40,6 +40,7 @@ func NewRedisCache(parameters interface{}, log zlog.Logger) (*RedisDriver, error if err != nil { log.Error().Err(err).Str("directory", properParameters.URL).Msg("failed to connect to redis") } + cacheDB := redis.NewClient(connOpts) if _, err := cacheDB.Ping(context.Background()).Result(); err != nil { diff --git a/test/blackbox/ci.sh b/test/blackbox/ci.sh index 14974440bd..6e16f53f6a 100755 --- a/test/blackbox/ci.sh +++ b/test/blackbox/ci.sh @@ -9,7 +9,7 @@ PATH=$PATH:${SCRIPTPATH}/../../hack/tools/bin tests=("pushpull" "pushpull_authn" "delete_images" "referrers" "metadata" "anonymous_policy" "annotations" "detect_manifest_collision" "cve" "sync" "sync_docker" "sync_replica_cluster" - "scrub" "garbage_collect" "metrics" "metrics_minimal" "multiarch_index") + "scrub" "garbage_collect" "metrics" "metrics_minimal" "multiarch_index" "redis_local" "redis_s3") for test in ${tests[*]}; do ${BATS} ${BATS_FLAGS} ${SCRIPTPATH}/${test}.bats > ${test}.log & pids+=($!) diff --git a/test/blackbox/redis.bats b/test/blackbox/redis_local.bats similarity index 57% rename from test/blackbox/redis.bats rename to test/blackbox/redis_local.bats index b7cf8fe8fe..cbc86109bf 100644 --- a/test/blackbox/redis.bats +++ b/test/blackbox/redis_local.bats @@ -72,6 +72,43 @@ EOF wait_zot_reachable ${zot_port} } +@test "push 2 images" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo --insecure-policy copy --dest-tls-verify=false \ + oci:${TEST_DATA_DIR}/golang:1.20 \ + docker://127.0.0.1:${zot_port}/golang:1.20 + [ "$status" -eq 0 ] + + run skopeo --insecure-policy copy --dest-tls-verify=false \ + oci:${TEST_DATA_DIR}/golang:1.20 \ + docker://127.0.0.1:${zot_port}/golang2:1.20 + [ "$status" -eq 0 ] + + run curl http://127.0.0.1:${zot_port}/v2/_catalog + [ "$status" -eq 0 ] + [ $(echo "${lines[-1]}" | jq '.repositories[]') = '"golang"' ] + run curl http://127.0.0.1:${zot_port}/v2/golang/tags/list + [ "$status" -eq 0 ] + [ $(echo "${lines[-1]}" | jq '.tags[]') = '"1.20"' ] +} + +@test "pull both images" { + local oci_data_dir=${BATS_FILE_TMPDIR}/oci + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo --insecure-policy copy --src-tls-verify=false \ + docker://127.0.0.1:${zot_port}/golang:1.20 \ + oci:${oci_data_dir}/golang:1.20 + [ "$status" -eq 0 ] + run cat ${BATS_FILE_TMPDIR}/oci/golang/index.json + [ "$status" -eq 0 ] + [ $(echo "${lines[-1]}" | jq '.manifests[].annotations."org.opencontainers.image.ref.name"') = '"1.20"' ] + + run skopeo --insecure-policy copy --src-tls-verify=false \ + docker://127.0.0.1:${zot_port}/golang2:1.20 \ + oci:${oci_data_dir}/golang:1.20 + [ "$status" -eq 0 ] +} + function teardown_file() { zot_stop_all redis_stop diff --git a/test/blackbox/redis_s3.bats b/test/blackbox/redis_s3.bats new file mode 100644 index 0000000000..8a66325a8c --- /dev/null +++ b/test/blackbox/redis_s3.bats @@ -0,0 +1,127 @@ +# Note: Intended to be run as "make run-blackbox-tests" or "make run-blackbox-ci" +# Makefile target installs & checks all necessary tooling +# Extra tools that are not covered in Makefile target needs to be added in verify_prerequisites() + +load helpers_zot +load helpers_redis +load helpers_cloud + +function verify_prerequisites() { + if [ ! $(command -v curl) ]; then + echo "you need to install curl as a prerequisite to running the tests" >&3 + return 1 + fi + + if [ ! $(command -v jq) ]; then + echo "you need to install jq as a prerequisite to running the tests" >&3 + return 1 + fi + + if [ ! $(command -v docker) ]; then + echo "you need to install docker as a prerequisite to running the tests" >&3 + return 1 + fi + + return 0 +} + +function setup_file() { + # Verify prerequisites are available + if ! $(verify_prerequisites); then + exit 1 + fi + + # Setup redis server + redis_start + + # Setup zot server + local zot_root_dir=${BATS_FILE_TMPDIR}/zot + local zot_sync_ondemand_config_file=${BATS_FILE_TMPDIR}/zot_sync_ondemand_config.json + zot_port=$(get_free_port) + echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port + + mkdir -p ${zot_root_dir} + + cat >${zot_sync_ondemand_config_file} <