StorageDriver: Test suite: improve cleanup

Verify that the file(s) have been deleted after calling Delete,
and retry if this is not the case. Furthermore, report the error
if a Delete operation fails.

Signed-off-by: Arthur Baars <arthur@semmle.com>
This commit is contained in:
Arthur Baars 2016-01-19 14:09:32 +00:00
parent e4b654f2ce
commit ffc9527782
3 changed files with 57 additions and 26 deletions

View file

@ -555,7 +555,16 @@ func (d *driver) Delete(context ctx.Context, path string) error {
if len(keys) > 0 {
sort.Sort(sort.Reverse(sort.StringSlice(keys)))
for _, key := range keys {
if err := storage.DeleteObject(gcsContext, d.bucket, key); err != nil {
err := storage.DeleteObject(gcsContext, d.bucket, key)
// GCS only guarantees eventual consistency, solistAll might return
// paths that no longer exist. If this happens, just ignore any not
// found error
if status, ok := err.(*googleapi.Error); ok {
if status.Code == http.StatusNotFound {
err = nil
}
}
if err != nil {
return err
}
}