func (s *localLiveSuite) SetUpSuite(c *gc.C) { s.BaseSuite.SetUpSuite(c) c.Logf("Running live tests using openstack service test double") s.srv.start(c, s.cred) s.LiveTests.SetUpSuite(c) openstack.UseTestImageData(openstack.ImageMetadataStorage(s.Env), s.cred) restoreFinishBootstrap := envtesting.DisableFinishBootstrap() s.AddSuiteCleanup(func(*gc.C) { restoreFinishBootstrap() }) }
func (s *localServerSuite) SetUpTest(c *gc.C) { s.BaseSuite.SetUpTest(c) s.srv.start(c, s.cred) cl := client.NewClient(s.cred, identity.AuthUserPass, nil) err := cl.Authenticate() c.Assert(err, gc.IsNil) containerURL, err := cl.MakeServiceURL("object-store", nil) c.Assert(err, gc.IsNil) s.TestConfig = s.TestConfig.Merge(coretesting.Attrs{ "tools-metadata-url": containerURL + "/juju-dist-test/tools", "image-metadata-url": containerURL + "/juju-dist-test", "auth-url": s.cred.URL, }) s.Tests.SetUpTest(c) // For testing, we create a storage instance to which is uploaded tools and image metadata. env := s.Prepare(c) s.toolsMetadataStorage = openstack.MetadataStorage(env) // Put some fake metadata in place so that tests that are simply // starting instances without any need to check if those instances // are running can find the metadata. envtesting.UploadFakeTools(c, s.toolsMetadataStorage) s.imageMetadataStorage = openstack.ImageMetadataStorage(env) openstack.UseTestImageData(s.imageMetadataStorage, s.cred) }
func (s *localHTTPSServerSuite) TestFetchFromImageMetadataSources(c *gc.C) { // Setup a custom URL for image metadata customStorage := openstack.CreateCustomStorage(s.env, "custom-metadata") customURL, err := customStorage.URL("") c.Assert(err, gc.IsNil) c.Check(customURL[:8], gc.Equals, "https://") config, err := s.env.Config().Apply( map[string]interface{}{"image-metadata-url": customURL}, ) c.Assert(err, gc.IsNil) err = s.env.SetConfig(config) c.Assert(err, gc.IsNil) sources, err := imagemetadata.GetMetadataSources(s.env) c.Assert(err, gc.IsNil) c.Assert(sources, gc.HasLen, 4) // Make sure there is something to download from each location private := "private-content" err = s.env.Storage().Put("images/"+private, bytes.NewBufferString(private), int64(len(private))) c.Assert(err, gc.IsNil) metadata := "metadata-content" metadataStorage := openstack.ImageMetadataStorage(s.env) err = metadataStorage.Put(metadata, bytes.NewBufferString(metadata), int64(len(metadata))) c.Assert(err, gc.IsNil) custom := "custom-content" err = customStorage.Put(custom, bytes.NewBufferString(custom), int64(len(custom))) c.Assert(err, gc.IsNil) // Read from the Config entry's image-metadata-url contentReader, url, err := sources[0].Fetch(custom) c.Assert(err, gc.IsNil) defer contentReader.Close() content, err := ioutil.ReadAll(contentReader) c.Assert(err, gc.IsNil) c.Assert(string(content), gc.Equals, custom) c.Check(url[:8], gc.Equals, "https://") // Read from the private bucket contentReader, url, err = sources[1].Fetch(private) c.Assert(err, gc.IsNil) defer contentReader.Close() content, err = ioutil.ReadAll(contentReader) c.Assert(err, gc.IsNil) c.Check(string(content), gc.Equals, private) c.Check(url[:8], gc.Equals, "https://") // Check the entry we got from keystone contentReader, url, err = sources[2].Fetch(metadata) c.Assert(err, gc.IsNil) defer contentReader.Close() content, err = ioutil.ReadAll(contentReader) c.Assert(err, gc.IsNil) c.Assert(string(content), gc.Equals, metadata) c.Check(url[:8], gc.Equals, "https://") // Verify that we are pointing at exactly where metadataStorage thinks we are metaURL, err := metadataStorage.URL(metadata) c.Assert(err, gc.IsNil) c.Check(url, gc.Equals, metaURL) }
func (s *localLiveSuite) TearDownSuite(c *gc.C) { openstack.RemoveTestImageData(openstack.ImageMetadataStorage(s.Env)) s.LiveTests.TearDownSuite(c) s.srv.stop() s.BaseSuite.TearDownSuite(c) }