Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a LogObserver() function to Member interface #18519

Open
clement2026 opened this issue Aug 31, 2024 · 2 comments
Open

Add a LogObserver() function to Member interface #18519

clement2026 opened this issue Aug 31, 2024 · 2 comments
Assignees
Labels
area/observability area/testing priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. type/feature

Comments

@clement2026
Copy link
Contributor

What would you like to be added?

Add a LogObserver() function to Member interface.

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

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.

type Member struct {
config.ServerConfig
UniqNumber int
MemberNumber int
Port string
PeerListeners, ClientListeners []net.Listener
GRPCListener net.Listener
// PeerTLSInfo enables peer TLS when set
PeerTLSInfo *transport.TLSInfo
// ClientTLSInfo enables client TLS when set
ClientTLSInfo *transport.TLSInfo
DialOptions []grpc.DialOption
RaftHandler *testutil.PauseableHandler
Server *etcdserver.EtcdServer
ServerClosers []func()
GRPCServerOpts []grpc.ServerOption
GRPCServer *grpc.Server
GRPCURL string
GRPCBridge *bridge
// ServerClient is a clientv3 that directly calls the etcdserver.
ServerClient *clientv3.Client
// Client is a clientv3 that communicates via socket, either UNIX or TCP.
Client *clientv3.Client
KeepDataDirTerminate bool
ClientMaxCallSendMsgSize int
ClientMaxCallRecvMsgSize int
UseIP bool
UseBridge bool
UseTCP bool
IsLearner bool
Closed bool
GRPCServerRecorder *grpctesting.GRPCRecorder
LogObserver *testutils.LogObserver
}

type EtcdProcess interface {
EndpointsGRPC() []string
EndpointsHTTP() []string
EndpointsMetrics() []string
Etcdctl(opts ...config.ClientOption) *EtcdctlV3
IsRunning() bool
Wait(ctx context.Context) error
Start(ctx context.Context) error
Restart(ctx context.Context) error
Stop() error
Close() error
Config() *EtcdServerProcessConfig
PeerProxy() proxy.Server
Failpoints() *BinaryFailpoints
LazyFS() *LazyFS
Logs() LogsExpect
Kill() error
}
type LogsExpect interface {
ExpectWithContext(context.Context, expect.ExpectedResponse) (string, error)
Lines() []string
LineCount() int
}

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
Copy link

/assign

@serathius
Copy link
Member

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.

@jmhbnz jmhbnz added priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. area/testing area/observability labels Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/observability area/testing priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. type/feature
Development

No branches or pull requests

4 participants