mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
redis driver for blob cache information and metadb (#2865)
* feat: add redis cache support https://github.com/project-zot/zot/pull/2005 Fixes https://github.com/project-zot/zot/issues/2004 * feat: add redis cache support Currently, we have dynamoDB as the remote shared cache but ideal only for the cloud use case. For on-prem use case, add support for redis. Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> * feat(redis): added blackbox tests for redis Signed-off-by: Petu Eusebiu <peusebiu@cisco.com> * feat(redis): dummy implementation of MetaDB interface for redis cache Signed-off-by: Alexei Dodon <adodon@cisco.com> * feat: check validity of driver configuration on metadb instantiation Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat: multiple fixes for redis cache driver implementation - add missing method GetAllBlobs - add redis cache tests, with and without mocking Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): redis implementation for MetaDB Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): use redsync to block concurrent write access to the redis DB Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): update .github/workflows/cluster.yaml to also test redis Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(metadb): add keyPrefix parameter for redis and remove unneeded method meta.Crate() Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): support RedisCluster configuration and add unit tests Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): more tests for redis metadb implementation Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): add more examples and update examples/README.md Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): move option parsing and redis client initialization under pkg/api/config/redis Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * chore(cachedb): move Cache interface to pkg/storage/types Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): reorganize code in pkg/storage/cache.go Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): call redis.SetLogger() with the zot logger as parameter Signed-off-by: Andrei Aaron <aaaron@luxoft.com> * feat(redis): rename pkg/meta/redisdb to pkg/meta/redis Signed-off-by: Andrei Aaron <aaaron@luxoft.com> --------- Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> Signed-off-by: Petu Eusebiu <peusebiu@cisco.com> Signed-off-by: Alexei Dodon <adodon@cisco.com> Signed-off-by: Andrei Aaron <aaaron@luxoft.com> Co-authored-by: a <a@tuxpa.in> Co-authored-by: Ramkumar Chinchani <rchincha@cisco.com> Co-authored-by: Petu Eusebiu <peusebiu@cisco.com> Co-authored-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
@@ -11,16 +11,19 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
rediscfg "zotregistry.dev/zot/pkg/api/config/redis"
|
||||
zcommon "zotregistry.dev/zot/pkg/common"
|
||||
"zotregistry.dev/zot/pkg/extensions/monitoring"
|
||||
"zotregistry.dev/zot/pkg/log"
|
||||
"zotregistry.dev/zot/pkg/meta"
|
||||
"zotregistry.dev/zot/pkg/meta/boltdb"
|
||||
"zotregistry.dev/zot/pkg/meta/dynamodb"
|
||||
"zotregistry.dev/zot/pkg/meta/redis"
|
||||
mTypes "zotregistry.dev/zot/pkg/meta/types"
|
||||
"zotregistry.dev/zot/pkg/storage"
|
||||
"zotregistry.dev/zot/pkg/storage/local"
|
||||
@@ -302,6 +305,27 @@ func TestParseStorageWithBoltDB(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseStorageWithRedisDB(t *testing.T) {
|
||||
Convey("Redis", t, func() {
|
||||
miniRedis := miniredis.RunT(t)
|
||||
|
||||
rootDir := t.TempDir()
|
||||
log := log.NewLogger("debug", "")
|
||||
|
||||
params := redis.DBDriverParameters{KeyPrefix: "zot"}
|
||||
driverConfig := map[string]interface{}{"url": "redis://" + miniRedis.Addr()}
|
||||
|
||||
redisDriver, err := rediscfg.GetRedisClient(driverConfig, log)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
metaDB, err := redis.New(redisDriver, params, log)
|
||||
So(metaDB, ShouldNotBeNil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
RunParseStorageTests(rootDir, metaDB, log)
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseStorageDynamoWrapper(t *testing.T) {
|
||||
tskip.SkipDynamo(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user