func (s *URLsSuite) TestToolsMetadataURLsRegisteredFuncs(c *gc.C) { tools.RegisterToolsDataSourceFunc("id0", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id0", "betwixt/releases", utils.NoVerifySSLHostnames), nil }) tools.RegisterToolsDataSourceFunc("id1", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id1", "yoink", utils.NoVerifySSLHostnames), nil }) // overwrite the one previously registered against id1 tools.RegisterToolsDataSourceFunc("id1", func(environs.Environ) (simplestreams.DataSource, error) { // NotSupported errors do not cause GetMetadataSources to fail, // they just cause the datasource function to be ignored. return nil, errors.NewNotSupported(nil, "oyvey") }) defer tools.UnregisterToolsDataSourceFunc("id0") defer tools.UnregisterToolsDataSourceFunc("id1") env := s.env(c, "config-tools-metadata-url") sources, err := tools.GetMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []string{ "config-tools-metadata-url/", "betwixt/releases/", "https://streams.canonical.com/juju/tools/", }) }
func (s *ImageMetadataSuite) TestImageMetadataURLsRegisteredFuncs(c *gc.C) { environs.RegisterImageDataSourceFunc("id0", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id0", "betwixt/releases", utils.NoVerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, false), nil }) environs.RegisterImageDataSourceFunc("id1", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id1", "yoink", utils.NoVerifySSLHostnames, simplestreams.SPECIFIC_CLOUD_DATA, false), nil }) // overwrite the one previously registered against id1 environs.RegisterImageDataSourceFunc("id1", func(environs.Environ) (simplestreams.DataSource, error) { return nil, errors.NewNotSupported(nil, "oyvey") }) environs.RegisterUserImageDataSourceFunc("id2", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id2", "foobar", utils.NoVerifySSLHostnames, simplestreams.CUSTOM_CLOUD_DATA, false), nil }) defer environs.UnregisterImageDataSourceFunc("id0") defer environs.UnregisterImageDataSourceFunc("id1") defer environs.UnregisterImageDataSourceFunc("id2") env := s.env(c, "config-image-metadata-url", "") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []sstesting.SourceDetails{ {"config-image-metadata-url/", ""}, {"foobar/", ""}, {"betwixt/releases/", ""}, {"https://streams.canonical.com/juju/images/releases/", imagemetadata.SimplestreamsImagesPublicKey}, {"http://cloud-images.ubuntu.com/releases/", imagemetadata.SimplestreamsImagesPublicKey}, }) }
func (s *URLsSuite) TestToolsSources(c *gc.C) { env := s.env(c, "config-tools-metadata-url") sources, err := tools.GetMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []string{ "config-tools-metadata-url/", "https://streams.canonical.com/juju/tools/"}) }
func (s *ImageMetadataSuite) TestImageMetadataURLsRegisteredFuncs(c *gc.C) { environs.RegisterImageDataSourceFunc("id0", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id0", "betwixt/releases", utils.NoVerifySSLHostnames), nil }) environs.RegisterImageDataSourceFunc("id1", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id1", "yoink", utils.NoVerifySSLHostnames), nil }) // overwrite the one previously registered against id1 environs.RegisterImageDataSourceFunc("id1", func(environs.Environ) (simplestreams.DataSource, error) { return nil, errors.NewNotSupported(nil, "oyvey") }) environs.RegisterUserImageDataSourceFunc("id2", func(environs.Environ) (simplestreams.DataSource, error) { return simplestreams.NewURLDataSource("id2", "foobar", utils.NoVerifySSLHostnames), nil }) defer environs.UnregisterImageDataSourceFunc("id0") defer environs.UnregisterImageDataSourceFunc("id1") defer environs.UnregisterImageDataSourceFunc("id2") env := s.env(c, "config-image-metadata-url", "") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []string{ "config-image-metadata-url/", "foobar/", "betwixt/releases/", "http://cloud-images.ubuntu.com/releases/", }) }
func (s *ImageMetadataSuite) TestImageMetadataURLs(c *gc.C) { env := s.env(c, "config-image-metadata-url", "") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []string{ "config-image-metadata-url/", "http://cloud-images.ubuntu.com/releases/", }) }
func (s *ImageMetadataSuite) TestImageMetadataURLsNonReleaseStream(c *gc.C) { env := s.env(c, "", "daily") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []string{ "http://cloud-images.ubuntu.com/daily/", }) }
func (s *ImageMetadataSuite) TestImageMetadataURLsNoConfigURL(c *gc.C) { env := s.env(c, "", "") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []string{ "https://streams.canonical.com/juju/images/releases/", "http://cloud-images.ubuntu.com/releases/", }) }
func (s *ImageMetadataSuite) TestImageMetadataURLsNonReleaseStream(c *gc.C) { env := s.env(c, "", "daily") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []sstesting.SourceDetails{ {"https://streams.canonical.com/juju/images/daily/", imagemetadata.SimplestreamsImagesPublicKey}, {"http://cloud-images.ubuntu.com/daily/", imagemetadata.SimplestreamsImagesPublicKey}, }) }
func (s *URLsSuite) TestImageMetadataURLsNonReleaseStream(c *gc.C) { env := s.env(c, "", "daily") sources, err := imagemetadata.GetMetadataSources(env) c.Assert(err, gc.IsNil) privateStorageURL, err := env.Storage().URL("images") c.Assert(err, gc.IsNil) sstesting.AssertExpectedSources(c, sources, []string{ privateStorageURL, "http://cloud-images.ubuntu.com/daily/"}) }
func (s *URLsSuite) TestImageMetadataURLs(c *gc.C) { env := s.env(c, "config-image-metadata-url", "") sources, err := imagemetadata.GetMetadataSources(env) c.Assert(err, gc.IsNil) privateStorageURL, err := env.Storage().URL("images") c.Assert(err, gc.IsNil) sstesting.AssertExpectedSources(c, sources, []string{ "config-image-metadata-url/", privateStorageURL, "http://cloud-images.ubuntu.com/releases/"}) }
func (s *ImageMetadataSuite) TestImageMetadataURLs(c *gc.C) { env := s.env(c, "config-image-metadata-url", "") sources, err := environs.ImageMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []sstesting.SourceDetails{ {"config-image-metadata-url/", ""}, {"https://streams.canonical.com/juju/images/releases/", keys.JujuPublicKey}, {"http://cloud-images.ubuntu.com/releases/", imagemetadata.SimplestreamsImagesPublicKey}, }) }
func (s *URLsSuite) TestToolsURLsNoConfigURL(c *gc.C) { env := s.env(c, "") sources, err := tools.GetMetadataSources(env) c.Assert(err, gc.IsNil) // Put a file in tools since the dummy storage provider requires a // file to exist before the URL can be found. This is to ensure it behaves // the same way as MAAS. err = env.Storage().Put("tools/dummy", strings.NewReader("dummy"), 5) c.Assert(err, gc.IsNil) privateStorageURL, err := env.Storage().URL("tools") c.Assert(err, gc.IsNil) sstesting.AssertExpectedSources(c, sources, []string{ privateStorageURL, "https://streams.canonical.com/juju/tools/"}) }
func (s *URLsSuite) TestToolsSources(c *gc.C) { env := s.env(c, "config-tools-metadata-url") sources, err := tools.GetMetadataSources(env) c.Assert(err, gc.IsNil) // Put a file in tools since the dummy storage provider requires a // file to exist before the URL can be found. This is to ensure it behaves // the same way as MAAS. err = env.Storage().Put("tools/dummy", strings.NewReader("dummy"), 5) c.Assert(err, gc.IsNil) privateStorageURL, err := env.Storage().URL("tools") c.Assert(err, gc.IsNil) sstesting.AssertExpectedSources(c, sources, []string{ "config-tools-metadata-url/", privateStorageURL, "https://streams.canonical.com/juju/tools/"}) haveExpectedSources := false for _, source := range sources { if allowRetry, ok := storage.TestingGetAllowRetry(source); ok { haveExpectedSources = true c.Assert(allowRetry, jc.IsFalse) } } c.Assert(haveExpectedSources, jc.IsTrue) }
func (s *URLsSuite) TestToolsURLsNoConfigURL(c *gc.C) { env := s.env(c, "") sources, err := tools.GetMetadataSources(env) c.Assert(err, jc.ErrorIsNil) sstesting.AssertExpectedSources(c, sources, []sstesting.SourceDetails{{"https://streams.canonical.com/juju/tools/", keys.JujuPublicKey}}) }