fix: running tests locally fails (#1879)

Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
Alexei Dodon
2023-10-05 14:34:50 +03:00
committed by GitHub
parent e6902b937f
commit 044ea85279
16 changed files with 88 additions and 138 deletions
+2 -9
View File
@@ -11,18 +11,11 @@ import (
"zotregistry.io/zot/pkg/log"
"zotregistry.io/zot/pkg/storage"
"zotregistry.io/zot/pkg/storage/cache"
tskip "zotregistry.io/zot/pkg/test/skip"
)
func skipIt(t *testing.T) {
t.Helper()
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
t.Skip("Skipping testing without AWS DynamoDB mock server")
}
}
func TestDynamoDB(t *testing.T) {
skipIt(t)
tskip.SkipDynamo(t)
Convey("Test dynamoDB", t, func(c C) {
log := log.NewLogger("debug", "")
dir := t.TempDir()
+11 -21
View File
@@ -40,6 +40,7 @@ import (
. "zotregistry.io/zot/pkg/test/image-utils"
"zotregistry.io/zot/pkg/test/inject"
"zotregistry.io/zot/pkg/test/mocks"
tskip "zotregistry.io/zot/pkg/test/skip"
)
//nolint:gochecknoglobals
@@ -58,18 +59,6 @@ func cleanupStorage(store driver.StorageDriver, name string) {
_ = store.Delete(context.Background(), name)
}
func skipIt(t *testing.T) {
t.Helper()
if os.Getenv("S3MOCK_ENDPOINT") == "" {
t.Skip("Skipping testing without AWS S3 mock server")
}
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
t.Skip("Skipping testing without AWS DynamoDB mock server")
}
}
func createMockStorage(rootDir string, cacheDir string, dedupe bool, store driver.StorageDriver,
) storageTypes.ImageStore {
log := log.Logger{Logger: zerolog.New(os.Stdout)}
@@ -382,7 +371,7 @@ func (s *StorageDriverMock) Walk(ctx context.Context, path string, f driver.Walk
}
func TestStorageDriverStatFunction(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -462,7 +451,7 @@ func TestStorageDriverStatFunction(t *testing.T) {
}
func TestGetOrasAndOCIReferrers(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
repo := "zot-test"
@@ -623,7 +612,7 @@ func TestGetOrasAndOCIReferrers(t *testing.T) {
}
func TestNegativeCasesObjectsStorage(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -1239,7 +1228,8 @@ func TestNegativeCasesObjectsStorage(t *testing.T) {
}
func TestS3Dedupe(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
tskip.SkipDynamo(t)
Convey("Dedupe", t, func(c C) {
uuid, err := guuid.NewV4()
if err != nil {
@@ -1928,7 +1918,7 @@ func TestS3Dedupe(t *testing.T) {
}
func TestRebuildDedupeIndex(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
Convey("Push images with dedupe true", t, func() {
uuid, err := guuid.NewV4()
@@ -2260,7 +2250,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
}
func TestRebuildDedupeMockStoreDriver(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -2783,7 +2773,7 @@ func TestRebuildDedupeMockStoreDriver(t *testing.T) {
}
func TestS3PullRange(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
Convey("Test against s3 image store", t, func() {
uuid, err := guuid.NewV4()
@@ -2959,7 +2949,7 @@ func TestS3PullRange(t *testing.T) {
}
func TestS3ManifestImageIndex(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
Convey("Test against s3 image store", t, func() {
uuid, err := guuid.NewV4()
@@ -3539,7 +3529,7 @@ func TestS3ManifestImageIndex(t *testing.T) {
}
func TestS3DedupeErr(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
+2 -1
View File
@@ -29,6 +29,7 @@ import (
"zotregistry.io/zot/pkg/test/deprecated"
. "zotregistry.io/zot/pkg/test/image-utils"
"zotregistry.io/zot/pkg/test/mocks"
tskip "zotregistry.io/zot/pkg/test/skip"
)
const (
@@ -56,7 +57,7 @@ func TestLocalCheckAllBlobsIntegrity(t *testing.T) {
}
func TestS3CheckAllBlobsIntegrity(t *testing.T) {
skipIt(t)
tskip.SkipS3(t)
Convey("test with S3 storage", t, func() {
uuid, err := guuid.NewV4()
+11 -18
View File
@@ -41,20 +41,13 @@ import (
storageTypes "zotregistry.io/zot/pkg/storage/types"
. "zotregistry.io/zot/pkg/test/image-utils"
"zotregistry.io/zot/pkg/test/mocks"
tskip "zotregistry.io/zot/pkg/test/skip"
)
func cleanupStorage(store driver.StorageDriver, name string) {
_ = store.Delete(context.Background(), name)
}
func skipIt(t *testing.T) {
t.Helper()
if os.Getenv("S3MOCK_ENDPOINT") == "" {
t.Skip("Skipping testing without AWS S3 mock server")
}
}
func createObjectsStore(rootDir string, cacheDir string) (
driver.StorageDriver, storageTypes.ImageStore, error,
) {
@@ -120,7 +113,7 @@ func TestStorageAPIs(t *testing.T) {
t.Run(testcase.testCaseName, func(t *testing.T) {
var imgStore storageTypes.ImageStore
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -752,7 +745,7 @@ func TestMandatoryAnnotations(t *testing.T) {
metrics := monitoring.NewMetricsServer(false, log)
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -876,7 +869,7 @@ func TestDeleteBlobsInUse(t *testing.T) {
metrics := monitoring.NewMetricsServer(false, log)
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -1175,7 +1168,7 @@ func TestStorageHandler(t *testing.T) {
var thirdRootDir string
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
var firstStorageDriver driver.StorageDriver
var secondStorageDriver driver.StorageDriver
var thirdStorageDriver driver.StorageDriver
@@ -1263,7 +1256,7 @@ func TestGarbageCollectImageManifest(t *testing.T) {
Convey("Garbage collect with default/long delay", func() {
var imgStore storageTypes.ImageStore
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -1425,7 +1418,7 @@ func TestGarbageCollectImageManifest(t *testing.T) {
gcDelay := 1 * time.Second
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -1736,7 +1729,7 @@ func TestGarbageCollectImageManifest(t *testing.T) {
gcDelay := 3 * time.Second
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -1972,7 +1965,7 @@ func TestGarbageCollectImageIndex(t *testing.T) {
Convey("Garbage collect with default/long delay", func() {
var imgStore storageTypes.ImageStore
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -2102,7 +2095,7 @@ func TestGarbageCollectImageIndex(t *testing.T) {
imageRetentionDelay := 2 * time.Second
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {
@@ -2412,7 +2405,7 @@ func TestGarbageCollectChainedImageIndexes(t *testing.T) {
imageRetentionDelay := 5 * time.Second
if testcase.storageType == storageConstants.S3StorageDriverName {
skipIt(t)
tskip.SkipS3(t)
uuid, err := guuid.NewV4()
if err != nil {