本文整理匯總了Golang中github.com/juju/juju/environs/imagemetadata/testing.PatchOfficialDataSources函數的典型用法代碼示例。如果您正苦於以下問題:Golang PatchOfficialDataSources函數的具體用法?Golang PatchOfficialDataSources怎麽用?Golang PatchOfficialDataSources使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了PatchOfficialDataSources函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetUpSuite
func (s *ebsVolumeSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
s.Tests.SetUpSuite(c)
s.Credential = cloud.NewCredential(
cloud.AccessKeyAuthType,
map[string]string{
"access-key": "x",
"secret-key": "x",
},
)
s.CloudRegion = "test"
// Upload arches that ec2 supports; add to this
// as ec2 coverage expands.
s.UploadArches = []string{arch.AMD64, arch.I386}
s.TestConfig = localConfigAttrs.Merge(testing.Attrs{
"access-key": "x",
"secret-key": "x",
"region": "test",
})
s.restoreEC2Patching = patchEC2ForTesting(c)
s.BaseSuite.PatchValue(&imagemetadata.SimplestreamsImagesPublicKey, sstesting.SignedMetadataPublicKey)
s.BaseSuite.PatchValue(&juju.JujuPublicKey, sstesting.SignedMetadataPublicKey)
imagetesting.PatchOfficialDataSources(&s.BaseSuite.CleanupSuite, "test:")
s.BaseSuite.PatchValue(ec2.DeleteSecurityGroupInsistently, deleteSecurityGroupForTestFunc)
}
示例2: SetUpSuite
func (t *localServerSuite) SetUpSuite(c *gc.C) {
t.BaseSuite.SetUpSuite(c)
t.Credential = cloud.NewCredential(
cloud.AccessKeyAuthType,
map[string]string{
"access-key": "x",
"secret-key": "x",
},
)
t.CloudRegion = "test"
// Upload arches that ec2 supports; add to this
// as ec2 coverage expands.
t.UploadArches = []string{arch.AMD64, arch.I386}
t.TestConfig = localConfigAttrs
t.restoreEC2Patching = patchEC2ForTesting(c)
imagetesting.PatchOfficialDataSources(&t.BaseSuite.CleanupSuite, "test:")
t.BaseSuite.PatchValue(&imagemetadata.SimplestreamsImagesPublicKey, sstesting.SignedMetadataPublicKey)
t.BaseSuite.PatchValue(&juju.JujuPublicKey, sstesting.SignedMetadataPublicKey)
t.BaseSuite.PatchValue(&jujuversion.Current, coretesting.FakeVersionNumber)
t.BaseSuite.PatchValue(&arch.HostArch, func() string { return arch.AMD64 })
t.BaseSuite.PatchValue(&series.HostSeries, func() string { return coretesting.FakeDefaultSeries })
t.BaseSuite.PatchValue(ec2.DeleteSecurityGroupInsistently, deleteSecurityGroupForTestFunc)
t.srv.createRootDisks = true
t.srv.startServer(c)
// TODO(jam) I don't understand why we shouldn't do this.
// t.Tests embeds the sstesting.TestDataSuite, but if we call this
// SetUpSuite, then all of the tests fail because they go to access
// "test:/streams/..." and it isn't found
// t.Tests.SetUpSuite(c)
}
示例3: SetUpSuite
func (s *ImageMetadataSuite) SetUpSuite(c *gc.C) {
s.provisionerSuite.SetUpSuite(c)
// Make sure that there is nothing in data sources.
// Each individual tests will decide if it needs metadata there.
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test:/daily")
s.PatchValue(&imagemetadata.SimplestreamsImagesPublicKey, sstesting.SignedMetadataPublicKey)
useTestImageData(c, nil)
}
示例4: SetUpTest
func (s *localLiveSuite) SetUpTest(c *gc.C) {
s.PatchValue(&version.Current, coretesting.FakeVersionNumber)
s.providerSuite.SetUpTest(c)
creds := joyent.MakeCredentials(c, s.TestConfig)
joyent.UseExternalTestImageMetadata(c, creds)
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test://host")
restoreFinishBootstrap := envtesting.DisableFinishBootstrap()
s.AddCleanup(func(*gc.C) { restoreFinishBootstrap() })
s.LiveTests.SetUpTest(c)
}
示例5: SetUpSuite
func (t *localLiveSuite) SetUpSuite(c *gc.C) {
t.LiveTests.SetUpSuite(c)
// Upload arches that ec2 supports; add to this
// as ec2 coverage expands.
t.UploadArches = []string{arch.AMD64, arch.I386}
t.TestConfig = localConfigAttrs
t.restoreEC2Patching = patchEC2ForTesting(c)
imagetesting.PatchOfficialDataSources(&t.BaseSuite.CleanupSuite, "test:")
t.srv.createRootDisks = true
t.srv.startServer(c)
}
示例6: PrepareStartInstanceFakes
func (s *environBrokerSuite) PrepareStartInstanceFakes(c *gc.C) {
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "")
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
s.FakeInstances(client)
s.FakeAvailabilityZones(client, "z1")
s.FakeAvailabilityZones(client, "z1")
s.FakeAvailabilityZones(client, "z1")
s.FakeCreateInstance(client, s.ServerUrl, c)
}
示例7: SetUpSuite
func (s *specSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
s.TestDataSuite.SetUpSuite(c)
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test:")
s.PatchValue(&imagemetadata.SimplestreamsImagesPublicKey, sstesting.SignedMetadataPublicKey)
s.PatchValue(&simplestreams.SimplestreamsJujuPublicKey, sstesting.SignedMetadataPublicKey)
UseTestImageData(c, TestImagesData)
UseTestInstanceTypeData(TestInstanceTypeCosts)
UseTestRegionData(TestRegions)
}
示例8: SetUpTest
func (s *AgentSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
// Set API host ports so FindTools/Tools API calls succeed.
hostPorts := [][]network.HostPort{
network.NewHostPorts(1234, "0.1.2.3"),
}
err := s.State.SetAPIHostPorts(hostPorts)
c.Assert(err, jc.ErrorIsNil)
s.PatchValue(&proxyupdater.NewWorker, func(*apiproxyupdater.Facade) (worker.Worker, error) {
return newDummyWorker(), nil
})
// Tests should not try to use internet. Ensure base url is empty.
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "")
}
示例9: setupMetadata
func (s *archSuite) setupMetadata(c *gc.C, arches []string) (environs.Environ, simplestreams.CloudSpec) {
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "")
env := &mockEnviron{
config: configGetter(c),
}
var images []*imagemetadata.ImageMetadata
for _, arch := range arches {
images = append(images, &imagemetadata.ImageMetadata{
Id: "image-id",
Arch: arch,
RegionName: "Region",
Endpoint: "https://endpoint/",
})
}
// Append an image from another region with some other arch to ensure it is ignored.
images = append(images, &imagemetadata.ImageMetadata{
Id: "image-id",
Arch: "arch",
RegionName: "Region-Two",
Endpoint: "https://endpoint/",
})
cloudSpec := simplestreams.CloudSpec{
Region: "Region",
Endpoint: "https://endpoint/",
}
metadataDir := c.MkDir()
stor, err := filestorage.NewFileStorageWriter(metadataDir)
c.Assert(err, jc.ErrorIsNil)
err = imagemetadata.MergeAndWriteMetadata("precise", images, &cloudSpec, stor)
c.Assert(err, jc.ErrorIsNil)
id := "SupportedArchitectures"
environs.RegisterImageDataSourceFunc(id, func(environs.Environ) (simplestreams.DataSource, error) {
return simplestreams.NewURLDataSource(id, "file://"+metadataDir+"/images", false, simplestreams.DEFAULT_CLOUD_DATA, false), nil
})
s.AddCleanup(func(*gc.C) {
environs.UnregisterImageDataSourceFunc(id)
})
return env, cloudSpec
}
示例10: SetUpTest
func (s *localServerSuite) SetUpTest(c *gc.C) {
s.providerSuite.SetUpTest(c)
s.PatchValue(&jujuversion.Current, coretesting.FakeVersionNumber)
s.cSrv.setupServer(c)
s.AddCleanup(s.cSrv.destroyServer)
s.Tests.ToolsFixture.UploadArches = []string{arch.AMD64}
s.Tests.SetUpTest(c)
s.TestConfig = GetFakeConfig(s.cSrv.Server.URL)
credentialsAttrs := joyent.CredentialsAttributes(s.TestConfig)
s.Credential = cloud.NewCredential(
cloud.UserPassAuthType,
credentialsAttrs,
)
// Put some fake image metadata in place.
creds := joyent.MakeCredentials(c, s.TestConfig)
joyent.UseExternalTestImageMetadata(c, creds)
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test://host")
}
示例11: SetUpTest
func (s *localServerSuite) SetUpTest(c *gc.C) {
s.baseSuite.SetUpTest(c)
s.PatchValue(&jujuversion.Current, coretesting.FakeVersionNumber)
s.cSrv.setupServer(c)
s.AddCleanup(s.cSrv.destroyServer)
s.PatchValue(&arch.HostArch, func() string { return arch.AMD64 })
s.Tests.SetUpTest(c)
s.Credential = cloud.NewCredential(cloud.UserPassAuthType, map[string]string{
"sdc-user": testUser,
"sdc-key-id": testKeyFingerprint,
"private-key": testPrivateKey,
"algorithm": "rsa-sha256",
})
s.CloudEndpoint = s.cSrv.Server.URL
s.CloudRegion = "some-region"
s.TestConfig = GetFakeConfig()
// Put some fake image metadata in place.
creds := joyent.MakeCredentials(c, s.CloudEndpoint, s.Credential)
joyent.UseExternalTestImageMetadata(c, creds)
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test://host")
}
示例12: SetUpSuite
func (s *imageMetadataUpdateSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test:")
useTestImageData(c, testImagesData)
}
示例13: SetUpTest
func (s *CommonProvisionerSuite) SetUpTest(c *gc.C) {
// Disable the default state policy, because the
// provisioner needs to be able to test pathological
// scenarios where a machine exists in state with
// invalid environment config.
dummy.SetStatePolicy(nil)
s.JujuConnSuite.SetUpTest(c)
// We do not want to pull published image metadata for tests...
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "")
// We want an image to start test instances
err := s.State.CloudImageMetadataStorage.SaveMetadata([]cloudimagemetadata.Metadata{{
cloudimagemetadata.MetadataAttributes{
Region: "region",
Series: "trusty",
Arch: "amd64",
VirtType: "",
RootStorageType: "",
Source: "test",
},
10,
"-999",
}})
c.Assert(err, jc.ErrorIsNil)
// Create the operations channel with more than enough space
// for those tests that don't listen on it.
op := make(chan dummy.Operation, 500)
dummy.Listen(op)
s.op = op
cfg, err := s.State.EnvironConfig()
c.Assert(err, jc.ErrorIsNil)
s.cfg = cfg
// Create a machine for the dummy bootstrap instance,
// so the provisioner doesn't destroy it.
insts, err := s.Environ.Instances([]instance.Id{dummy.BootstrapInstanceId})
c.Assert(err, jc.ErrorIsNil)
addrs, err := insts[0].Addresses()
c.Assert(err, jc.ErrorIsNil)
machine, err := s.State.AddOneMachine(state.MachineTemplate{
Addresses: addrs,
Series: "quantal",
Nonce: agent.BootstrapNonce,
InstanceId: dummy.BootstrapInstanceId,
Jobs: []state.MachineJob{state.JobManageEnviron},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(machine.Id(), gc.Equals, "0")
current := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
err = machine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
password, err := utils.RandomPassword()
c.Assert(err, jc.ErrorIsNil)
err = machine.SetPassword(password)
c.Assert(err, jc.ErrorIsNil)
s.st = s.OpenAPIAsMachine(c, machine.Tag(), password, agent.BootstrapNonce)
c.Assert(s.st, gc.NotNil)
c.Logf("API: login as %q successful", machine.Tag())
s.provisioner = s.st.Provisioner()
c.Assert(s.provisioner, gc.NotNil)
}
示例14: SetUpSuite
func (s *baseImageMetadataSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "test:")
}