mirror of
https://github.com/project-zot/zot.git
synced 2024-12-30 22:34:13 -05:00
fix: running tests locally fails (#1879)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
parent
e6902b937f
commit
044ea85279
16 changed files with 88 additions and 138 deletions
|
@ -69,6 +69,7 @@ import (
|
||||||
"zotregistry.io/zot/pkg/test/mocks"
|
"zotregistry.io/zot/pkg/test/mocks"
|
||||||
ociutils "zotregistry.io/zot/pkg/test/oci-utils"
|
ociutils "zotregistry.io/zot/pkg/test/oci-utils"
|
||||||
"zotregistry.io/zot/pkg/test/signature"
|
"zotregistry.io/zot/pkg/test/signature"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -98,22 +99,6 @@ func getCredString(username, password string) string {
|
||||||
return usernameAndHash
|
return usernameAndHash
|
||||||
}
|
}
|
||||||
|
|
||||||
func skipIt(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if os.Getenv("S3MOCK_ENDPOINT") == "" {
|
|
||||||
t.Skip("Skipping testing without AWS S3 mock server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func skipDynamo(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
|
|
||||||
t.Skip("Skipping testing without AWS DynamoDB mock server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
Convey("Make a new controller", t, func() {
|
Convey("Make a new controller", t, func() {
|
||||||
conf := config.New()
|
conf := config.New()
|
||||||
|
@ -147,8 +132,8 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
|
||||||
driver = storage.CreateCacheDatabaseDriver(conf.Storage.StorageConfig, log)
|
driver = storage.CreateCacheDatabaseDriver(conf.Storage.StorageConfig, log)
|
||||||
So(driver, ShouldBeNil)
|
So(driver, ShouldBeNil)
|
||||||
})
|
})
|
||||||
skipDynamo(t)
|
tskip.SkipDynamo(t)
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
Convey("Test CreateCacheDatabaseDriver dynamodb", t, func() {
|
Convey("Test CreateCacheDatabaseDriver dynamodb", t, func() {
|
||||||
log := log.NewLogger("debug", "")
|
log := log.NewLogger("debug", "")
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
@ -166,9 +151,10 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
|
||||||
"skipverify": false,
|
"skipverify": false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT")
|
||||||
conf.Storage.CacheDriver = map[string]interface{}{
|
conf.Storage.CacheDriver = map[string]interface{}{
|
||||||
"name": "dynamodb",
|
"name": "dynamodb",
|
||||||
"endpoint": "http://localhost:4566",
|
"endpoint": endpoint,
|
||||||
"region": "us-east-2",
|
"region": "us-east-2",
|
||||||
"cacheTablename": "BlobTable",
|
"cacheTablename": "BlobTable",
|
||||||
"repoMetaTablename": "RepoMetadataTable",
|
"repoMetaTablename": "RepoMetadataTable",
|
||||||
|
@ -183,7 +169,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
|
||||||
// negative test cases
|
// negative test cases
|
||||||
|
|
||||||
conf.Storage.CacheDriver = map[string]interface{}{
|
conf.Storage.CacheDriver = map[string]interface{}{
|
||||||
"endpoint": "http://localhost:4566",
|
"endpoint": endpoint,
|
||||||
"region": "us-east-2",
|
"region": "us-east-2",
|
||||||
"cacheTablename": "BlobTable",
|
"cacheTablename": "BlobTable",
|
||||||
"repoMetaTablename": "RepoMetadataTable",
|
"repoMetaTablename": "RepoMetadataTable",
|
||||||
|
@ -197,7 +183,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
|
||||||
|
|
||||||
conf.Storage.CacheDriver = map[string]interface{}{
|
conf.Storage.CacheDriver = map[string]interface{}{
|
||||||
"name": "dummy",
|
"name": "dummy",
|
||||||
"endpoint": "http://localhost:4566",
|
"endpoint": endpoint,
|
||||||
"region": "us-east-2",
|
"region": "us-east-2",
|
||||||
"cacheTablename": "BlobTable",
|
"cacheTablename": "BlobTable",
|
||||||
"repoMetaTablename": "RepoMetadataTable",
|
"repoMetaTablename": "RepoMetadataTable",
|
||||||
|
@ -371,7 +357,8 @@ func TestAutoPortSelection(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestObjectStorageController(t *testing.T) {
|
func TestObjectStorageController(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
tskip.SkipDynamo(t)
|
||||||
|
|
||||||
bucket := "zot-storage-test"
|
bucket := "zot-storage-test"
|
||||||
|
|
||||||
|
@ -438,7 +425,7 @@ func TestObjectStorageController(t *testing.T) {
|
||||||
|
|
||||||
conf.Storage.CacheDriver = map[string]interface{}{
|
conf.Storage.CacheDriver = map[string]interface{}{
|
||||||
"name": "dynamodb",
|
"name": "dynamodb",
|
||||||
"endpoint": "http://localhost:4566",
|
"endpoint": os.Getenv("DYNAMODBMOCK_ENDPOINT"),
|
||||||
"region": "us-east-2",
|
"region": "us-east-2",
|
||||||
"cachetablename": "test",
|
"cachetablename": "test",
|
||||||
"repometatablename": "RepoMetadataTable",
|
"repometatablename": "RepoMetadataTable",
|
||||||
|
@ -493,7 +480,7 @@ func TestObjectStorageController(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestObjectStorageControllerSubPaths(t *testing.T) {
|
func TestObjectStorageControllerSubPaths(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
bucket := "zot-storage-test"
|
bucket := "zot-storage-test"
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,6 @@ var (
|
||||||
httpClientLock sync.Mutex //nolint: gochecknoglobals
|
httpClientLock sync.Mutex //nolint: gochecknoglobals
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
httpTimeout = 5 * time.Minute
|
|
||||||
certsPath = "/etc/containers/certs.d"
|
|
||||||
homeCertsDir = ".config/containers/certs.d"
|
|
||||||
clientCertFilename = "client.cert"
|
|
||||||
clientKeyFilename = "client.key"
|
|
||||||
caCertFilename = "ca.crt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func makeGETRequest(ctx context.Context, url, username, password string,
|
func makeGETRequest(ctx context.Context, url, username, password string,
|
||||||
verifyTLS bool, debug bool, resultsPtr interface{}, configWriter io.Writer,
|
verifyTLS bool, debug bool, resultsPtr interface{}, configWriter io.Writer,
|
||||||
) (http.Header, error) {
|
) (http.Header, error) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (spinner *spinnerState) stopSpinner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
waitTimeout = httpTimeout + 5*time.Second
|
waitTimeout = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
type stringResult struct {
|
type stringResult struct {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import (
|
||||||
test "zotregistry.io/zot/pkg/test/common"
|
test "zotregistry.io/zot/pkg/test/common"
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
"zotregistry.io/zot/pkg/test/signature"
|
"zotregistry.io/zot/pkg/test/signature"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
type errReader int
|
type errReader int
|
||||||
|
@ -122,7 +123,7 @@ func TestSignatureUploadAndVerificationLocal(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignatureUploadAndVerificationAWS(t *testing.T) {
|
func TestSignatureUploadAndVerificationAWS(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipDynamo(t)
|
||||||
|
|
||||||
Convey("test with AWS", t, func() {
|
Convey("test with AWS", t, func() {
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
|
@ -1000,11 +1001,3 @@ func RunSignatureUploadAndVerificationTests(t *testing.T, cacheDriverParams map[
|
||||||
So(resp.StatusCode(), ShouldEqual, http.StatusInternalServerError)
|
So(resp.StatusCode(), ShouldEqual, http.StatusInternalServerError)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func skipIt(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
|
|
||||||
t.Skip("Skipping testing without AWS mock server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import (
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
"zotregistry.io/zot/pkg/test/mocks"
|
"zotregistry.io/zot/pkg/test/mocks"
|
||||||
"zotregistry.io/zot/pkg/test/signature"
|
"zotregistry.io/zot/pkg/test/signature"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -658,7 +659,7 @@ func TestLocalTrustStore(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAWSTrustStore(t *testing.T) {
|
func TestAWSTrustStore(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipDynamo(t)
|
||||||
|
|
||||||
trustpolicy := "trustpolicy"
|
trustpolicy := "trustpolicy"
|
||||||
|
|
||||||
|
@ -1336,11 +1337,3 @@ func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func skipIt(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
|
|
||||||
t.Skip("Skipping testing without AWS mock server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -2012,6 +2012,7 @@ func TestMandatoryAnnotations(t *testing.T) {
|
||||||
|
|
||||||
logFile, err := os.CreateTemp("", "zot-log*.txt")
|
logFile, err := os.CreateTemp("", "zot-log*.txt")
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
defer os.Remove(logFile.Name())
|
||||||
|
|
||||||
destConfig.Log.Output = logFile.Name()
|
destConfig.Log.Output = logFile.Name()
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,14 @@ import (
|
||||||
|
|
||||||
"zotregistry.io/zot/pkg/log" //nolint:go-staticcheck
|
"zotregistry.io/zot/pkg/log" //nolint:go-staticcheck
|
||||||
"zotregistry.io/zot/pkg/meta/version"
|
"zotregistry.io/zot/pkg/meta/version"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWrapperErrors(t *testing.T) {
|
func TestWrapperErrors(t *testing.T) {
|
||||||
const (
|
tskip.SkipDynamo(t)
|
||||||
endpoint = "http://localhost:4566"
|
|
||||||
region = "us-east-2"
|
const region = "us-east-2"
|
||||||
)
|
endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT")
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -23,15 +23,16 @@ import (
|
||||||
mTypes "zotregistry.io/zot/pkg/meta/types"
|
mTypes "zotregistry.io/zot/pkg/meta/types"
|
||||||
reqCtx "zotregistry.io/zot/pkg/requestcontext"
|
reqCtx "zotregistry.io/zot/pkg/requestcontext"
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const badTablename = "bad tablename"
|
const badTablename = "bad tablename"
|
||||||
|
|
||||||
func TestIterator(t *testing.T) {
|
func TestIterator(t *testing.T) {
|
||||||
const (
|
tskip.SkipDynamo(t)
|
||||||
endpoint = "http://localhost:4566"
|
|
||||||
region = "us-east-2"
|
const region = "us-east-2"
|
||||||
)
|
endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT")
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -131,10 +132,10 @@ func TestIteratorErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrapperErrors(t *testing.T) {
|
func TestWrapperErrors(t *testing.T) {
|
||||||
const (
|
tskip.SkipDynamo(t)
|
||||||
endpoint = "http://localhost:4566"
|
|
||||||
region = "us-east-2"
|
const region = "us-east-2"
|
||||||
)
|
endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT")
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import (
|
||||||
"zotregistry.io/zot/pkg/test/deprecated"
|
"zotregistry.io/zot/pkg/test/deprecated"
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
signature "zotregistry.io/zot/pkg/test/signature"
|
signature "zotregistry.io/zot/pkg/test/signature"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -97,7 +98,7 @@ func TestBoltDB(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDynamoDBWrapper(t *testing.T) {
|
func TestDynamoDBWrapper(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipDynamo(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2688,7 +2689,7 @@ func generateTestImage() ([]byte, []byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateDynamo(t *testing.T) {
|
func TestCreateDynamo(t *testing.T) {
|
||||||
skipDynamo(t)
|
tskip.SkipDynamo(t)
|
||||||
|
|
||||||
Convey("Create", t, func() {
|
Convey("Create", t, func() {
|
||||||
dynamoDBDriverParams := mdynamodb.DBDriverParameters{
|
dynamoDBDriverParams := mdynamodb.DBDriverParameters{
|
||||||
|
@ -2747,11 +2748,3 @@ func TestCreateBoltDB(t *testing.T) {
|
||||||
So(func() { _, _ = meta.Create("boltdb", nil, mdynamodb.DBDriverParameters{}, log) }, ShouldPanic)
|
So(func() { _, _ = meta.Create("boltdb", nil, mdynamodb.DBDriverParameters{}, log) }, ShouldPanic)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func skipDynamo(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
|
|
||||||
t.Skip("Skipping testing without AWS DynamoDB mock server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import (
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
"zotregistry.io/zot/pkg/test/mocks"
|
"zotregistry.io/zot/pkg/test/mocks"
|
||||||
"zotregistry.io/zot/pkg/test/signature"
|
"zotregistry.io/zot/pkg/test/signature"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const repo = "repo"
|
const repo = "repo"
|
||||||
|
@ -367,7 +368,7 @@ func TestParseStorageWithBoltDB(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseStorageDynamoWrapper(t *testing.T) {
|
func TestParseStorageDynamoWrapper(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipDynamo(t)
|
||||||
|
|
||||||
Convey("Dynamodb", t, func() {
|
Convey("Dynamodb", t, func() {
|
||||||
rootDir := t.TempDir()
|
rootDir := t.TempDir()
|
||||||
|
@ -596,14 +597,6 @@ func TestGetReferredInfo(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func skipIt(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if os.Getenv("S3MOCK_ENDPOINT") == "" {
|
|
||||||
t.Skip("Skipping testing without AWS S3 mock server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetSignatureLayersInfo(t *testing.T) {
|
func TestGetSignatureLayersInfo(t *testing.T) {
|
||||||
Convey("wrong signature type", t, func() {
|
Convey("wrong signature type", t, func() {
|
||||||
layers, err := meta.GetSignatureLayersInfo("repo", "tag", "123", "wrong signature type", []byte{},
|
layers, err := meta.GetSignatureLayersInfo("repo", "tag", "123", "wrong signature type", []byte{},
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"zotregistry.io/zot/pkg/meta/boltdb"
|
"zotregistry.io/zot/pkg/meta/boltdb"
|
||||||
mdynamodb "zotregistry.io/zot/pkg/meta/dynamodb"
|
mdynamodb "zotregistry.io/zot/pkg/meta/dynamodb"
|
||||||
"zotregistry.io/zot/pkg/meta/version"
|
"zotregistry.io/zot/pkg/meta/version"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrTestError = errors.New("test error")
|
var ErrTestError = errors.New("test error")
|
||||||
|
@ -113,15 +114,12 @@ func setBoltDBVersion(db *bbolt.DB, vers string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVersioningDynamoDB(t *testing.T) {
|
func TestVersioningDynamoDB(t *testing.T) {
|
||||||
const (
|
tskip.SkipDynamo(t)
|
||||||
endpoint = "http://localhost:4566"
|
|
||||||
region = "us-east-2"
|
|
||||||
)
|
|
||||||
|
|
||||||
Convey("Tests", t, func() {
|
Convey("Tests", t, func() {
|
||||||
params := mdynamodb.DBDriverParameters{
|
params := mdynamodb.DBDriverParameters{
|
||||||
Endpoint: endpoint,
|
Endpoint: os.Getenv("DYNAMODBMOCK_ENDPOINT"),
|
||||||
Region: region,
|
Region: "us-east-2",
|
||||||
RepoMetaTablename: "RepoMetadataTable",
|
RepoMetaTablename: "RepoMetadataTable",
|
||||||
ManifestDataTablename: "ManifestDataTable",
|
ManifestDataTablename: "ManifestDataTable",
|
||||||
IndexDataTablename: "IndexDataTable",
|
IndexDataTablename: "IndexDataTable",
|
||||||
|
|
11
pkg/storage/cache/dynamodb_test.go
vendored
11
pkg/storage/cache/dynamodb_test.go
vendored
|
@ -11,18 +11,11 @@ import (
|
||||||
"zotregistry.io/zot/pkg/log"
|
"zotregistry.io/zot/pkg/log"
|
||||||
"zotregistry.io/zot/pkg/storage"
|
"zotregistry.io/zot/pkg/storage"
|
||||||
"zotregistry.io/zot/pkg/storage/cache"
|
"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) {
|
func TestDynamoDB(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipDynamo(t)
|
||||||
Convey("Test dynamoDB", t, func(c C) {
|
Convey("Test dynamoDB", t, func(c C) {
|
||||||
log := log.NewLogger("debug", "")
|
log := log.NewLogger("debug", "")
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
|
@ -40,6 +40,7 @@ import (
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
"zotregistry.io/zot/pkg/test/inject"
|
"zotregistry.io/zot/pkg/test/inject"
|
||||||
"zotregistry.io/zot/pkg/test/mocks"
|
"zotregistry.io/zot/pkg/test/mocks"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
|
@ -58,18 +59,6 @@ func cleanupStorage(store driver.StorageDriver, name string) {
|
||||||
_ = store.Delete(context.Background(), name)
|
_ = 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,
|
func createMockStorage(rootDir string, cacheDir string, dedupe bool, store driver.StorageDriver,
|
||||||
) storageTypes.ImageStore {
|
) storageTypes.ImageStore {
|
||||||
log := log.Logger{Logger: zerolog.New(os.Stdout)}
|
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) {
|
func TestStorageDriverStatFunction(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -462,7 +451,7 @@ func TestStorageDriverStatFunction(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetOrasAndOCIReferrers(t *testing.T) {
|
func TestGetOrasAndOCIReferrers(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
repo := "zot-test"
|
repo := "zot-test"
|
||||||
|
|
||||||
|
@ -623,7 +612,7 @@ func TestGetOrasAndOCIReferrers(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNegativeCasesObjectsStorage(t *testing.T) {
|
func TestNegativeCasesObjectsStorage(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1239,7 +1228,8 @@ func TestNegativeCasesObjectsStorage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestS3Dedupe(t *testing.T) {
|
func TestS3Dedupe(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
tskip.SkipDynamo(t)
|
||||||
Convey("Dedupe", t, func(c C) {
|
Convey("Dedupe", t, func(c C) {
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1928,7 +1918,7 @@ func TestS3Dedupe(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuildDedupeIndex(t *testing.T) {
|
func TestRebuildDedupeIndex(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
Convey("Push images with dedupe true", t, func() {
|
Convey("Push images with dedupe true", t, func() {
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
|
@ -2260,7 +2250,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuildDedupeMockStoreDriver(t *testing.T) {
|
func TestRebuildDedupeMockStoreDriver(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2783,7 +2773,7 @@ func TestRebuildDedupeMockStoreDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestS3PullRange(t *testing.T) {
|
func TestS3PullRange(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
Convey("Test against s3 image store", t, func() {
|
Convey("Test against s3 image store", t, func() {
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
|
@ -2959,7 +2949,7 @@ func TestS3PullRange(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestS3ManifestImageIndex(t *testing.T) {
|
func TestS3ManifestImageIndex(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
Convey("Test against s3 image store", t, func() {
|
Convey("Test against s3 image store", t, func() {
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
|
@ -3539,7 +3529,7 @@ func TestS3ManifestImageIndex(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestS3DedupeErr(t *testing.T) {
|
func TestS3DedupeErr(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"zotregistry.io/zot/pkg/test/deprecated"
|
"zotregistry.io/zot/pkg/test/deprecated"
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
"zotregistry.io/zot/pkg/test/mocks"
|
"zotregistry.io/zot/pkg/test/mocks"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -56,7 +57,7 @@ func TestLocalCheckAllBlobsIntegrity(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestS3CheckAllBlobsIntegrity(t *testing.T) {
|
func TestS3CheckAllBlobsIntegrity(t *testing.T) {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
Convey("test with S3 storage", t, func() {
|
Convey("test with S3 storage", t, func() {
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
|
|
|
@ -41,20 +41,13 @@ import (
|
||||||
storageTypes "zotregistry.io/zot/pkg/storage/types"
|
storageTypes "zotregistry.io/zot/pkg/storage/types"
|
||||||
. "zotregistry.io/zot/pkg/test/image-utils"
|
. "zotregistry.io/zot/pkg/test/image-utils"
|
||||||
"zotregistry.io/zot/pkg/test/mocks"
|
"zotregistry.io/zot/pkg/test/mocks"
|
||||||
|
tskip "zotregistry.io/zot/pkg/test/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cleanupStorage(store driver.StorageDriver, name string) {
|
func cleanupStorage(store driver.StorageDriver, name string) {
|
||||||
_ = store.Delete(context.Background(), name)
|
_ = 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) (
|
func createObjectsStore(rootDir string, cacheDir string) (
|
||||||
driver.StorageDriver, storageTypes.ImageStore, error,
|
driver.StorageDriver, storageTypes.ImageStore, error,
|
||||||
) {
|
) {
|
||||||
|
@ -120,7 +113,7 @@ func TestStorageAPIs(t *testing.T) {
|
||||||
t.Run(testcase.testCaseName, func(t *testing.T) {
|
t.Run(testcase.testCaseName, func(t *testing.T) {
|
||||||
var imgStore storageTypes.ImageStore
|
var imgStore storageTypes.ImageStore
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -752,7 +745,7 @@ func TestMandatoryAnnotations(t *testing.T) {
|
||||||
metrics := monitoring.NewMetricsServer(false, log)
|
metrics := monitoring.NewMetricsServer(false, log)
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -876,7 +869,7 @@ func TestDeleteBlobsInUse(t *testing.T) {
|
||||||
metrics := monitoring.NewMetricsServer(false, log)
|
metrics := monitoring.NewMetricsServer(false, log)
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1175,7 +1168,7 @@ func TestStorageHandler(t *testing.T) {
|
||||||
var thirdRootDir string
|
var thirdRootDir string
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
var firstStorageDriver driver.StorageDriver
|
var firstStorageDriver driver.StorageDriver
|
||||||
var secondStorageDriver driver.StorageDriver
|
var secondStorageDriver driver.StorageDriver
|
||||||
var thirdStorageDriver driver.StorageDriver
|
var thirdStorageDriver driver.StorageDriver
|
||||||
|
@ -1263,7 +1256,7 @@ func TestGarbageCollectImageManifest(t *testing.T) {
|
||||||
Convey("Garbage collect with default/long delay", func() {
|
Convey("Garbage collect with default/long delay", func() {
|
||||||
var imgStore storageTypes.ImageStore
|
var imgStore storageTypes.ImageStore
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1425,7 +1418,7 @@ func TestGarbageCollectImageManifest(t *testing.T) {
|
||||||
gcDelay := 1 * time.Second
|
gcDelay := 1 * time.Second
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1736,7 +1729,7 @@ func TestGarbageCollectImageManifest(t *testing.T) {
|
||||||
gcDelay := 3 * time.Second
|
gcDelay := 3 * time.Second
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1972,7 +1965,7 @@ func TestGarbageCollectImageIndex(t *testing.T) {
|
||||||
Convey("Garbage collect with default/long delay", func() {
|
Convey("Garbage collect with default/long delay", func() {
|
||||||
var imgStore storageTypes.ImageStore
|
var imgStore storageTypes.ImageStore
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2102,7 +2095,7 @@ func TestGarbageCollectImageIndex(t *testing.T) {
|
||||||
imageRetentionDelay := 2 * time.Second
|
imageRetentionDelay := 2 * time.Second
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2412,7 +2405,7 @@ func TestGarbageCollectChainedImageIndexes(t *testing.T) {
|
||||||
imageRetentionDelay := 5 * time.Second
|
imageRetentionDelay := 5 * time.Second
|
||||||
|
|
||||||
if testcase.storageType == storageConstants.S3StorageDriverName {
|
if testcase.storageType == storageConstants.S3StorageDriverName {
|
||||||
skipIt(t)
|
tskip.SkipS3(t)
|
||||||
|
|
||||||
uuid, err := guuid.NewV4()
|
uuid, err := guuid.NewV4()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
22
pkg/test/skip/testskip.go
Normal file
22
pkg/test/skip/testskip.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package skip
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SkipS3(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
if os.Getenv("S3MOCK_ENDPOINT") == "" {
|
||||||
|
t.Skip("Skipping testing without AWS S3 mock server")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SkipDynamo(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
|
||||||
|
t.Skip("Skipping testing without AWS DynamoDB mock server")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue