func (p BlobstoreProvider) Get(provider string, options map[string]interface{}) (boshblob.Blobstore, error) { configDir, err := p.fs.TempDir("blobstore-s3-config") if err != nil { return nil, bosherr.WrapError(err, "Cerating tmp dir for blobstore config") } configPath := filepath.Join(configDir, "config.json") blobstore := boshblob.NewExternalBlobstore( provider, options, p.fs, p.runner, p.uuidGen, configPath, ) blobstore = boshblob.NewSHA1VerifiableBlobstore(blobstore) blobstore = boshblob.NewRetryableBlobstore(blobstore, 3, p.logger) err = blobstore.Validate() if err != nil { return nil, bosherr.WrapError(err, "Validating blobstore") } return blobstore, nil }
fakeblob "github.com/cloudfoundry/bosh-agent/blobstore/fakes" bosherr "github.com/cloudfoundry/bosh-agent/errors" boshlog "github.com/cloudfoundry/bosh-agent/logger" ) var _ = Describe("retryableBlobstore", func() { var ( innerBlobstore *fakeblob.FakeBlobstore logger boshlog.Logger retryableBlobstore boshblob.Blobstore ) BeforeEach(func() { innerBlobstore = &fakeblob.FakeBlobstore{} logger = boshlog.NewLogger(boshlog.LevelNone) retryableBlobstore = boshblob.NewRetryableBlobstore(innerBlobstore, 3, logger) }) Describe("Get", func() { Context("when inner blobstore succeeds before maximum number of get tries (first time)", func() { It("returns path without an error", func() { innerBlobstore.GetFileName = "fake-path" path, err := retryableBlobstore.Get("fake-blob-id", "fake-fingerprint") Expect(err).ToNot(HaveOccurred()) Expect(path).To(Equal("fake-path")) Expect(innerBlobstore.GetBlobIDs).To(Equal([]string{"fake-blob-id"})) Expect(innerBlobstore.GetFingerprints).To(Equal([]string{"fake-fingerprint"})) }) })