GCE: Allow nodes to exceed target pool maximums
If we would exceeded the TargetPool API maximums, instead just randomly select some subsection of the nodes to include in the TP instead.
This commit is contained in:
@@ -18,6 +18,8 @@ package rand
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -71,3 +73,14 @@ func TestPerm(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestShuffle(t *testing.T) {
|
||||
Seed(5) // Arbitrary RNG seed for deterministic testing.
|
||||
have := []int{0, 1, 2, 3, 4}
|
||||
want := []int{3, 2, 4, 1, 0} // "have" shuffled, with RNG at Seed(5).
|
||||
got := append([]int{}, have...)
|
||||
Shuffle(sort.IntSlice(got))
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Shuffle(%v) => %v, want %v", have, got, want)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user