Improve plugins grouping (alternative to #1424) (#1437)

* Fix races in test (#1446)

Co-authored-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Co-authored-by: alteredCoder <kevin@crowdsec.net>
Co-authored-by: AlteredCoder <64792091+AlteredCoder@users.noreply.github.com>
This commit is contained in:
Thibault "bui" Koechlin 2022-04-19 19:12:23 +02:00 committed by GitHub
parent 0f7f21a7db
commit e6a35e8714
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 403 additions and 34 deletions

View file

@ -21,9 +21,11 @@ func resetTestTomb(testTomb *tomb.Tomb) {
}
func resetWatcherAlertCounter(pw *PluginWatcher) {
for k := range pw.AlertCountByPluginName {
pw.AlertCountByPluginName[k] = 0
pw.AlertCountByPluginName.Lock()
for k := range pw.AlertCountByPluginName.data {
pw.AlertCountByPluginName.data[k] = 0
}
pw.AlertCountByPluginName.Unlock()
}
func insertNAlertsToPlugin(pw *PluginWatcher, n int, pluginName string) {
@ -34,7 +36,8 @@ func insertNAlertsToPlugin(pw *PluginWatcher, n int, pluginName string) {
func listenChannelWithTimeout(ctx context.Context, channel chan string) error {
select {
case <-channel:
case x := <-channel:
log.Printf("received -> %v", x)
case <-ctx.Done():
return ctx.Err()
}