etcd-io / etcd

Distributed reliable key-value store for the most critical data of a distributed system
https://etcd.io
Apache License 2.0
47.38k stars 9.72k forks source link

Add a `LogObserver()` function to `Member` interface #18519

Open clement2026 opened 2 weeks ago

clement2026 commented 2 weeks ago

What would you like to be added?

Add a LogObserver() function to Member interface.

https://github.com/etcd-io/etcd/blob/4bb9392289623e8bf05916281bd696fbbe42fd4d/tests/framework/interfaces/interface.go#L39-L43

It may look something like this:

 type Member interface { 
    Client() Client 
    Start(ctx context.Context) error 
    Stop() 
        LogObserver()  LogObserver         <<< here
 } 

Why is this needed?

I was writing a test that waits for events by watching logs. Then I noticed both e2e test and integration test have their own log observer implementations.

https://github.com/etcd-io/etcd/blob/4bb9392289623e8bf05916281bd696fbbe42fd4d/tests/framework/integration/cluster.go#L549-L589

https://github.com/etcd-io/etcd/blob/4bb9392289623e8bf05916281bd696fbbe42fd4d/tests/framework/e2e/etcd_process.go#L45-L69

Would it be a good idea to add a LogObserver() function to Member interface? This way, I can rewrite the test to work for both e2e and integration tests.

anishbista60 commented 2 weeks ago

/assign

serathius commented 1 week ago

I don't think it will be easy as for integration tests you cannot easily collect logs. You need inject a logger that does it for you.