Skip to content

Commit ca63ac5

Browse files
lavarouhahuja2
authored andcommitted
tests: make tests deterministic (#1087)
Force non-zero duration of helper user function. When tests execute fast enough, the helper function's segment start time and end time are equal and this causes the segment to be dropped. To address this test instability, non-zero duration is forced on test helper user functions. This is a follow up to #781.
1 parent 1b17d22 commit ca63ac5

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

tests/integration/jit/function/test_span_class_function.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
newrelic_add_custom_tracer('Classname::functionName');
208208
function main()
209209
{
210+
time_nanosleep(0, 50000); // force non-zero duration for the segment not to be dropped.
210211
echo 'Hello';
211212
}
212213
main();

tests/integration/jit/tracing/test_span_class_function.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
newrelic_add_custom_tracer('Classname::functionName');
207207
function main()
208208
{
209+
time_nanosleep(0, 50000); // force non-zero duration for the segment not to be dropped.
209210
echo 'Hello';
210211
}
211212
main();

tests/integration/lang/trampoline/test_trampoline_02.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@
7777
$anon = new class() {
7878
function execute()
7979
{
80+
time_nanosleep(0, 50000); // force non-zero duration for the segment not to be dropped.
8081
new ReflectionClass('Wrapper');
8182
}
8283
};
8384

8485
$anon2 = new class() {
8586
function execute()
8687
{
88+
time_nanosleep(0, 50000); // force non-zero duration for the segment not to be dropped.
8789
new ReflectionClass('Wrapper');
8890
}
8991
};

tests/integration/opcache/disabled/test_span_class_function.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
newrelic_add_custom_tracer('Classname::functionName');
209209
function main()
210210
{
211+
time_nanosleep(0, 50000); // force non-zero duration for the segment not to be dropped.
211212
echo 'Hello';
212213
}
213214
main();

0 commit comments

Comments
 (0)