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
3 changed files with 41 additions and 10 deletions
|
@ -63,7 +63,8 @@ func New(params *Parameters) (*Driver, error) {
|
|||
d := &driver{
|
||||
azClient: azClient,
|
||||
client: client,
|
||||
rootDirectory: params.RootDirectory}
|
||||
rootDirectory: params.RootDirectory,
|
||||
}
|
||||
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 {
|
||||
// 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, "/")
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -52,14 +52,18 @@ func init() {
|
|||
}
|
||||
|
||||
azureDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
||||
params := Parameters{
|
||||
Container: container,
|
||||
AccountName: accountName,
|
||||
AccountKey: accountKey,
|
||||
Realm: realm,
|
||||
RootDirectory: rootDirectory,
|
||||
parameters := map[string]interface{}{
|
||||
"container": container,
|
||||
"accountname": accountName,
|
||||
"accountkey": accountKey,
|
||||
"realm": realm,
|
||||
"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
|
||||
|
|
|
@ -388,7 +388,11 @@ func (suite *DriverSuite) TestReaderWithOffset(c *check.C) {
|
|||
// TestContinueStreamAppendLarge tests that a stream write can be appended to without
|
||||
// corrupting the data with a large chunk size.
|
||||
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
|
||||
|
@ -824,6 +828,15 @@ func (suite *DriverSuite) TestStatCall(c *check.C) {
|
|||
c.Assert(fi.Path(), check.Equals, dirPath)
|
||||
c.Assert(fi.Size(), check.Equals, int64(0))
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue