• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang api.ReplicationController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang api.ReplicationControllerList类代码示例发布时间:2022-05-23
下一篇:
Golang api.PodStatus类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap