-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in the JS VM cache (#4074)
Signed-off-by: Simon Plourde <[email protected]>
- Loading branch information
Simon Plourde
authored
Oct 27, 2020
1 parent
4d5b16a
commit 62478c4
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package js | ||
|
||
import ( | ||
"testing" | ||
|
||
corev2 "github.com/sensu/sensu-go/api/core/v2" | ||
"github.com/sensu/sensu-go/types/dynamic" | ||
) | ||
|
||
// This is a unit test to cover the race condition found in | ||
// https://github.com/sensu/sensu-go/issues/4073 | ||
func TestEvaluateRaceCondition(t *testing.T) { | ||
entity := corev2.FixtureEntity("foo") | ||
synth := dynamic.Synthesize(entity) | ||
params := map[string]interface{}{"entity": synth} | ||
|
||
go func() { | ||
_, _ = Evaluate("true", params, nil) | ||
}() | ||
go func() { | ||
_, _ = Evaluate("true", params, nil) | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters