示例#1
0
// Polls for the store to have the same number of pods as the argument
func waitForPodsInIntent(kpStore *kptest.FakePodStore, numPodsExpected int) error {
	condition := func() error {
		manifestResults, _, err := kpStore.AllPods(kp.INTENT_TREE)
		if err != nil {
			return util.Errorf("Unable to get all pods from pod store: %v", err)
		}
		if len(manifestResults) != numPodsExpected {
			return util.Errorf(
				"Expected no manifests to be scheduled, got '%v' manifests, expected '%v'",
				len(manifestResults),
				numPodsExpected,
			)
		}
		return nil
	}
	return waitForCondition(condition)
}
示例#2
0
// Polls for the store to have a pod with the same pod id and node name
func waitForSpecificPod(kpStore *kptest.FakePodStore, nodeName types.NodeName, podID types.PodID) error {
	condition := func() error {
		manifestResults, _, err := kpStore.AllPods(kp.INTENT_TREE)
		if err != nil {
			return util.Errorf("Unable to get all pods from pod store: %v", err)
		}
		if manifestResults[0].PodLocation.Node != nodeName {
			return util.Errorf("expected manifest scheduled on the right node")
		}
		if manifestResults[0].PodLocation.PodID != podID {
			return util.Errorf("expected manifest scheduled with correct pod ID")
		}
		if manifestResults[0].Manifest.ID() != podID {
			return util.Errorf("expected manifest with correct ID")
		}
		return nil
	}
	return waitForCondition(condition)
}