grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

Expose the underlying channel from testutils.Channel

Open easwars opened this issue 3 years ago • 11 comments

testutils.Channel provides a useful timed receive operation for tests.

There are some tests though where access to the underlying channel is required, because it is passed to some other component which receives on the channel. For example: readyCh in this test.

It would be nice to expose this underlying channel for tests that really need it. Something along the lines of timer.C would suffice.

easwars avatar Aug 10 '21 23:08 easwars

/assign

jackwener avatar Aug 14 '21 04:08 jackwener

Hi, I willing to take this task up.

jackwener avatar Aug 14 '21 04:08 jackwener

Thanks.

easwars avatar Aug 16 '21 18:08 easwars

I'm not sure whether I got the right point of issue. In order to expose the underlying channel, Is it enough that modify [ch](ch chan interface{}) into Ch? I think that I may not understand correctly. Maybe I need some tips, thanks.

jackwener avatar Aug 17 '21 08:08 jackwener

Yes, rename ch to C and add a comment, something to this effect

// C is the underlying channel on which values sent using the SendXxx() methods are delivered.
// Tests which cannot use ReceiveXxx() for whatever reasons can use C to read the values.

And also try to change the example test which I pointed to in the original description.

Hope this helps.

easwars avatar Aug 17 '21 17:08 easwars

And also try to change the example test which I pointed to in the original description.

The test should be changed, but it will be easy for me if the instruction and problem about test file is more clear.

jackwener avatar Aug 19 '21 05:08 jackwener

Maybe I get the point. because underlying channel is't exposed, there aren't some tests.

https://github.com/grpc/grpc-go/blob/997ce619eb555b6a481e741afa6390ad3cd80d5c/xds/internal/server/listener_wrapper_test.go#L212

change into lw, readyCh, xdsC, lis, cleanup := newListenerWrapper(t)

And I should add some tests about underlying channel in xdsC and lis.

jackwener avatar Aug 20 '21 18:08 jackwener

Will be picking this one up once #4779 is resolved

uds5501 avatar Oct 15 '21 11:10 uds5501

It would be nice to expose this underlying channel for tests that really need it. Something along the lines of timer.C would suffice.

@easwars I have a question regarding this, changing readyCh is kind of confusing here. readyCh is essentially a <- chan struct{} which is triggered from goodUpdate.Done() method.

Am I supposed to change Event struct in grpcsync package from

type Event struct {
	fired int32
	c     chan struct{}
	o     sync.Once
}

to

type Event struct {
	fired int32
	c     testutils.Channel{}
	o     sync.Once
}

A little guidance would be lovely, thank you!

uds5501 avatar Oct 15 '21 14:10 uds5501

hi @dfawley @easwars , is this issue still relevant?

Aditya-Sood avatar May 05 '23 18:05 Aditya-Sood

@Aditya-Sood Yes, this is still relevant, but very low priority. I replied on your other PR about some additional changes that we require on the xDS client and config_selector. That work is higher priority and definitely more interesting than this one.

easwars avatar May 05 '23 18:05 easwars

hi @easwars, shall I pick this up now?

Aditya-Sood avatar Aug 20 '23 16:08 Aditya-Sood

Sure, the other one with the LRS loads would be higher priority for sure. I'll let you pick which one you want to work on.

easwars avatar Aug 21 '23 21:08 easwars

sure I'll start with the LRS issue first and then work on this

Aditya-Sood avatar Aug 23 '23 04:08 Aditya-Sood