-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SpanCaptureReporter test spillage (#22)
* Discard spans started before `attach/0` was called * Trigger `report/2` and wait 1ms before `collect/0` * Set and advise `send_interval_ms: 100` to reduce unpredictability of `report/2` time, which with `send_interval_ms: 1` would sometimes wait until after `detach/0`
- Loading branch information
Garth Kidd
committed
Aug 3, 2019
1 parent
221c58f
commit 3af2473
Showing
4 changed files
with
84 additions
and
8 deletions.
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
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
43 changes: 43 additions & 0 deletions
43
test/opencensus_test_support_span_capture_reporter_test.exs
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,43 @@ | ||
defmodule Opencensus.TestSupport.SpanCaptureReporterTest do | ||
use ExUnit.Case, async: false | ||
import Opencensus.Trace | ||
|
||
alias Opencensus.TestSupport.SpanCaptureReporter | ||
|
||
describe "Opencensus.TestSupport.SpanCaptureReporter.collect/3" do | ||
defp loop_count do | ||
case System.get_env("CI") do | ||
nil -> 10 | ||
_ -> 1000 | ||
end | ||
end | ||
|
||
test "before detach, gets the just-finished span" do | ||
for _ <- 1..loop_count() do | ||
SpanCaptureReporter.attach() | ||
|
||
with_child_span "inner" do | ||
[0, 1, 1, 2, 2, 2, 2, 3, 3, 4] |> Enum.random() |> :timer.sleep() | ||
:... | ||
end | ||
|
||
assert SpanCaptureReporter.collect() |> length() == 1 | ||
SpanCaptureReporter.detach() | ||
end | ||
end | ||
|
||
test "after detach, gets the just-finished span" do | ||
for _ <- 1..loop_count() do | ||
SpanCaptureReporter.attach() | ||
|
||
with_child_span "inner" do | ||
[0, 1, 1, 2, 2, 2, 2, 3, 3, 4] |> Enum.random() |> :timer.sleep() | ||
:... | ||
end | ||
|
||
SpanCaptureReporter.detach() | ||
assert SpanCaptureReporter.collect() |> length() == 1 | ||
end | ||
end | ||
end | ||
end |