mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #93721 from gitlawr/speedup-reconciler-tests
Speed up master reconciler tests
This commit is contained in:
commit
b7d59d37fa
@ -24,6 +24,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -412,8 +413,8 @@ func verifyEndpointsWithIPs(servers []*kubeapiservertesting.TestServer, ips []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) {
|
func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) {
|
||||||
var leaseServers []*kubeapiservertesting.TestServer
|
var leaseServers = make([]*kubeapiservertesting.TestServer, leaseCount)
|
||||||
var masterCountServers []*kubeapiservertesting.TestServer
|
var masterCountServers = make([]*kubeapiservertesting.TestServer, masterCount)
|
||||||
etcd := framework.SharedEtcd()
|
etcd := framework.SharedEtcd()
|
||||||
|
|
||||||
instanceOptions := &kubeapiservertesting.TestServerInstanceOptions{
|
instanceOptions := &kubeapiservertesting.TestServerInstanceOptions{
|
||||||
@ -423,16 +424,22 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) {
|
|||||||
// cleanup the registry storage
|
// cleanup the registry storage
|
||||||
defer registry.CleanupStorage()
|
defer registry.CleanupStorage()
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
// 1. start masterCount api servers
|
// 1. start masterCount api servers
|
||||||
for i := 0; i < masterCount; i++ {
|
for i := 0; i < masterCount; i++ {
|
||||||
// start master count api server
|
// start master count api server
|
||||||
server := kubeapiservertesting.StartTestServerOrDie(t, instanceOptions, []string{
|
wg.Add(1)
|
||||||
"--endpoint-reconciler-type", "master-count",
|
go func(i int) {
|
||||||
"--advertise-address", fmt.Sprintf("10.0.1.%v", i+1),
|
defer wg.Done()
|
||||||
"--apiserver-count", fmt.Sprintf("%v", masterCount),
|
server := kubeapiservertesting.StartTestServerOrDie(t, instanceOptions, []string{
|
||||||
}, etcd)
|
"--endpoint-reconciler-type", "master-count",
|
||||||
masterCountServers = append(masterCountServers, server)
|
"--advertise-address", fmt.Sprintf("10.0.1.%v", i+1),
|
||||||
|
"--apiserver-count", fmt.Sprintf("%v", masterCount),
|
||||||
|
}, etcd)
|
||||||
|
masterCountServers[i] = server
|
||||||
|
}(i)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
// 2. verify master count servers have registered
|
// 2. verify master count servers have registered
|
||||||
if err := wait.PollImmediate(3*time.Second, 2*time.Minute, func() (bool, error) {
|
if err := wait.PollImmediate(3*time.Second, 2*time.Minute, func() (bool, error) {
|
||||||
@ -453,14 +460,23 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) {
|
|||||||
|
|
||||||
// 3. start lease api servers
|
// 3. start lease api servers
|
||||||
for i := 0; i < leaseCount; i++ {
|
for i := 0; i < leaseCount; i++ {
|
||||||
options := []string{
|
wg.Add(1)
|
||||||
"--endpoint-reconciler-type", "lease",
|
go func(i int) {
|
||||||
"--advertise-address", fmt.Sprintf("10.0.1.%v", i+10),
|
defer wg.Done()
|
||||||
}
|
options := []string{
|
||||||
server := kubeapiservertesting.StartTestServerOrDie(t, instanceOptions, options, etcd)
|
"--endpoint-reconciler-type", "lease",
|
||||||
defer server.TearDownFn()
|
"--advertise-address", fmt.Sprintf("10.0.1.%v", i+10),
|
||||||
leaseServers = append(leaseServers, server)
|
}
|
||||||
|
server := kubeapiservertesting.StartTestServerOrDie(t, instanceOptions, options, etcd)
|
||||||
|
leaseServers[i] = server
|
||||||
|
}(i)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
defer func() {
|
||||||
|
for i := 0; i < leaseCount; i++ {
|
||||||
|
leaseServers[i].TearDownFn()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
@ -488,15 +504,15 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestReconcilerMasterLeaseCombined(t *testing.T) {
|
func TestReconcilerMasterLeaseCombined(t *testing.T) {
|
||||||
testReconcilersMasterLease(t, 1, 3)
|
testReconcilersMasterLease(t, 1, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReconcilerMasterLeaseMultiMoreMasters(t *testing.T) {
|
func TestReconcilerMasterLeaseMultiMoreMasters(t *testing.T) {
|
||||||
testReconcilersMasterLease(t, 3, 2)
|
testReconcilersMasterLease(t, 2, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReconcilerMasterLeaseMultiCombined(t *testing.T) {
|
func TestReconcilerMasterLeaseMultiCombined(t *testing.T) {
|
||||||
testReconcilersMasterLease(t, 3, 3)
|
testReconcilersMasterLease(t, 2, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiMasterNodePortAllocation(t *testing.T) {
|
func TestMultiMasterNodePortAllocation(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user