Skip to content

Commit

Permalink
Flaky blobs caps systemtest (#77)
Browse files Browse the repository at this point in the history
* Flaky blobs caps systemtest

AB#5311
  • Loading branch information
eccles authored Aug 14, 2024
1 parent 5892023 commit f281e36
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
27 changes: 16 additions & 11 deletions azblob/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@ import (

azStorageBlob "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"

"github.com/datatrails/go-datatrails-common/logger"
"github.com/datatrails/go-datatrails-common/tracing"
)

// Count counts the number of blobs filtered by the given tags filter
func (azp *Storer) Count(ctx context.Context, tagsFilter string, opts ...Option) (int64, error) {

logger.Sugar.Debugf("Count")

r, err := azp.FilteredList(ctx, tagsFilter, opts...)
if err != nil {
return 0, err
}

return int64(len(r.Items)), nil
var count int64
var m ListMarker

for {
r, err := azp.FilteredList(ctx, tagsFilter, append(opts, WithListMarker(m))...)
if err != nil {
return 0, err
}
count += int64(len(r.Items))
if r.Marker == nil || *r.Marker == "" {
break
}
m = r.Marker
}
return count, nil
}

type FilterResponse struct {
Expand Down Expand Up @@ -92,12 +98,11 @@ func (azp *Storer) FilteredList(ctx context.Context, tagsFilter string, opts ...
Items: resp.Blobs,
}

r.Marker = resp.NextMarker
if r.Marker != nil {
span.SetTag("nextmarker", *r.Marker)
}

return r, err
return r, nil
}

type ListerResponse struct {
Expand Down
11 changes: 11 additions & 0 deletions azblob/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package azblob

import (
"github.com/datatrails/go-datatrails-common/logger"
)

const (
DebugLevel = logger.DebugLevel
)

type Logger = logger.Logger
2 changes: 2 additions & 0 deletions azblob/storer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type Storer struct {
containerURL string
containerClient *ContainerClient
serviceClient *ServiceClient

log Logger
}

// New returns new az blob read/write object
Expand Down

0 comments on commit f281e36

Please sign in to comment.