本文整理匯總了Golang中acceptance-tests/testing/destiny.Manifest.ConsulMembers方法的典型用法代碼示例。如果您正苦於以下問題:Golang Manifest.ConsulMembers方法的具體用法?Golang Manifest.ConsulMembers怎麽用?Golang Manifest.ConsulMembers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類acceptance-tests/testing/destiny.Manifest
的用法示例。
在下文中一共展示了Manifest.ConsulMembers方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewKV
func NewKV(manifest destiny.Manifest, count int) (kv consul.KV, err error) {
members := manifest.ConsulMembers()
if len(members) != count {
err = fmt.Errorf("expected %d consul members, found %d", count, len(members))
return
}
consulMemberAddresses := []string{}
for _, member := range members {
consulMemberAddresses = append(consulMemberAddresses, member.Address)
}
dataDir, err := ioutil.TempDir("", "consul")
if err != nil {
return
}
configDir, err := ioutil.TempDir("", "consul-config")
if err != nil {
return
}
var encryptKey string
if len(manifest.Properties.Consul.EncryptKeys) > 0 {
key := manifest.Properties.Consul.EncryptKeys[0]
encryptKey = base64.StdEncoding.EncodeToString(pbkdf2.Key([]byte(key), []byte(""), 20000, 16, sha1.New))
}
agent := consul.NewAgent(consul.AgentOptions{
DataDir: dataDir,
RetryJoin: consulMemberAddresses,
ConfigDir: configDir,
Domain: "cf.internal",
Key: manifest.Properties.Consul.AgentKey,
Cert: manifest.Properties.Consul.AgentCert,
CACert: manifest.Properties.Consul.CACert,
Encrypt: encryptKey,
ServerName: "consul agent",
})
agentLocation := "http://127.0.0.1:8500"
kv = consul.NewManagedKV(consul.ManagedKVConfig{
Agent: agent,
KV: consul.NewHTTPKV(agentLocation),
Catalog: consul.NewHTTPCatalog(agentLocation),
})
return
}
示例2:
{"running"},
{"running"},
{"running"},
}))
})
It("provides a functioning server after the scale down", func() {
By("setting a persistent value to check the cluster is up", func() {
err := kv.Set(testKey, testValue)
Expect(err).NotTo(HaveOccurred())
})
By("scaling from 3 nodes to 1", func() {
manifest.Jobs[0], manifest.Properties = destiny.SetJobInstanceCount(manifest.Jobs[0], manifest.Networks[0], manifest.Properties, 1)
members := manifest.ConsulMembers()
Expect(members).To(HaveLen(1))
yaml, err := manifest.ToYAML()
Expect(err).NotTo(HaveOccurred())
err = client.Deploy(yaml)
Expect(err).NotTo(HaveOccurred())
Eventually(func() ([]bosh.VM, error) {
return client.DeploymentVMs(manifest.Name)
}, "1m", "10s").Should(ConsistOf([]bosh.VM{
{"running"},
}))
})