Example #1
0
func (s *gridfsSuite) TestNamespaceSeparation(c *gc.C) {
	anotherStor := storage.NewGridFS("juju", "another", s.Session)
	path := "/path/to/file"
	assertPut(c, anotherStor, path, "hello world")
	_, err := s.stor.Get(path)
	c.Assert(err, gc.ErrorMatches, `failed to open GridFS file "/path/to/file": not found`)
}
Example #2
0
func (s *managedStorageSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	s.MgoSuite.SetUpTest(c)
	s.db = s.Session.DB("juju")
	s.txnRunner = statetxn.NewRunner(txn.NewRunner(s.db.C("txns")))
	s.resourceStorage = storage.NewGridFS("storage", "test", s.Session)
	s.managedStorage = storage.NewManagedStorage(s.db, s.txnRunner, s.resourceStorage)
}
Example #3
0
func (s *gridfsSuite) TestNamespaceSeparationRemove(c *gc.C) {
	anotherStor := storage.NewGridFS("juju", "another", s.Session)
	path := "/path/to/file"
	assertPut(c, s.stor, path, "hello world")
	assertPut(c, anotherStor, path, "hello again")
	err := s.stor.Remove(path)
	c.Assert(err, gc.IsNil)
	assertGet(c, anotherStor, "/path/to/file", "hello again")
}
Example #4
0
func (s *benchmarkSuite) BenchmarkManagedStorageCreate(c *gc.C) {
	db := s.Session.DB("a-database")
	txnRunner := jujuTxn.NewRunner(txn.NewRunner(db.C("txns")))
	rstore := storage.NewGridFS(db.Name, "prefix", s.Session)
	store := storage.NewManagedStorage(db, txnRunner, rstore)
	c.ResetTimer()
	const fileSize = 30 * 1024
	for i := 0; i < c.N; i++ {
		src := newDataSource(int64(i), fileSize)
		err := store.PutForEnvironment("env-uuid", fmt.Sprintf("file%d", i), src, fileSize)
		c.Assert(err, gc.IsNil)
	}
}
Example #5
0
func (s *gridfsSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	s.MgoSuite.SetUpTest(c)
	s.stor = storage.NewGridFS("juju", "test", s.Session)
}