mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
* 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:
parent
0f7f21a7db
commit
e6a35e8714
7 changed files with 403 additions and 34 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue