Skip to content

Commit

Permalink
chore: add testing for k8s informer panic (#8810)
Browse files Browse the repository at this point in the history
  • Loading branch information
eecsliu authored Feb 7, 2024
1 parent a35696d commit 3805ebd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions master/internal/rm/kubernetesrm/informer_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (

"github.com/pkg/errors"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
k8sV1 "k8s.io/api/core/v1"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
Expand Down Expand Up @@ -302,6 +304,22 @@ func TestEventListener(t *testing.T) {
}
}

// TestInformerPanic tests that we panic on unexpected retryWatcher channel close.
func TestInformerPanic(t *testing.T) {
ctx := context.TODO()
eventChan := make(chan watch.Event)

i := informer{
syslog: logrus.WithField("component", "panicInformer"),
resultChan: eventChan,
}

close(eventChan)
require.Panics(t, func() {
i.run(ctx)
})
}

// Methods for mockWatcher.
func (m *mockWatcher) Stop() {
close(m.c)
Expand Down

0 comments on commit 3805ebd

Please sign in to comment.