mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 06:43:54 +00:00
fix petset ut bug
This commit is contained in:
parent
2a7d0df30d
commit
927569bc5b
@ -246,7 +246,7 @@ func (f *fakePetClient) deletePetAtIndex(index int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakePetClient) setHealthy(index int) error {
|
func (f *fakePetClient) setHealthy(index int) error {
|
||||||
if len(f.pets) < index {
|
if len(f.pets) <= index {
|
||||||
return fmt.Errorf("Index out of range, len %v index %v", len(f.pets), index)
|
return fmt.Errorf("Index out of range, len %v index %v", len(f.pets), index)
|
||||||
}
|
}
|
||||||
f.pets[index].pod.Status.Phase = api.PodRunning
|
f.pets[index].pod.Status.Phase = api.PodRunning
|
||||||
@ -268,7 +268,7 @@ func (f *fakePetClient) isHealthy(pod *api.Pod) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakePetClient) setDeletionTimestamp(index int) error {
|
func (f *fakePetClient) setDeletionTimestamp(index int) error {
|
||||||
if len(f.pets) < index {
|
if len(f.pets) <= index {
|
||||||
return fmt.Errorf("Index out of range, len %v index %v", len(f.pets), index)
|
return fmt.Errorf("Index out of range, len %v index %v", len(f.pets), index)
|
||||||
}
|
}
|
||||||
f.pets[index].pod.DeletionTimestamp = &unversioned.Time{Time: time.Now()}
|
f.pets[index].pod.DeletionTimestamp = &unversioned.Time{Time: time.Now()}
|
||||||
|
@ -73,7 +73,7 @@ func scalePetSet(t *testing.T, ps *apps.PetSet, psc *PetSetController, fc *fakeP
|
|||||||
for i := 0; i < scale; i++ {
|
for i := 0; i < scale; i++ {
|
||||||
pl := fc.getPodList()
|
pl := fc.getPodList()
|
||||||
if len(pl) != i {
|
if len(pl) != i {
|
||||||
t.Errorf("Unexpected number of pets, expected %d found %d", i, len(fc.pets))
|
t.Errorf("Unexpected number of pets, expected %d found %d", i, len(pl))
|
||||||
}
|
}
|
||||||
if _, syncErr := psc.syncPetSet(ps, pl); syncErr != nil {
|
if _, syncErr := psc.syncPetSet(ps, pl); syncErr != nil {
|
||||||
errs = append(errs, syncErr)
|
errs = append(errs, syncErr)
|
||||||
@ -120,7 +120,7 @@ func TestPetSetControllerDeletes(t *testing.T) {
|
|||||||
knownPods := fc.getPodList()
|
knownPods := fc.getPodList()
|
||||||
for i := replicas - 1; i >= 0; i-- {
|
for i := replicas - 1; i >= 0; i-- {
|
||||||
if len(fc.pets) != i+1 {
|
if len(fc.pets) != i+1 {
|
||||||
t.Errorf("Unexpected number of pets, expected %d found %d", i, len(fc.pets))
|
t.Errorf("Unexpected number of pets, expected %d found %d", i+1, len(fc.pets))
|
||||||
}
|
}
|
||||||
if _, syncErr := psc.syncPetSet(ps, knownPods); syncErr != nil {
|
if _, syncErr := psc.syncPetSet(ps, knownPods); syncErr != nil {
|
||||||
errs = append(errs, syncErr)
|
errs = append(errs, syncErr)
|
||||||
|
Loading…
Reference in New Issue
Block a user