Fix an out-of-bound array access in simulator.TestClear()
This commit is contained in:
parent
f18b65a80c
commit
6821ab8f90
|
|
@ -53,6 +53,10 @@ func createTestPods(n int) []*apiv1.Pod {
|
||||||
}
|
}
|
||||||
|
|
||||||
func assignPodsToNodes(pods []*apiv1.Pod, nodes []*apiv1.Node) {
|
func assignPodsToNodes(pods []*apiv1.Pod, nodes []*apiv1.Node) {
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
j := 0
|
j := 0
|
||||||
for i := 0; i < len(pods); i++ {
|
for i := 0; i < len(pods); i++ {
|
||||||
if j >= len(nodes) {
|
if j >= len(nodes) {
|
||||||
|
|
|
||||||
|
|
@ -240,8 +240,8 @@ func TestClear(t *testing.T) {
|
||||||
// Run with -count=1 to avoid caching.
|
// Run with -count=1 to avoid caching.
|
||||||
localRand := rand.New(rand.NewSource(time.Now().Unix()))
|
localRand := rand.New(rand.NewSource(time.Now().Unix()))
|
||||||
|
|
||||||
nodeCount := localRand.Intn(100)
|
nodeCount := localRand.Intn(99) + 1
|
||||||
podCount := localRand.Intn(1000)
|
podCount := localRand.Intn(999) + 1
|
||||||
extraNodeCount := localRand.Intn(100)
|
extraNodeCount := localRand.Intn(100)
|
||||||
extraPodCount := localRand.Intn(1000)
|
extraPodCount := localRand.Intn(1000)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue