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:
Zach Loafman
2016-05-04 15:11:16 -07:00
parent e973b5d27a
commit faf0c44429
4 changed files with 211 additions and 26 deletions

View File

@@ -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)
}
}