mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Merge pull request #19440 from Random-Liu/add-update-count-in-density-test
Auto commit by PR queue bot
This commit is contained in:
commit
9e7da41481
@ -211,6 +211,8 @@ var _ = Describe("Density [Skipped]", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a listener for events.
|
// Create a listener for events.
|
||||||
|
// eLock is a lock protects the events
|
||||||
|
var eLock sync.Mutex
|
||||||
events := make([](*api.Event), 0)
|
events := make([](*api.Event), 0)
|
||||||
_, controller := controllerframework.NewInformer(
|
_, controller := controllerframework.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
@ -225,6 +227,8 @@ var _ = Describe("Density [Skipped]", func() {
|
|||||||
0,
|
0,
|
||||||
controllerframework.ResourceEventHandlerFuncs{
|
controllerframework.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) {
|
AddFunc: func(obj interface{}) {
|
||||||
|
eLock.Lock()
|
||||||
|
defer eLock.Unlock()
|
||||||
events = append(events, obj.(*api.Event))
|
events = append(events, obj.(*api.Event))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -232,6 +236,34 @@ var _ = Describe("Density [Skipped]", func() {
|
|||||||
stop := make(chan struct{})
|
stop := make(chan struct{})
|
||||||
go controller.Run(stop)
|
go controller.Run(stop)
|
||||||
|
|
||||||
|
// Create a listener for api updates
|
||||||
|
// uLock is a lock protects the updateCount
|
||||||
|
var uLock sync.Mutex
|
||||||
|
updateCount := 0
|
||||||
|
label := labels.SelectorFromSet(labels.Set(map[string]string{"name": RCName}))
|
||||||
|
_, updateController := controllerframework.NewInformer(
|
||||||
|
&cache.ListWatch{
|
||||||
|
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
||||||
|
options.LabelSelector = label
|
||||||
|
return c.Pods(ns).List(options)
|
||||||
|
},
|
||||||
|
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
||||||
|
options.LabelSelector = label
|
||||||
|
return c.Pods(ns).Watch(options)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
&api.Pod{},
|
||||||
|
0,
|
||||||
|
controllerframework.ResourceEventHandlerFuncs{
|
||||||
|
UpdateFunc: func(_, _ interface{}) {
|
||||||
|
uLock.Lock()
|
||||||
|
defer uLock.Unlock()
|
||||||
|
updateCount++
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
go updateController.Run(stop)
|
||||||
|
|
||||||
// Start the replication controller.
|
// Start the replication controller.
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
expectNoError(RunRC(config))
|
expectNoError(RunRC(config))
|
||||||
@ -241,10 +273,22 @@ var _ = Describe("Density [Skipped]", func() {
|
|||||||
By("Waiting for all events to be recorded")
|
By("Waiting for all events to be recorded")
|
||||||
last := -1
|
last := -1
|
||||||
current := len(events)
|
current := len(events)
|
||||||
|
lastCount := -1
|
||||||
|
currentCount := updateCount
|
||||||
timeout := 10 * time.Minute
|
timeout := 10 * time.Minute
|
||||||
for start := time.Now(); last < current && time.Since(start) < timeout; time.Sleep(10 * time.Second) {
|
for start := time.Now(); (last < current || lastCount < currentCount) && time.Since(start) < timeout; time.Sleep(10 * time.Second) {
|
||||||
|
func() {
|
||||||
|
eLock.Lock()
|
||||||
|
defer eLock.Unlock()
|
||||||
last = current
|
last = current
|
||||||
current = len(events)
|
current = len(events)
|
||||||
|
}()
|
||||||
|
func() {
|
||||||
|
uLock.Lock()
|
||||||
|
defer uLock.Unlock()
|
||||||
|
lastCount = currentCount
|
||||||
|
currentCount = updateCount
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
close(stop)
|
close(stop)
|
||||||
|
|
||||||
@ -252,6 +296,10 @@ var _ = Describe("Density [Skipped]", func() {
|
|||||||
Logf("Warning: Not all events were recorded after waiting %.2f minutes", timeout.Minutes())
|
Logf("Warning: Not all events were recorded after waiting %.2f minutes", timeout.Minutes())
|
||||||
}
|
}
|
||||||
Logf("Found %d events", current)
|
Logf("Found %d events", current)
|
||||||
|
if currentCount != lastCount {
|
||||||
|
Logf("Warning: Not all updates were recorded after waiting %.2f minutes", timeout.Minutes())
|
||||||
|
}
|
||||||
|
Logf("Found %d updates", currentCount)
|
||||||
|
|
||||||
// Tune the threshold for allowed failures.
|
// Tune the threshold for allowed failures.
|
||||||
badEvents := BadEvents(events)
|
badEvents := BadEvents(events)
|
||||||
|
Loading…
Reference in New Issue
Block a user