mirror of https://github.com/linkerd/linkerd2.git
destination: Fix flakey TestEndpointProfileTranslator (#12182)
TestEndpointProfileTranslator could race against the consumer task so that the final queue insertion would not necessarily fail. The send buffer has been eliminated to avoid this race.
This commit is contained in:
parent
c831361062
commit
e1ab0a2e46
|
|
@ -110,6 +110,10 @@ func (ept *endpointProfileTranslator) Update(address *watcher.Address) error {
|
|||
}
|
||||
}
|
||||
|
||||
func (ept *endpointProfileTranslator) queueLen() int {
|
||||
return len(ept.updates)
|
||||
}
|
||||
|
||||
func (ept *endpointProfileTranslator) update(address *watcher.Address) {
|
||||
var opaquePorts map[uint32]struct{}
|
||||
if address.Pod != nil {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func TestEndpointProfileTranslator(t *testing.T) {
|
|||
|
||||
t.Run("Sends update", func(t *testing.T) {
|
||||
mockGetProfileServer := &mockDestinationGetProfileServer{
|
||||
profilesReceived: make(chan *pb.DestinationProfile, 1),
|
||||
profilesReceived: make(chan *pb.DestinationProfile), // UNBUFFERED
|
||||
}
|
||||
log := logging.WithField("test", t.Name())
|
||||
translator := newEndpointProfileTranslator(
|
||||
|
|
@ -110,9 +110,13 @@ func TestEndpointProfileTranslator(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// The queue should be full and the next update should fail.
|
||||
t.Logf("Queue length=%d capacity=%d", translator.queueLen(), updateQueueCapacity)
|
||||
if err := translator.Update(podAddr); err == nil {
|
||||
t.Fatal("Expected update to fail")
|
||||
t.Fatalf("Expected update to fail; queue=%d; capacity=%d", translator.queueLen(), updateQueueCapacity)
|
||||
|
||||
}
|
||||
|
||||
select {
|
||||
case <-endStream:
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue