Skip to content

Commit

Permalink
Revert "Vendor update bosh-utils to not load entire blobstore into me…
Browse files Browse the repository at this point in the history
…mory"

This reverts commit 8af529d.
  • Loading branch information
lwoydziak committed Sep 22, 2015
1 parent 6332b68 commit 688739b
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package blobstore

import (
"os"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system"
"path/filepath"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)

type BlobManager struct {
Expand All @@ -19,10 +17,10 @@ func NewBlobManager(fs boshsys.FileSystem, blobstorePath string) (manager BlobMa
return
}

func (manager BlobManager) Fetch(blobID string) (readOnlyFile boshsys.File, err error) {
func (manager BlobManager) Fetch(blobID string) (blobBytes []byte, err error) {
blobPath := filepath.Join(manager.blobstorePath, blobID)

readOnlyFile, err = manager.fs.OpenFile(blobPath, os.O_RDONLY, os.ModeDir)
blobBytes, err = manager.fs.ReadFile(blobPath)
if err != nil {
err = bosherr.WrapError(err, "Reading blob")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,38 @@
package blobstore_test

import (
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

. "github.com/cloudfoundry/bosh-utils/blobstore"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore"
fakesys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes"
)

func createBlobManager() (blobManager BlobManager, fs boshsys.FileSystem) {
logger := boshlog.NewLogger(boshlog.LevelNone)
fs = boshsys.NewOsFileSystem(logger)
blobManager = NewBlobManager(fs, "/tmp")
return
}

func readFile(fileIO boshsys.File) (fileBytes []byte) {
fileStat, _ := fileIO.Stat()
fileBytes = make([]byte, fileStat.Size())
fileIO.Read(fileBytes)
func createBlobManager() (blobManager BlobManager, fs *fakesys.FakeFileSystem) {
fs = fakesys.NewFakeFileSystem()
blobManager = NewBlobManager(fs, "/var/vcap/micro_bosh/data/cache")
return
}

var _ = Describe("Testing with Ginkgo", func() {
It("fetch", func() {
blobManager, fs := createBlobManager()
fs.WriteFileString("/tmp/105d33ae-655c-493d-bf9f-1df5cf3ca847", "some data")

readOnlyFile, err := blobManager.Fetch("105d33ae-655c-493d-bf9f-1df5cf3ca847")
defer fs.RemoveAll(readOnlyFile.Name())
fs.WriteFileString("/var/vcap/micro_bosh/data/cache/105d33ae-655c-493d-bf9f-1df5cf3ca847", "some data")

blobBytes, err := blobManager.Fetch("105d33ae-655c-493d-bf9f-1df5cf3ca847")
Expect(err).ToNot(HaveOccurred())
fileBytes := readFile(readOnlyFile)

Expect(string(fileBytes)).To(Equal("some data"))
Expect(string(blobBytes)).To(Equal("some data"))
})

It("write", func() {

blobManager, fs := createBlobManager()
fs.WriteFileString("/tmp/105d33ae-655c-493d-bf9f-1df5cf3ca847", "some data")
defer fs.RemoveAll("/tmp/105d33ae-655c-493d-bf9f-1df5cf3ca847")
fs.WriteFileString("/var/vcap/micro_bosh/data/cache/105d33ae-655c-493d-bf9f-1df5cf3ca847", "some data")

err := blobManager.Write("105d33ae-655c-493d-bf9f-1df5cf3ca847", []byte("new data"))
Expect(err).ToNot(HaveOccurred())

contents, err := fs.ReadFileString("/tmp/105d33ae-655c-493d-bf9f-1df5cf3ca847")
contents, err := fs.ReadFileString("/var/vcap/micro_bosh/data/cache/105d33ae-655c-493d-bf9f-1df5cf3ca847")
Expect(err).ToNot(HaveOccurred())
Expect(contents).To(Equal("new data"))
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package blobstore_test

import (
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

"testing"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"path/filepath"

"errors"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-utils/system"
boshuuid "github.com/cloudfoundry/bosh-utils/uuid"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system"
boshuuid "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/uuid"
)

type externalBlobstore struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"path/filepath"
"strings"

. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

boshassert "github.com/cloudfoundry/bosh-utils/assert"
. "github.com/cloudfoundry/bosh-utils/blobstore"
fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"
fakeuuid "github.com/cloudfoundry/bosh-utils/uuid/fakes"
boshassert "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/assert"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore"
fakesys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes"
fakeuuid "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/uuid/fakes"
)

var _ = Describe("externalBlobstore", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"os"
"path/filepath"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-utils/system"
boshuuid "github.com/cloudfoundry/bosh-utils/uuid"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system"
boshuuid "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/uuid"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"errors"
"os"

. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

. "github.com/cloudfoundry/bosh-utils/blobstore"
fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"
fakeuuid "github.com/cloudfoundry/bosh-utils/uuid/fakes"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore"
fakesys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes"
fakeuuid "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/uuid/fakes"
)

var _ = Describe("localBlobstore", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"path/filepath"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
"github.com/cloudfoundry/bosh-utils/system"
boshuuid "github.com/cloudfoundry/bosh-utils/uuid"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/logger"
"github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system"
boshuuid "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/uuid"
)

const (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package blobstore_test

import (
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

. "github.com/cloudfoundry/bosh-utils/blobstore"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"
boshuuid "github.com/cloudfoundry/bosh-utils/uuid"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore"
boshlog "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/logger"
fakesys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes"
boshuuid "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/uuid"
)

var _ = Describe("Provider", func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package blobstore

import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/logger"
)

type retryableBlobstore struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package blobstore_test
import (
"errors"

. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

boshblob "github.com/cloudfoundry/bosh-utils/blobstore"
fakeblob "github.com/cloudfoundry/bosh-utils/blobstore/fakes"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshblob "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore"
fakeblob "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore/fakes"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/logger"
)

var _ = Describe("retryableBlobstore", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"os"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
)

type sha1VerifiableBlobstore struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package blobstore_test
import (
"errors"

. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

boshblob "github.com/cloudfoundry/bosh-utils/blobstore"
fakeblob "github.com/cloudfoundry/bosh-utils/blobstore/fakes"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshblob "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore"
fakeblob "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore/fakes"
bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors"
)

var _ = Describe("sha1VerifiableBlobstore", func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package logger_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"

"testing"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package logger_test
import (
"fmt"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-utils/internal/github.com/onsi/gomega"

"bytes"
. "github.com/cloudfoundry/bosh-utils/logger"
Expand Down
6 changes: 3 additions & 3 deletions internal/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
{
"canonical": "github.com/cloudfoundry/bosh-utils/blobstore",
"comment": "",
"local": "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/blobstore",
"revision": "6afd602ab4188f5aff4a8330c222efc7620631f3",
"revisionTime": "2015-09-14T15:11:55-07:00"
"local": "github.com/cloudfoundry/bosh-utils/blobstore",
"revision": "f2e1cd2009f456fe7f1a6ef06335584cc3d0d9b6",
"revisionTime": "2015-08-03T17:23:41-07:00"
},
{
"canonical": "github.com/cloudfoundry/bosh-utils/blobstore/fakes",
Expand Down

0 comments on commit 688739b

Please sign in to comment.