本文整理汇总了Golang中github.com/tsuru/docker-cluster/cluster.Storage.UpdateNode方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.UpdateNode方法的具体用法?Golang Storage.UpdateNode怎么用?Golang Storage.UpdateNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/docker-cluster/cluster.Storage
的用法示例。
在下文中一共展示了Storage.UpdateNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testStorageLockNodeHealing
func testStorageLockNodeHealing(storage cluster.Storage, t *testing.T) {
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(100))
node := cluster.Node{Address: "addr-xyz"}
defer storage.RemoveNode("addr-xyz")
err := storage.StoreNode(node)
assertIsNil(err, t)
successCount := 0
wg := sync.WaitGroup{}
wg.Add(50)
for i := 0; i < 50; i++ {
go func() {
defer wg.Done()
locked, err := storage.LockNodeForHealing("addr-xyz", true, 5*time.Second)
assertIsNil(err, t)
if locked {
successCount++
}
}()
}
wg.Wait()
if successCount != 1 {
t.Fatalf("Expected success in only one goroutine, got: %d", successCount)
}
dbNode, err := storage.RetrieveNode("addr-xyz")
assertIsNil(err, t)
if dbNode.Healing.LockedUntil.IsZero() {
t.Fatal("Expected node Healing.LockedUntil not to be zero")
}
if !dbNode.Healing.IsFailure {
t.Fatal("Expected node healing.isFailure to be true")
}
dbNode.Healing = cluster.HealingData{}
err = storage.UpdateNode(dbNode)
assertIsNil(err, t)
dbNode, err = storage.RetrieveNode("addr-xyz")
assertIsNil(err, t)
if !dbNode.Healing.LockedUntil.IsZero() {
t.Fatal("Expected node Healing.LockedUntil to be zero")
}
if dbNode.Healing.IsFailure {
t.Fatal("Expected node Healing.IsFailure to be false")
}
}
示例2: testStorageStoreUpdateNode
func testStorageStoreUpdateNode(storage cluster.Storage, t *testing.T) {
node1 := cluster.Node{Address: "my-addr-1", Metadata: map[string]string{"abc": "def", "x": "y"}}
defer storage.RemoveNode("my-addr-1")
err := storage.StoreNode(node1)
assertIsNil(err, t)
delete(node1.Metadata, "x")
node1.Metadata["ahoy"] = "foo"
err = storage.UpdateNode(node1)
assertIsNil(err, t)
nd, err := storage.RetrieveNode("my-addr-1")
if !reflect.DeepEqual(nd, node1) {
t.Errorf("unexpected node, expected: %#v, got: %#v", node1, nd)
}
node1.Address = "my-addr-xxxxxx"
err = storage.UpdateNode(node1)
if err != cstorage.ErrNoSuchNode {
t.Errorf("Expected ErrNoSuchNode got: %#v", err)
}
}