magnusbaeck / logstash-filter-verifier

Apache License 2.0
192 stars 27 forks source link

Use observer pattern for reporting test progress #46

Closed magnusbaeck closed 4 years ago

magnusbaeck commented 7 years ago

Currently, the progress and results of testing is only reported to stdout as user messages, which is fine for human consumption but makes it hard to present the results in a structured way for machine consumption (like CI systems).

Instead of overloading the current code paths with various output formats, let's solve this with the observer pattern so that the core code would report its progress to the zero, one, or more TestResultProcessor pointers (or whatever name we come up with) that it's given upon initialization (based on user options) and let those entities worry about what to echo to the terminal, write to files (and in what format), or process in some other way we haven't thought of yet.

Some observers we'll want to implement early on:

Tetha commented 6 years ago

Moin,

I've done a first simple, ham-fisted iteration over at my fork. I'd like some feedback, especially because I'm no go expert. Feel free to poke me with improvements whenever :)

Overall, I've introduced a package 'reporting' with an interface 'Reporter' and I've mostly tried to push existing informational fmt.Printf-calls into methods of this Reporter interface. Names are open to change. I've also added a QuietReporter because I wasn't sure if I need to worry about the parallel tests being in parallel and then I'd need concurrency and whatever. A /dev/null-reporter does the right thing even in a concurrent case and a very silent mode might be desirable.

There's a few things I'm bumping into by now:

I'd like some feedback especially about the first two parts before I progress here. But from there, most reporting issues should be rather simple to handle even with the minimal API I have from pushing prints around.

magnusbaeck commented 4 years ago

Closed by #74.

@Tetha, I saw your old comment just now. Sorry for not getting back to you with feedback! I'm pretty sure I flagged the notification email when I got it but then it got pushed down by more recent messages and simply disappeared from view.