當前位置: 首頁>>代碼示例>>Golang>>正文


Golang api.ReplicationController類代碼示例

本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.ReplicationController的典型用法代碼示例。如果您正苦於以下問題:Golang ReplicationController類的具體用法?Golang ReplicationController怎麽用?Golang ReplicationController使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ReplicationController類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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")
	}
}
開發者ID:asim,項目名稱:kubernetes,代碼行數:26,代碼來源:replication_controller_test.go

示例2: TestWatchControllers

func TestWatchControllers(t *testing.T) {
	fakeWatch := watch.NewFake()
	client := &client.Fake{Watch: fakeWatch}
	manager := NewReplicationManager(client)
	var testControllerSpec api.ReplicationController
	received := make(chan struct{})
	manager.syncHandler = func(controllerSpec api.ReplicationController) error {
		if !api.Semantic.DeepDerivative(controllerSpec, testControllerSpec) {
			t.Errorf("Expected %#v, but got %#v", testControllerSpec, controllerSpec)
		}
		close(received)
		return nil
	}

	resourceVersion := ""
	go manager.watchControllers(&resourceVersion)

	// Test normal case
	testControllerSpec.Name = "foo"

	fakeWatch.Add(&testControllerSpec)

	select {
	case <-received:
	case <-time.After(10 * time.Millisecond):
		t.Errorf("Expected 1 call but got 0")
	}
}
開發者ID:vrosnet,項目名稱:kubernetes,代碼行數:28,代碼來源:replication_controller_test.go

示例3: 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")
	}
}
開發者ID:hknochi,項目名稱:kubernetes,代碼行數:51,代碼來源:replication_controller_test.go

示例4: Rename

func Rename(c RollingUpdaterClient, rc *api.ReplicationController, newName string) error {
	oldName := rc.Name
	rc.Name = newName
	rc.ResourceVersion = ""

	_, err := c.CreateReplicationController(rc.Namespace, rc)
	if err != nil {
		return err
	}
	err = c.DeleteReplicationController(rc.Namespace, oldName)
	if err != nil && !errors.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:da4e,項目名稱:kubernetes,代碼行數:15,代碼來源:rolling_updater.go

示例5: TestExtractControllerJson

func TestExtractControllerJson(t *testing.T) {
	mockRegistry := MockControllerRegistry{}
	storage := ControllerRegistryStorage{
		registry: &mockRegistry,
	}
	controller := api.ReplicationController{
		JSONBase: api.JSONBase{
			ID: "foo",
		},
	}
	body, err := json.Marshal(controller)
	expectNoError(t, err)
	controllerOut, err := storage.Extract(string(body))
	expectNoError(t, err)
	// Extract adds a Kind
	controller.Kind = "cluster#replicationController"
	if !reflect.DeepEqual(controller, controllerOut) {
		t.Errorf("Expected %#v, found %#v", controller, controllerOut)
	}
}
開發者ID:haegyung,項目名稱:kubernetes,代碼行數:20,代碼來源:controller_registry_test.go

示例6: TestWatchControllers

func TestWatchControllers(t *testing.T) {
	fakeWatch := watch.NewFake()
	client := &testclient.Fake{Watch: fakeWatch}
	manager := NewReplicationManager(client, BurstReplicas)
	manager.podStoreSynced = alwaysReady

	var testControllerSpec api.ReplicationController
	received := make(chan string)

	// The update sent through the fakeWatcher should make its way into the workqueue,
	// and eventually into the syncHandler. The handler validates the received controller
	// and closes the received channel to indicate that the test can finish.
	manager.syncHandler = func(key string) error {

		obj, exists, err := manager.rcStore.Store.GetByKey(key)
		if !exists || err != nil {
			t.Errorf("Expected to find controller under key %v", key)
		}
		controllerSpec := *obj.(*api.ReplicationController)
		if !api.Semantic.DeepDerivative(controllerSpec, testControllerSpec) {
			t.Errorf("Expected %#v, but got %#v", testControllerSpec, controllerSpec)
		}
		close(received)
		return nil
	}
	// Start only the rc watcher and the workqueue, send a watch event,
	// and make sure it hits the sync method.
	stopCh := make(chan struct{})
	defer close(stopCh)
	go manager.rcController.Run(stopCh)
	go util.Until(manager.worker, 10*time.Millisecond, stopCh)

	testControllerSpec.Name = "foo"
	fakeWatch.Add(&testControllerSpec)

	select {
	case <-received:
	case <-time.After(controllerTimeout):
		t.Errorf("Expected 1 call but got 0")
	}
}
開發者ID:rferris,項目名稱:kubernetes,代碼行數:41,代碼來源:replication_controller_test.go

示例7: SetNextControllerAnnotation

func SetNextControllerAnnotation(rc *api.ReplicationController, name string) {
	if rc.Annotations == nil {
		rc.Annotations = map[string]string{}
	}
	rc.Annotations[nextControllerAnnotation] = name
}
開發者ID:da4e,項目名稱:kubernetes,代碼行數:6,代碼來源:rolling_updater.go

示例8: Extract

func (storage *ControllerRegistryStorage) Extract(body string) (interface{}, error) {
	result := api.ReplicationController{}
	err := json.Unmarshal([]byte(body), &result)
	result.Kind = "cluster#replicationController"
	return result, err
}
開發者ID:haegyung,項目名稱:kubernetes,代碼行數:6,代碼來源:controller_registry.go

示例9: withCreated

func withCreated(item *kapi.ReplicationController, creationTimestamp util.Time) *kapi.ReplicationController {
	item.CreationTimestamp = creationTimestamp
	return item
}
開發者ID:pombredanne,項目名稱:atomic-enterprise,代碼行數:4,代碼來源:data_test.go

示例10: CreateRC

func (self *realKubeFramework) CreateRC(ns string, rc *api.ReplicationController) (*api.ReplicationController, error) {
	rc.Namespace = ns
	return self.kubeClient.ReplicationControllers(ns).Create(rc)
}
開發者ID:kurkop,項目名稱:heapster,代碼行數:4,代碼來源:framework.go


注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/api.ReplicationController類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。