本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.ReplicationController.ID方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReplicationController.ID方法的具體用法?Golang ReplicationController.ID怎麽用?Golang ReplicationController.ID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/GoogleCloudPlatform/kubernetes/pkg/api.ReplicationController
的用法示例。
在下文中一共展示了ReplicationController.ID方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestWatchControllers
func TestWatchControllers(t *testing.T) {
client := FakeWatcher{watch.NewFake(), &client.Fake{}}
manager := NewReplicationManager(client)
var testControllerSpec api.ReplicationController
received := make(chan struct{})
manager.syncHandler = func(controllerSpec api.ReplicationController) error {
if !reflect.DeepEqual(controllerSpec, testControllerSpec) {
t.Errorf("Expected %#v, but got %#v", testControllerSpec, controllerSpec)
}
close(received)
return nil
}
resourceVersion := uint64(0)
go manager.watchControllers(&resourceVersion)
// Test normal case
testControllerSpec.ID = "foo"
client.w.Add(&testControllerSpec)
select {
case <-received:
case <-time.After(10 * time.Millisecond):
t.Errorf("Expected 1 call but got 0")
}
}
示例2: TestWatchControllers
func TestWatchControllers(t *testing.T) {
defer beginTimeout(20 * time.Second).done()
fakeEtcd := tools.MakeFakeEtcdClient(t)
manager := MakeReplicationManager(fakeEtcd, nil)
var testControllerSpec api.ReplicationController
received := make(chan bool)
manager.syncHandler = func(controllerSpec api.ReplicationController) error {
if !reflect.DeepEqual(controllerSpec, testControllerSpec) {
t.Errorf("Expected %#v, but got %#v", testControllerSpec, controllerSpec)
}
close(received)
return nil
}
go manager.watchControllers()
fakeEtcd.WaitForWatchCompletion()
// Test normal case
testControllerSpec.ID = "foo"
fakeEtcd.WatchResponse <- &etcd.Response{
Action: "set",
Node: &etcd.Node{
Value: util.MakeJSONString(testControllerSpec),
},
}
select {
case <-received:
case <-time.After(10 * time.Millisecond):
t.Errorf("Expected 1 call but got 0")
}
// Test error case
fakeEtcd.WatchInjectError <- fmt.Errorf("Injected error")
// Did everything shut down?
if _, open := <-fakeEtcd.WatchResponse; open {
t.Errorf("An injected error did not cause a graceful shutdown")
}
// Test purposeful shutdown
go manager.watchControllers()
fakeEtcd.WaitForWatchCompletion()
fakeEtcd.WatchStop <- true
// Did everything shut down?
if _, open := <-fakeEtcd.WatchResponse; open {
t.Errorf("A stop did not cause a graceful shutdown")
}
}