mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #107445 from mengjiao-liu/goroutine_leak_TestSelectorSpreadScore
Fix goroutine leaks in package `selectorspread`
This commit is contained in:
commit
0c8074e1b1
@ -58,7 +58,8 @@ func BenchmarkTestSelectorSpreadPriority(b *testing.B) {
|
|||||||
client := fake.NewSimpleClientset(
|
client := fake.NewSimpleClientset(
|
||||||
&v1.Service{Spec: v1.ServiceSpec{Selector: map[string]string{"foo": ""}}},
|
&v1.Service{Spec: v1.ServiceSpec{Selector: map[string]string{"foo": ""}}},
|
||||||
)
|
)
|
||||||
ctx := context.Background()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
||||||
_ = informerFactory.Core().V1().Services().Lister()
|
_ = informerFactory.Core().V1().Services().Lister()
|
||||||
informerFactory.Start(ctx.Done())
|
informerFactory.Start(ctx.Done())
|
||||||
|
@ -396,7 +396,8 @@ func TestSelectorSpreadScore(t *testing.T) {
|
|||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
nodes := makeNodeList(test.nodes)
|
nodes := makeNodeList(test.nodes)
|
||||||
snapshot := cache.NewSnapshot(test.pods, nodes)
|
snapshot := cache.NewSnapshot(test.pods, nodes)
|
||||||
ctx := context.Background()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
informerFactory, err := populateAndStartInformers(ctx, test.rcs, test.rss, test.services, test.sss)
|
informerFactory, err := populateAndStartInformers(ctx, test.rcs, test.rss, test.services, test.sss)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating informerFactory: %+v", err)
|
t.Errorf("error creating informerFactory: %+v", err)
|
||||||
@ -653,7 +654,8 @@ func TestZoneSelectorSpreadPriority(t *testing.T) {
|
|||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
nodes := makeLabeledNodeList(labeledNodes)
|
nodes := makeLabeledNodeList(labeledNodes)
|
||||||
snapshot := cache.NewSnapshot(test.pods, nodes)
|
snapshot := cache.NewSnapshot(test.pods, nodes)
|
||||||
ctx := context.Background()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
informerFactory, err := populateAndStartInformers(ctx, test.rcs, test.rss, test.services, test.sss)
|
informerFactory, err := populateAndStartInformers(ctx, test.rcs, test.rss, test.services, test.sss)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating informerFactory: %+v", err)
|
t.Errorf("error creating informerFactory: %+v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user