mirror of
https://github.com/distribution/distribution
synced 2024-11-06 19:35:52 +01:00
Merge pull request #3932 from flavianmissi/fix-azure-test-parameters
registry/storage/driver: test call to Stat(ctx, "/")
This commit is contained in:
commit
ba46c769b3
@ -63,7 +63,8 @@ func New(params *Parameters) (*Driver, error) {
|
|||||||
d := &driver{
|
d := &driver{
|
||||||
azClient: azClient,
|
azClient: azClient,
|
||||||
client: client,
|
client: client,
|
||||||
rootDirectory: params.RootDirectory}
|
rootDirectory: params.RootDirectory,
|
||||||
|
}
|
||||||
return &Driver{baseEmbed: baseEmbed{Base: base.Base{StorageDriver: d}}}, nil
|
return &Driver{baseEmbed: baseEmbed{Base: base.Base{StorageDriver: d}}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,11 +421,24 @@ func (d *driver) listBlobs(ctx context.Context, virtPath string) ([]string, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) blobName(path string) string {
|
func (d *driver) blobName(path string) string {
|
||||||
|
// avoid returning an empty blob name.
|
||||||
|
// this will happen when rootDirectory is unset, and path == "/",
|
||||||
|
// which is what we get from the storage driver health check Stat call.
|
||||||
|
if d.rootDirectory == "" && path == "/" {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
return strings.TrimLeft(strings.TrimRight(d.rootDirectory, "/")+path, "/")
|
return strings.TrimLeft(strings.TrimRight(d.rootDirectory, "/")+path, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func is404(err error) bool {
|
func is404(err error) bool {
|
||||||
return bloberror.HasCode(err, bloberror.BlobNotFound, bloberror.ContainerNotFound, bloberror.ResourceNotFound)
|
return bloberror.HasCode(
|
||||||
|
err,
|
||||||
|
bloberror.BlobNotFound,
|
||||||
|
bloberror.ContainerNotFound,
|
||||||
|
bloberror.ResourceNotFound,
|
||||||
|
bloberror.CannotVerifyCopySource,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type writer struct {
|
type writer struct {
|
||||||
|
@ -52,14 +52,18 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
azureDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
azureDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
||||||
params := Parameters{
|
parameters := map[string]interface{}{
|
||||||
Container: container,
|
"container": container,
|
||||||
AccountName: accountName,
|
"accountname": accountName,
|
||||||
AccountKey: accountKey,
|
"accountkey": accountKey,
|
||||||
Realm: realm,
|
"realm": realm,
|
||||||
RootDirectory: rootDirectory,
|
"rootdirectory": rootDirectory,
|
||||||
}
|
}
|
||||||
return New(¶ms)
|
params, err := NewParameters(parameters)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return New(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip Azure storage driver tests if environment variable parameters are not provided
|
// Skip Azure storage driver tests if environment variable parameters are not provided
|
||||||
|
@ -388,7 +388,11 @@ func (suite *DriverSuite) TestReaderWithOffset(c *check.C) {
|
|||||||
// TestContinueStreamAppendLarge tests that a stream write can be appended to without
|
// TestContinueStreamAppendLarge tests that a stream write can be appended to without
|
||||||
// corrupting the data with a large chunk size.
|
// corrupting the data with a large chunk size.
|
||||||
func (suite *DriverSuite) TestContinueStreamAppendLarge(c *check.C) {
|
func (suite *DriverSuite) TestContinueStreamAppendLarge(c *check.C) {
|
||||||
suite.testContinueStreamAppend(c, int64(10*1024*1024))
|
chunkSize := int64(10 * 1024 * 1024)
|
||||||
|
if suite.Name() == "azure" {
|
||||||
|
chunkSize = int64(4 * 1024 * 1024)
|
||||||
|
}
|
||||||
|
suite.testContinueStreamAppend(c, chunkSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestContinueStreamAppendSmall is the same as TestContinueStreamAppendLarge, but only
|
// TestContinueStreamAppendSmall is the same as TestContinueStreamAppendLarge, but only
|
||||||
@ -824,6 +828,15 @@ func (suite *DriverSuite) TestStatCall(c *check.C) {
|
|||||||
c.Assert(fi.Path(), check.Equals, dirPath)
|
c.Assert(fi.Path(), check.Equals, dirPath)
|
||||||
c.Assert(fi.Size(), check.Equals, int64(0))
|
c.Assert(fi.Size(), check.Equals, int64(0))
|
||||||
c.Assert(fi.IsDir(), check.Equals, true)
|
c.Assert(fi.IsDir(), check.Equals, true)
|
||||||
|
|
||||||
|
// The storage healthcheck performs this exact call to Stat.
|
||||||
|
// PathNotFoundErrors are not considered health check failures.
|
||||||
|
_, err = suite.StorageDriver.Stat(suite.ctx, "/")
|
||||||
|
// Some drivers will return a not found here, while others will not
|
||||||
|
// return an error at all. If we get an error, ensure it's a not found.
|
||||||
|
if err != nil {
|
||||||
|
c.Assert(err, check.FitsTypeOf, storagedriver.PathNotFoundError{})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPutContentMultipleTimes checks that if storage driver can overwrite the content
|
// TestPutContentMultipleTimes checks that if storage driver can overwrite the content
|
||||||
|
Loading…
Reference in New Issue
Block a user