本文整理汇总了Golang中github.com/square/p2/pkg/types.PodID函数的典型用法代码示例。如果您正苦于以下问题:Golang PodID函数的具体用法?Golang PodID怎么用?Golang PodID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PodID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestStartWatchBasic
func TestStartWatchBasic(t *testing.T) {
quitCh := make(chan struct{})
defer close(quitCh)
hs, checker := NewFakeHealthStore()
go hs.StartWatch(quitCh)
node := types.NodeName("abc01.sjc1")
podID1 := types.PodID("podID1")
podID2 := types.PodID("podID2")
result := hs.Fetch(podID1, node)
if result != nil {
t.Errorf("expected cache to start empty, found %v", result)
}
checker.Send([]*health.Result{
{ID: podID1, Node: node},
{ID: podID2, Node: node},
})
result = hs.Fetch(podID1, node)
if result == nil {
t.Errorf("expected health store to have %s", podID1)
}
result = hs.Fetch(podID2, node)
if result == nil {
t.Errorf("expected health store to have %s", podID2)
}
}
开发者ID:petertseng,项目名称:p2,代码行数:30,代码来源:store_test.go
示例2: TestList
func TestList(t *testing.T) {
store := consulStoreWithFakeKV()
// Create first DaemonSet
firstPodID := types.PodID("some_pod_id")
minHealth := 0
clusterName := ds_fields.ClusterName("some_name")
azLabel := pc_fields.AvailabilityZone("some_zone")
selector := klabels.Everything().
Add(pc_fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{azLabel.String()})
manifestBuilder := manifest.NewBuilder()
manifestBuilder.SetID(firstPodID)
firstManifest := manifestBuilder.GetManifest()
timeout := replication.NoTimeout
firstDS, err := store.Create(firstManifest, minHealth, clusterName, selector, firstPodID, timeout)
if err != nil {
t.Fatalf("Unable to create daemon set: %s", err)
}
// Create second DaemonSet
secondPodID := types.PodID("different_pod_id")
manifestBuilder = manifest.NewBuilder()
manifestBuilder.SetID(secondPodID)
secondManifest := manifestBuilder.GetManifest()
secondDS, err := store.Create(secondManifest, minHealth, clusterName, selector, secondPodID, timeout)
if err != nil {
t.Fatalf("Unable to create daemon set: %s", err)
}
daemonSetList, err := store.List()
if err != nil {
t.Fatalf("Error getting list of daemon sets: %s", err)
}
Assert(t).AreEqual(len(daemonSetList), 2, "Unexpected number of daemon sets listed")
for _, daemonSet := range daemonSetList {
if daemonSet.ID == firstDS.ID {
Assert(t).AreEqual(daemonSet.PodID, firstPodID, "Listed daemon set pod ids were not equal")
} else if daemonSet.PodID == secondDS.PodID {
Assert(t).AreEqual(daemonSet.PodID, secondPodID, "Listed daemon set pod ids were not equal")
} else {
t.Errorf("Unexpected daemon set listed: %v", daemonSet)
}
}
}
开发者ID:rudle,项目名称:p2,代码行数:55,代码来源:consul_store_test.go
示例3: TestLabelsOnCreate
func TestLabelsOnCreate(t *testing.T) {
store := consulStoreWithFakeKV()
podID := types.PodID("pod_id")
az := fields.AvailabilityZone("us-west")
clusterName := fields.ClusterName("cluster_name")
selector := klabels.Everything().
Add(fields.PodIDLabel, klabels.EqualsOperator, []string{podID.String()}).
Add(fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{az.String()}).
Add(fields.ClusterNameLabel, klabels.EqualsOperator, []string{clusterName.String()})
annotations := fields.Annotations(map[string]interface{}{
"foo": "bar",
})
pc, err := store.Create(podID, az, clusterName, selector, annotations, kptest.NewSession())
if err != nil {
t.Fatalf("Unable to create pod cluster: %s", err)
}
matches, err := store.applicator.GetMatches(selector, labels.PC)
if err != nil {
t.Fatalf("Unable to check for label match on new pod cluster: %s", err)
}
if len(matches) != 1 {
t.Errorf("Expected one pod cluster to match label selector")
}
if fields.ID(matches[0].ID) != pc.ID {
t.Errorf("The pod cluster selector didn't match the new pod cluster")
}
}
开发者ID:drcapulet,项目名称:p2,代码行数:33,代码来源:consul_store_test.go
示例4: constructFinishFromEnvironment
func (e EnvironmentExtractor) constructFinishFromEnvironment(exitCode int, exitStatus int) (FinishOutput, error) {
podID := os.Getenv(pods.PodIDEnvVar)
if podID == "" {
return FinishOutput{}, util.Errorf("No %s env var set", pods.PodIDEnvVar)
}
launchableID := os.Getenv(pods.LaunchableIDEnvVar)
if launchableID == "" {
return FinishOutput{}, util.Errorf("No %s env var set", pods.LaunchableIDEnvVar)
}
entryPoint := os.Getenv(launch.EntryPointEnvVar)
if entryPoint == "" {
return FinishOutput{}, util.Errorf("No %s env var set", launch.EntryPointEnvVar)
}
// It's okay if this one is missing, most pods are "legacy" pods that have a blank unique key
podUniqueKey := os.Getenv(pods.PodUniqueKeyEnvVar)
return FinishOutput{
PodID: types.PodID(podID),
LaunchableID: launch.LaunchableID(launchableID),
EntryPoint: entryPoint,
PodUniqueKey: types.PodUniqueKey(podUniqueKey),
ExitCode: exitCode,
ExitStatus: exitStatus,
}, nil
}
开发者ID:petertseng,项目名称:p2,代码行数:28,代码来源:env_extractor.go
示例5: ensureConsistency
func (rc *replicationController) ensureConsistency(current types.PodLocations) error {
manifestSHA, err := rc.Manifest.SHA()
if err != nil {
return err
}
for _, pod := range current {
intent, _, err := rc.kpStore.Pod(kp.INTENT_TREE, pod.Node, types.PodID(pod.PodID))
if err != nil && err != pods.NoCurrentManifest {
return err
}
var intentSHA string
if intent != nil {
intentSHA, err = intent.SHA()
if err != nil {
rc.logger.WithError(err).WithField("node", pod.Node).Warn("Could not hash manifest to determine consistency of intent")
}
if intentSHA == manifestSHA {
continue
}
}
rc.logger.WithField("node", pod.Node).WithField("intentManifestSHA", intentSHA).Info("Found inconsistency in scheduled manifest")
if err := rc.schedule(pod.Node); err != nil {
return err
}
}
return nil
}
开发者ID:drcapulet,项目名称:p2,代码行数:29,代码来源:replication_controller.go
示例6: TestUpdatePods
// UpdatePods looks at the pods currently being monitored and
// compares that to what the reality store indicates should be
// running. UpdatePods then shuts down the monitors for dead
// pods and creates PodWatch structs for new pods.
func TestUpdatePods(t *testing.T) {
var current []PodWatch
var reality []kp.ManifestResult
// ids for current: 0, 1, 2, 3
for i := 0; i < 4; i++ {
current = append(current, *newWatch(types.PodID(strconv.Itoa(i))))
}
// ids for reality: 1, 2, test
for i := 1; i < 3; i++ {
// Health checking is not supported for uuid pods, so ensure that even
// if /reality contains a uuid pod we don't actually watch its health
uuidKeyResult := newManifestResult("some_uuid_pod")
uuidKeyResult.PodUniqueKey = types.NewPodUUID()
reality = append(reality, uuidKeyResult)
reality = append(reality, newManifestResult(current[i].manifest.ID()))
}
reality = append(reality, newManifestResult("test"))
// ids for pods: 1, 2, test
// 0, 3 should have values in their shutdownCh
logger := logging.NewLogger(logrus.Fields{})
pods := updatePods(&MockHealthManager{}, nil, nil, current, reality, "", &logger)
Assert(t).AreEqual(true, <-current[0].shutdownCh, "this PodWatch should have been shutdown")
Assert(t).AreEqual(true, <-current[3].shutdownCh, "this PodWatch should have been shutdown")
Assert(t).AreEqual(current[1].manifest.ID(), pods[0].manifest.ID(), "pod with id:1 should have been returned")
Assert(t).AreEqual(current[2].manifest.ID(), pods[1].manifest.ID(), "pod with id:1 should have been returned")
Assert(t).AreEqual("test", string(pods[2].manifest.ID()), "should have added pod with id:test to list")
}
开发者ID:petertseng,项目名称:p2,代码行数:33,代码来源:health_test.go
示例7: TestCreate
func TestCreate(t *testing.T) {
testAZ := fields.AvailabilityZone("west-coast")
testCN := fields.ClusterName("test")
testPodID := types.PodID("pod")
selector := labels.Everything().
Add(fields.PodIDLabel, labels.EqualsOperator, []string{testPodID.String()}).
Add(fields.AvailabilityZoneLabel, labels.EqualsOperator, []string{testAZ.String()}).
Add(fields.ClusterNameLabel, labels.EqualsOperator, []string{testCN.String()})
session := kptest.NewSession()
pcstore := pcstoretest.NewFake()
pcController := NewPodCluster(testAZ, testCN, testPodID, pcstore, selector, session)
annotations := map[string]string{
"load_balancer_info": "totally",
"pager_information": "555-111-2222",
}
buf, err := json.Marshal(annotations)
if err != nil {
t.Errorf("json marshal error: %v", err)
}
var testAnnotations fields.Annotations
if err := json.Unmarshal(buf, &testAnnotations); err != nil {
t.Errorf("json unmarshal error: %v", err)
}
pc, err := pcController.Create(fields.Annotations(testAnnotations))
if err != nil {
t.Errorf("got error during creation: %v", err)
}
if pc.ID == "" {
t.Error("got empty pc ID")
}
if pc.PodID != testPodID {
t.Errorf("Expected to get %s, got: %v", pc.PodID, testPodID)
}
if pc.Name != testCN {
t.Errorf("Expected to get %s, got: %v", testCN, pc.Name)
}
if pc.AvailabilityZone != testAZ {
t.Errorf("Expected to get %s, got: %v", testAZ, pc.AvailabilityZone)
}
if pc.PodSelector.String() != selector.String() {
t.Errorf("Expected to get %s, got: %v", selector, pc.PodSelector)
}
if pc.Annotations["load_balancer_info"] != testAnnotations["load_balancer_info"] {
t.Errorf("Expected to get %s, got: %v", testAnnotations, pc.Annotations)
}
if pc.Annotations["pager_information"] != testAnnotations["pager_information"] {
t.Errorf("Expected to get %s, got: %v", testAnnotations, pc.Annotations)
}
}
开发者ID:petertseng,项目名称:p2,代码行数:60,代码来源:control_test.go
示例8: PodID
func (h *HookEnv) PodID() (types.PodID, error) {
id := os.Getenv(HOOKED_POD_ID_ENV_VAR)
if id == "" {
return "", util.Errorf("Did not provide a pod ID to use")
}
return types.PodID(id), nil
}
开发者ID:petertseng,项目名称:p2,代码行数:8,代码来源:hook_env.go
示例9: deleteLegacyPod
func (rm *P2RM) deleteLegacyPod() error {
_, err := rm.Store.DeletePod(kp.INTENT_TREE, rm.NodeName, types.PodID(rm.PodID))
if err != nil {
return fmt.Errorf("unable to remove pod: %v", err)
}
return nil
}
开发者ID:petertseng,项目名称:p2,代码行数:8,代码来源:rm.go
示例10: handlePodRemoval
func handlePodRemoval(consulClient consulutil.ConsulClient, labeler labels.ApplicatorWithoutWatches) error {
var rm *P2RM
if *podUniqueKey != "" {
rm = NewUUIDP2RM(consulClient, types.PodUniqueKey(*podUniqueKey), types.PodID(*podName), labeler)
} else {
if *nodeName == "" {
hostname, err := os.Hostname()
if err != nil {
return fmt.Errorf("error getting hostname. use --node to specify a node: %v\n", err)
}
*nodeName = hostname
}
rm = NewLegacyP2RM(consulClient, types.PodID(*podName), types.NodeName(*nodeName), labeler)
}
podIsManagedByRC, rcID, err := rm.checkForManagingReplicationController()
if err != nil {
return err
}
if !podIsManagedByRC {
err = rm.deletePod()
if err != nil {
return err
}
}
if podIsManagedByRC && !*deallocation {
return fmt.Errorf("error: %s is managed by replication controller: %s\n"+
"It's possible you meant you deallocate this pod on this node. If so, please confirm your intention with --deallocate\n", *nodeName, rcID)
}
if podIsManagedByRC && *deallocation {
err = rm.decrementDesiredCount(rcID)
if err != nil {
return fmt.Errorf("Encountered error deallocating from the RC %s. You may attempt this command again or use `p2-rctl` to cleanup manually.\n%v",
rcID,
err)
}
}
fmt.Printf("%s: successfully removed %s\n", rm.NodeName, rm.PodID)
return nil
}
开发者ID:petertseng,项目名称:p2,代码行数:45,代码来源:main.go
示例11: TestWatch
func TestWatch(t *testing.T) {
store := consulStoreWithFakeKV()
podID := types.PodID("pod_id")
az := fields.AvailabilityZone("us-west")
clusterName := fields.ClusterName("cluster_name")
selector := klabels.Everything().
Add(fields.PodIDLabel, klabels.EqualsOperator, []string{podID.String()}).
Add(fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{az.String()}).
Add(fields.ClusterNameLabel, klabels.EqualsOperator, []string{clusterName.String()})
annotations := fields.Annotations(map[string]interface{}{
"foo": "bar",
})
var watched WatchedPodClusters
session := kptest.NewSession()
pc, err := store.Create(podID, az, clusterName, selector, annotations, session)
if err != nil {
t.Fatalf("Unable to create first pod cluster: %s", err)
}
pc2, err := store.Create(podID, "us-east", clusterName, selector, annotations, session)
if err != nil {
t.Fatalf("Unable to create second pod cluster: %s", err)
}
quit := make(chan struct{})
defer close(quit)
watch := store.Watch(quit)
select {
case watchedPC := <-watch:
watched = watchedPC
case <-time.After(5 * time.Second):
t.Fatal("nothing on the channel")
}
if len(watched.Clusters) != 2 {
t.Fatalf("Expected to get two watched PodClusters, but did not: got %v", len(watched.Clusters))
}
expectedIDs := []fields.ID{pc.ID, pc2.ID}
for _, id := range expectedIDs {
found := false
for _, pc := range watched.Clusters {
if id == pc.ID {
found = true
break
}
}
if !found {
t.Errorf("Expected to find id '%s' among watch results, but was not present", id)
}
}
}
开发者ID:drcapulet,项目名称:p2,代码行数:56,代码来源:consul_store_test.go
示例12: Service
func (h AlwaysHappyHealthChecker) Service(serviceID string) (map[types.NodeName]health.Result, error) {
results := make(map[types.NodeName]health.Result)
for _, node := range h.allNodes {
results[node] = health.Result{
ID: types.PodID(serviceID),
Status: health.Passing,
}
}
return results, nil
}
开发者ID:petertseng,项目名称:p2,代码行数:10,代码来源:fake_checker.go
示例13: createPodCluster
func createPodCluster(store *consulStore, t *testing.T) fields.PodCluster {
podID := types.PodID("pod_id")
az := fields.AvailabilityZone("us-west")
clusterName := fields.ClusterName("cluster_name")
selector := klabels.Everything().
Add(fields.PodIDLabel, klabels.EqualsOperator, []string{podID.String()}).
Add(fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{az.String()}).
Add(fields.ClusterNameLabel, klabels.EqualsOperator, []string{clusterName.String()})
annotations := fields.Annotations(map[string]interface{}{
"foo": "bar",
})
session := kptest.NewSession()
pc, err := store.Create(podID, az, clusterName, selector, annotations, session)
if err != nil {
t.Fatalf("Unable to create pod cluster: %s", err)
}
if pc.ID == "" {
t.Errorf("pod cluster should have an id")
}
if pc.PodID == "" {
t.Errorf("pod cluster should have a pod id")
}
if pc.PodID != podID {
t.Errorf("pod id wasn't properly set. Wanted '%s' got '%s'", podID, pc.PodID)
}
if pc.AvailabilityZone != az {
t.Errorf("availability zone wasn't properly set. Wanted '%s' got '%s'", az, pc.AvailabilityZone)
}
if pc.Name != clusterName {
t.Errorf("cluster name wasn't properly set. Wanted '%s' got '%s'", clusterName, pc.Name)
}
testLabels := klabels.Set{
fields.PodIDLabel: podID.String(),
fields.AvailabilityZoneLabel: az.String(),
fields.ClusterNameLabel: clusterName.String(),
}
if matches := pc.PodSelector.Matches(testLabels); !matches {
t.Errorf("the pod cluster has a bad pod selector")
}
if pc.Annotations["foo"] != "bar" {
t.Errorf("Annotations didn't match expected")
}
return pc
}
开发者ID:drcapulet,项目名称:p2,代码行数:55,代码来源:consul_store_test.go
示例14: NodeAndPodIDFromPodLabel
func NodeAndPodIDFromPodLabel(labeled Labeled) (types.NodeName, types.PodID, error) {
if labeled.LabelType != POD {
return "", "", util.Errorf("Label was not a pod label, was %s", labeled.LabelType)
}
parts := strings.SplitN(labeled.ID, "/", 2)
if len(parts) < 2 {
return "", "", util.Errorf("malformed pod label %s", labeled.ID)
}
return types.NodeName(parts[0]), types.PodID(parts[1]), nil
}
开发者ID:drcapulet,项目名称:p2,代码行数:12,代码来源:consul_applicator.go
示例15: createDaemonSet
func createDaemonSet(store *consulStore, t *testing.T) ds_fields.DaemonSet {
podID := types.PodID("some_pod_id")
minHealth := 0
clusterName := ds_fields.ClusterName("some_name")
azLabel := pc_fields.AvailabilityZone("some_zone")
selector := klabels.Everything().
Add(pc_fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{azLabel.String()})
manifestBuilder := manifest.NewBuilder()
manifestBuilder.SetID(podID)
manifest := manifestBuilder.GetManifest()
timeout := replication.NoTimeout
ds, err := store.Create(manifest, minHealth, clusterName, selector, podID, timeout)
if err != nil {
t.Fatalf("Unable to create daemon set: %s", err)
}
if ds.ID == "" {
t.Error("daemon set should have an id")
}
Assert(t).AreNotEqual(ds.ID, "", "Daemon set should have an id")
Assert(t).AreNotEqual(ds.PodID, "", "Daemon set should have a pod id")
Assert(t).AreEqual(ds.PodID, podID, "Daemon set pod id was not set correctly")
Assert(t).AreEqual(ds.MinHealth, minHealth, "Daemon set minimum health was not set correctly")
Assert(t).AreEqual(ds.Name, clusterName, "Daemon set cluster name was not set correctly")
Assert(t).IsFalse(ds.Disabled, "Daemon set disabled field was not set correctly")
testLabels := klabels.Set{
pc_fields.AvailabilityZoneLabel: azLabel.String(),
}
if matches := ds.NodeSelector.Matches(testLabels); !matches {
t.Error("The daemon set has a bad node selector")
}
originalSHA, err := manifest.SHA()
if err != nil {
t.Fatal("Unable to retrieve SHA from manifest")
}
getSHA, err := ds.Manifest.SHA()
if err != nil {
t.Fatal("Unable to retrieve SHA from manifest retrieved from daemon set")
}
Assert(t).AreEqual(originalSHA, getSHA, "Daemon set manifest not set correctly")
return ds
}
开发者ID:rudle,项目名称:p2,代码行数:52,代码来源:consul_store_test.go
示例16: examplePodCluster
func examplePodCluster() fields.PodCluster {
podId := "slug"
availabilityZone := "us-west"
clusterName := "production"
return fields.PodCluster{
PodID: types.PodID(podId),
AvailabilityZone: fields.AvailabilityZone(availabilityZone),
Name: fields.ClusterName(clusterName),
PodSelector: klabels.Everything(),
Annotations: fields.Annotations{},
}
}
开发者ID:drcapulet,项目名称:p2,代码行数:13,代码来源:consul_store_test.go
示例17: TestCreate
func TestCreate(t *testing.T) {
store := consulStoreWithFakeKV()
createDaemonSet(store, t)
// Create a bad DaemonSet
podID := types.PodID("")
minHealth := 0
clusterName := ds_fields.ClusterName("some_name")
azLabel := pc_fields.AvailabilityZone("some_zone")
selector := klabels.Everything().
Add(pc_fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{azLabel.String()})
manifestBuilder := manifest.NewBuilder()
manifestBuilder.SetID("")
podManifest := manifestBuilder.GetManifest()
timeout := replication.NoTimeout
if _, err := store.Create(podManifest, minHealth, clusterName, selector, podID, timeout); err == nil {
t.Error("Expected create to fail on bad pod id")
}
podID = types.PodID("pod_id")
if _, err := store.Create(podManifest, minHealth, clusterName, selector, podID, timeout); err == nil {
t.Error("Expected create to fail on bad manifest pod id")
}
manifestBuilder = manifest.NewBuilder()
manifestBuilder.SetID("different_pod_id")
podManifest = manifestBuilder.GetManifest()
if _, err := store.Create(podManifest, minHealth, clusterName, selector, podID, timeout); err == nil {
t.Error("Expected create to fail on pod id and manifest pod id mismatch")
}
}
开发者ID:rudle,项目名称:p2,代码行数:37,代码来源:consul_store_test.go
示例18: TestDelete
func TestDelete(t *testing.T) {
store := consulStoreWithFakeKV()
podID := types.PodID("pod_id")
az := fields.AvailabilityZone("us-west")
clusterName := fields.ClusterName("cluster_name")
selector := klabels.Everything().
Add(fields.PodIDLabel, klabels.EqualsOperator, []string{podID.String()}).
Add(fields.AvailabilityZoneLabel, klabels.EqualsOperator, []string{az.String()}).
Add(fields.ClusterNameLabel, klabels.EqualsOperator, []string{clusterName.String()})
annotations := fields.Annotations(map[string]interface{}{
"foo": "bar",
})
// Create a pod cluster
pc, err := store.Create(podID, az, clusterName, selector, annotations, kptest.NewSession())
if err != nil {
t.Fatalf("Unable to create pod cluster: %s", err)
}
pc, err = store.Get(pc.ID)
if err != nil {
t.Fatalf("Unable to get pod cluster: %s", err)
}
err = store.Delete(pc.ID)
if err != nil {
t.Fatalf("Unexpected error deleting pod cluster: %s", err)
}
_, err = store.Get(pc.ID)
if err == nil {
t.Fatalf("Should have gotten an error fetching a deleted pod cluster")
}
if !IsNotExist(err) {
t.Errorf("The error should have been a pocstore.IsNotExist but was '%s'", err)
}
labels, err := store.applicator.GetLabels(labels.PC, pc.ID.String())
if err != nil {
t.Fatalf("Got error when trying to confirm label deletion: %s", err)
}
if len(labels.Labels) != 0 {
t.Errorf("Labels were not deleted along with the pod cluster")
}
}
开发者ID:drcapulet,项目名称:p2,代码行数:49,代码来源:consul_store_test.go
示例19: updateWithHealth
func updateWithHealth(t *testing.T,
desiredOld, desiredNew int,
oldNodes, newNodes map[types.NodeName]bool,
checks map[types.NodeName]health.Result,
) (update, manifest.Manifest, manifest.Manifest) {
podID := "mypod"
oldManifest := podWithIDAndPort(podID, 9001)
newManifest := podWithIDAndPort(podID, 9002)
podMap := map[kptest.FakePodStoreKey]manifest.Manifest{}
assignManifestsToNodes(types.PodID(podID), oldNodes, podMap, oldManifest, newManifest)
assignManifestsToNodes(types.PodID(podID), newNodes, podMap, newManifest, oldManifest)
kps := kptest.NewFakePodStore(podMap, nil)
rcs := rcstore.NewFake()
applicator := labels.NewFakeApplicator()
oldRC, err := createRC(rcs, applicator, oldManifest, desiredOld, oldNodes)
Assert(t).IsNil(err, "expected no error setting up old RC")
newRC, err := createRC(rcs, applicator, newManifest, desiredNew, newNodes)
Assert(t).IsNil(err, "expected no error setting up new RC")
return update{
kps: kps,
rcs: rcs,
hcheck: checkertest.NewSingleService(podID, checks),
labeler: applicator,
logger: logging.TestLogger(),
Update: fields.Update{
OldRC: oldRC.ID,
NewRC: newRC.ID,
},
}, oldManifest, newManifest
}
开发者ID:petertseng,项目名称:p2,代码行数:36,代码来源:update_test.go
示例20: TestList
func TestList(t *testing.T) {
store := consulStoreWithFakeKV()
podID := types.PodID("pod_id")
az := fields.AvailabilityZone("us-west")
clusterName := fields.ClusterName("cluster_name")
selector := klabels.Everything()
annotations := fields.Annotations(map[string]interface{}{
"foo": "bar",
})
// Create a pod cluster
pc, err := store.Create(podID, az, clusterName, selector, annotations, kptest.NewSession())
if err != nil {
t.Fatalf("Unable to create pod cluster: %s", err)
}
// Create another one
pc2, err := store.Create(podID+"2", az, clusterName, selector, annotations, kptest.NewSession())
if err != nil {
t.Fatalf("Unable to create pod cluster: %s", err)
}
// Now test List() and make sure we get both back
pcs, err := store.List()
if err != nil {
t.Fatalf("Unable to list pod clusters: %s", err)
}
if len(pcs) != 2 {
t.Fatalf("Expected 2 results but there were %d", len(pcs))
}
for _, foundPC := range pcs {
found := false
for _, expectedPC := range []fields.ID{pc.ID, pc2.ID} {
if foundPC.ID == expectedPC {
found = true
}
}
if !found {
t.Errorf("Didn't find one of the pod clusters in the list")
}
}
}
开发者ID:drcapulet,项目名称:p2,代码行数:47,代码来源:consul_store_test.go
注:本文中的github.com/square/p2/pkg/types.PodID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论