-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): Enable opcache by default for the integration runner. (#752
) * Enable the opcache.so extension by default in the integration_runner * Ensure the opcache INI settings in the integration_runner environment are enabled (these can be overwritten in the test case INI section if needing to test without opcache) * Added few tests to ensure compatibility with opcache disabled and to demonstrate how to overwrite the value. --------- Co-authored-by: ZNeumann <[email protected]> Co-authored-by: Zach Neumann <[email protected]> Co-authored-by: Michal Nowacki <[email protected]>
- Loading branch information
1 parent
958d859
commit 55d3904
Showing
28 changed files
with
3,575 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* Test should not run with opache */ | ||
if (extension_loaded('Zend OPcache')) { | ||
if (false != opcache_get_status()) { | ||
die("fail: OPcache enabled but needs to be disabled\n"); | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* Opcache only supported with PHP 7+ */ | ||
if (version_compare(PHP_VERSION, "7.1", "<")) { | ||
die("skip: PHP < 7.1 not supported\n"); | ||
} |
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,75 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
Transaction event created and no errors despite creating spans | ||
for a HUGE number of calls. | ||
*/ | ||
|
||
/*SKIPIF | ||
<?php | ||
require('skipif.inc'); | ||
*/ | ||
|
||
/*INI | ||
newrelic.distributed_tracing_enabled=1 | ||
newrelic.transaction_tracer.threshold = 0 | ||
error_reporting = E_ALL | ||
opcache.enable=0 | ||
opcache.enable_cli=0 | ||
opcache.file_update_protection=0 | ||
opcache.jit_buffer_size=32M | ||
opcache.jit=function | ||
*/ | ||
|
||
/*EXPECT_ANALYTICS_EVENTS | ||
[ | ||
"?? agent run id", | ||
{ | ||
"reservoir_size": 50, | ||
"events_seen": 1 | ||
}, | ||
[ | ||
[ | ||
{ | ||
"traceId": "??", | ||
"duration": "??", | ||
"timestamp": "??", | ||
"type": "Transaction", | ||
"name": "OtherTransaction\/php__FILE__", | ||
"guid": "??", | ||
"priority": "??", | ||
"sampled": true, | ||
"totalTime": "??", | ||
"error": false | ||
}, | ||
{}, | ||
{} | ||
] | ||
] | ||
] | ||
*/ | ||
|
||
|
||
/*EXPECT | ||
Hello | ||
*/ | ||
require('opcache_test.inc'); | ||
|
||
newrelic_add_custom_tracer('computation'); | ||
|
||
function computation(float $a): int | ||
{ | ||
|
||
$b = intval($a) % (2 ** 32); | ||
return $b; | ||
} | ||
|
||
for ($i = 0; $i < 500; ++$i) { | ||
computation(2**64); | ||
} | ||
echo 'Hello'; |
81 changes: 81 additions & 0 deletions
81
tests/integration/opcache/disabled/test_even_odd_count.php
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,81 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
Transaction event generated with JIT enabled even when doing lots of loops. | ||
*/ | ||
|
||
/*SKIPIF | ||
<?php | ||
require('skipif.inc'); | ||
*/ | ||
|
||
/*INI | ||
newrelic.distributed_tracing_enabled=1 | ||
newrelic.transaction_tracer.threshold = 0 | ||
newrelic.cross_application_tracer.enabled = false | ||
error_reporting = E_ALL | ||
opcache.enable=0 | ||
opcache.enable_cli=0 | ||
opcache.file_update_protection=0 | ||
opcache.jit_buffer_size=32M | ||
opcache.jit=function | ||
*/ | ||
|
||
/*EXPECT_ERROR_EVENTS null */ | ||
|
||
/*EXPECT_ANALYTICS_EVENTS | ||
[ | ||
"?? agent run id", | ||
{ | ||
"reservoir_size": 50, | ||
"events_seen": 1 | ||
}, | ||
[ | ||
[ | ||
{ | ||
"traceId": "??", | ||
"duration": "??", | ||
"timestamp": "??", | ||
"type": "Transaction", | ||
"name": "OtherTransaction\/php__FILE__", | ||
"guid": "??", | ||
"priority": "??", | ||
"sampled": true, | ||
"totalTime": "??", | ||
"error": false | ||
}, | ||
{}, | ||
{} | ||
] | ||
] | ||
] | ||
*/ | ||
|
||
/*EXPECT | ||
5000 | ||
*/ | ||
require('opcache_test.inc'); | ||
|
||
|
||
function even(int $a): bool { | ||
if ($a == 1) { | ||
return false; | ||
} else if (($a % 2) == 0) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
$count = 0; | ||
for ($i = 1; $i <= 10000; $i++) | ||
{ | ||
if (even($i)) $count++; | ||
} | ||
echo "$count"; | ||
|
52 changes: 52 additions & 0 deletions
52
tests/integration/opcache/disabled/test_recursion_no_segfault.php
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,52 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
JIT enabled, should still instrument without crashing. | ||
Previous tests would invariably cause a segfault when | ||
recursively finding the 10th fibonacci number. | ||
*/ | ||
|
||
/*SKIPIF | ||
<?php | ||
require('skipif.inc'); | ||
*/ | ||
|
||
/*INI | ||
error_reporting = E_ALL | ||
newrelic.distributed_tracing_enabled=1 | ||
newrelic.transaction_tracer.threshold = 0 | ||
newrelic.cross_application_tracer.enabled = false | ||
opcache.enable=0 | ||
opcache.enable_cli=0 | ||
opcache.file_update_protection=0 | ||
opcache.jit_buffer_size=32M | ||
opcache.jit=function | ||
*/ | ||
|
||
/*EXPECT_ERROR_EVENTS | ||
null | ||
*/ | ||
|
||
/*EXPECT | ||
89 | ||
*/ | ||
require('opcache_test.inc'); | ||
|
||
newrelic_add_custom_tracer('fibonacci'); | ||
|
||
|
||
function fibonacci($n){ | ||
return(($n < 2) ? 1 : fibonacci($n - 2) + fibonacci($n - 1)); | ||
} | ||
|
||
$n = 10; /* Get the nth Fibonacci number. */ | ||
|
||
$fibonacci = fibonacci($n); | ||
echo $fibonacci; | ||
|
Oops, something went wrong.