Skip to content

Commit 8cc6259

Browse files
Fix Centos7 EOL issue, fixed tests bind host (#1181)
* Try to solve missing centos mirror list * Updated centos images * Changed status check host * Modified bind address for test * Next try * Disabled WordPressAutoInstrumentationTest only on unstable environments * Separate usages of local host IPs for server and client usages --------- Co-authored-by: Sergey Kleyman <[email protected]>
1 parent 477431f commit 8cc6259

17 files changed

+127
-38
lines changed

Diff for: agent/native/ext/ConfigManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ static void initOptionsMetadata( OptionMetadata* optsMeta )
964964
buildBoolOptionMetadata,
965965
astProcessEnabled,
966966
ELASTIC_APM_CFG_OPT_NAME_AST_PROCESS_ENABLED,
967-
/* defaultValue: */ true );
967+
/* defaultValue: */ false );
968968

969969
ELASTIC_APM_INIT_METADATA(
970970
buildBoolOptionMetadata,

Diff for: agent/php/ElasticApm/Impl/Config/AllOptionsMetadata.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function get(): array
8282
/** @var array<string, OptionMetadata<mixed>> $value */
8383
$value = [
8484
OptionNames::API_KEY => new NullableStringOptionMetadata(),
85-
OptionNames::AST_PROCESS_ENABLED => new BoolOptionMetadata(/* defaultValue: */ true),
85+
OptionNames::AST_PROCESS_ENABLED => new BoolOptionMetadata(/* defaultValue: */ false),
8686
OptionNames::AST_PROCESS_DEBUG_DUMP_CONVERTED_BACK_TO_SOURCE
8787
=> new BoolOptionMetadata(/* defaultValue: */ true),
8888
OptionNames::AST_PROCESS_DEBUG_DUMP_FOR_PATH_PREFIX => new NullableStringOptionMetadata(),

Diff for: packaging/Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ tar-install: ## Install the tar installer to run some smoke tests
173173
.PHONY: rpm-install
174174
rpm-install: ## Install the rpm installer to run some smoke tests
175175
@echo "::group::$@" # Helping to group logs in GitHub actions
176-
TYPE=rpm $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1
176+
TYPE=rpm $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
177177
@echo "::endgroup::"
178178

179179
.PHONY: deb-install-in-apache
@@ -206,7 +206,7 @@ deb-install-release-github: ## Install the deb installer from a given release to
206206
.PHONY: rpm-install-release-github
207207
rpm-install-release-github: ## Install the rpm installer from a given release to run some smoke tests
208208
@echo "::group::$@" # Helping to group logs in GitHub actions
209-
VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1
209+
VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
210210
@echo "::endgroup::"
211211

212212
.PHONY: tar-install-release-github
@@ -248,7 +248,7 @@ deb-lifecycle-testing-in-fpm: ## Lifecycle testing for the deb installer with fp
248248
.PHONY: rpm-lifecycle-testing
249249
rpm-lifecycle-testing: ## Lifecycle testing for the rpm installer
250250
@echo "::group::$@" # Helping to group logs in GitHub actions
251-
TYPE=rpm-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1
251+
TYPE=rpm-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
252252
@echo "::endgroup::"
253253

254254
.PHONY: tar-lifecycle-testing
@@ -263,13 +263,13 @@ rpm-php-upgrade-testing: PHP_VERSION=7.2
263263
rpm-php-upgrade-testing: ## PHP upgrade, from 7.2 to 7.4, testing for the rpm installer
264264
@echo "::group::$@" # Helping to group logs in GitHub actions
265265
echo "'$(PHP_VERSION)'"
266-
TYPE=php-upgrade PHP_VERSION=$(PHP_VERSION) PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.2
266+
TYPE=php-upgrade PHP_VERSION=$(PHP_VERSION) PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
267267
@echo "::endgroup::"
268268

269269
.PHONY: rpm-agent-upgrade-testing
270270
rpm-agent-upgrade-testing: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer
271271
@echo "::group::$@" # Helping to group logs in GitHub actions
272-
VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1
272+
VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
273273
@echo "::endgroup::"
274274

275275
.PHONY: deb-agent-upgrade-testing
@@ -281,7 +281,7 @@ deb-agent-upgrade-testing: ## Agent upgrade, from 1.0.0 to the current generated
281281
.PHONY: rpm-agent-upgrade-testing-local
282282
rpm-agent-upgrade-testing-local: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer
283283
@echo "::group::$@" # Helping to group logs in GitHub actions
284-
VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade-local PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1
284+
VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade-local PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
285285
@echo "::endgroup::"
286286

287287
.PHONY: deb-agent-upgrade-testing-local

Diff for: packaging/test/centos/CentOS-Base.repo

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[base]
2+
name=CentOS-$releasever - Base
3+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
4+
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
5+
gpgcheck=1
6+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
7+
8+
#released updates
9+
[updates]
10+
name=CentOS-$releasever - Updates
11+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
12+
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
13+
gpgcheck=1
14+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
15+
16+
#additional packages that may be useful
17+
[extras]
18+
name=CentOS-$releasever - Extras
19+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
20+
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
21+
gpgcheck=1
22+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
23+
24+
#additional packages that extend functionality of existing packages
25+
[centosplus]
26+
name=CentOS-$releasever - Plus
27+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
28+
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
29+
gpgcheck=1
30+
enabled=0
31+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Diff for: packaging/test/centos/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM centos:centos7
22
ARG PHP_VERSION=7.2
33
ENV PHP_VERSION ${PHP_VERSION}
44

5+
COPY CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
6+
57
RUN yum update -y \
68
&& yum install -y \
79
git \

Diff for: packaging/test/docker-compose.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -158,49 +158,49 @@ services:
158158
- PHP_VERSION=7.2
159159

160160
rpm-php83:
161-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.3-0.0.1
161+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.3-0.0.3
162162
build:
163163
context: centos
164164
dockerfile: Dockerfile
165165
args:
166166
- PHP_VERSION=8.3
167167
rpm-php82:
168-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.2-0.0.1
168+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.2-0.0.3
169169
build:
170170
context: centos
171171
dockerfile: Dockerfile
172172
args:
173173
- PHP_VERSION=8.2
174174
rpm-php81:
175-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.1-0.0.1
175+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.1-0.0.3
176176
build:
177177
context: centos
178178
dockerfile: Dockerfile
179179
args:
180180
- PHP_VERSION=8.1
181181
rpm-php80:
182-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.0-0.0.1
182+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.0-0.0.3
183183
build:
184184
context: centos
185185
dockerfile: Dockerfile
186186
args:
187187
- PHP_VERSION=8.0
188188
rpm-php74:
189-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.4-0.0.1
189+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.4-0.0.3
190190
build:
191191
context: centos
192192
dockerfile: Dockerfile
193193
args:
194194
- PHP_VERSION=7.4
195195
rpm-php73:
196-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.3-0.0.1
196+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.3-0.0.3
197197
build:
198198
context: centos
199199
dockerfile: Dockerfile
200200
args:
201201
- PHP_VERSION=7.3
202202
rpm-php72:
203-
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.2-0.0.2
203+
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.2-0.0.3
204204
build:
205205
context: centos
206206
dockerfile: Dockerfile

Diff for: tests/ElasticApmTests/ComponentTests/CurlAutoInstrumentationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function appCodeClient(MixedMap $appCodeArgs): void
6565
$curlHandle = null;
6666
try {
6767
$curlHandle = HttpClientUtilForTests::createCurlHandleToSendRequestToAppCode(
68-
(new UrlParts())->host(HttpServerHandle::DEFAULT_HOST)->port($serverPort),
68+
(new UrlParts())->host(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS)->port($serverPort),
6969
$dataPerRequest,
7070
self::buildResourcesClientForAppCode()
7171
);

Diff for: tests/ElasticApmTests/ComponentTests/HttpTransactionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ function (HttpAppCodeRequestParams $appCodeRequestParams) use ($httpMethod, &$ex
8686
self::assertNotNull($tx->context->request);
8787
self::assertSame($httpMethod, $tx->context->request->method);
8888
self::assertNotNull($tx->context->request->url);
89-
self::assertSame(HttpServerHandle::DEFAULT_HOST, $tx->context->request->url->domain);
89+
self::assertSame(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS, $tx->context->request->url->domain);
9090
self::assertNotNull($expectedUrlParts->port);
9191
$expectedFullUrl
92-
= $expectedUrlParts->scheme . '://' . HttpServerHandle::DEFAULT_HOST . ':' . $expectedUrlParts->port . '/';
92+
= $expectedUrlParts->scheme . '://' . HttpServerHandle::CLIENT_LOCALHOST_ADDRESS . ':' . $expectedUrlParts->port . '/';
9393
self::assertSame($expectedFullUrl, $tx->context->request->url->full);
9494
self::assertSame($expectedFullUrl, $tx->context->request->url->original);
9595
self::assertSame($expectedUrlParts->scheme, $tx->context->request->url->protocol);

Diff for: tests/ElasticApmTests/ComponentTests/Util/BuiltinHttpServerAppCodeHostStarter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function buildCommandLine(array $ports): string
7474
{
7575
Assert::assertCount(1, $ports);
7676
return InfraUtilForTests::buildAppCodePhpCmd($this->agentConfigSourceBuilder->getPhpIniFile())
77-
. " -S 0.0.0.0:" . $ports[0]
77+
. ' -S ' . HttpServerHandle::SERVER_LOCALHOST_ADDRESS . ':' . $ports[0]
7878
. ' "' . FileUtilForTests::listToPath([__DIR__, self::APP_CODE_HOST_ROUTER_SCRIPT]) . '"';
7979
}
8080

Diff for: tests/ElasticApmTests/ComponentTests/Util/ComponentTestCaseBase.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
namespace ElasticApmTests\ComponentTests\Util;
2525

2626
use Elastic\Apm\Impl\AutoInstrument\AutoInstrumentationBase;
27+
use Elastic\Apm\Impl\Config\AllOptionsMetadata;
2728
use Elastic\Apm\Impl\Config\OptionNames;
2829
use Elastic\Apm\Impl\GlobalTracerHolder;
2930
use Elastic\Apm\Impl\Log\Level as LogLevel;
@@ -197,7 +198,9 @@ protected static function implTestIsAutoInstrumentationEnabled(string $instrClas
197198
$actualNames = $instr->keywords();
198199
$actualNames[] = $instr->name();
199200
self::assertEqualAsSets($expectedNames, $actualNames);
200-
self::assertTrue($instr->isEnabled());
201+
$astProcessEnabledDefaultValue = AllOptionsMetadata::get()[OptionNames::AST_PROCESS_ENABLED]->defaultValue();
202+
$isEnabledByDefault = $astProcessEnabledDefaultValue || (!$instr->requiresUserlandCodeInstrumentation());
203+
self::assertSame($isEnabledByDefault, $instr->isEnabled());
201204

202205
/**
203206
* @param string $name
@@ -238,17 +241,17 @@ protected static function implTestIsAutoInstrumentationEnabled(string $instrClas
238241
$dbgCtx->clearCurrentSubScope(['disableInstrumentationsOptVal' => $disableInstrumentationsOptVal]);
239242
$tracer = self::buildTracerForTests()->withConfig(OptionNames::DISABLE_INSTRUMENTATIONS, $disableInstrumentationsOptVal)->build();
240243
$instr = new $instrClassName($tracer);
241-
self::assertTrue($instr->isEnabled());
244+
self::assertSame($isEnabledByDefault, $instr->isEnabled());
242245
}
243246
$dbgCtx->popSubScope();
244247

245248
$dbgCtx->pushSubScope();
246249
foreach ([true, false] as $astProcessEnabled) {
247250
$dbgCtx->clearCurrentSubScope(['astProcessEnabled' => $astProcessEnabled]);
248-
$expectedIsEnabled = $astProcessEnabled || (!$instr->requiresUserlandCodeInstrumentation());
251+
$isEnabledByDefault = $astProcessEnabled || (!$instr->requiresUserlandCodeInstrumentation());
249252
$tracer = self::buildTracerForTests()->withConfig(OptionNames::AST_PROCESS_ENABLED, BoolUtil::toString($astProcessEnabled))->build();
250253
$instr = new $instrClassName($tracer);
251-
self::assertSame($expectedIsEnabled, $instr->isEnabled());
254+
self::assertSame($isEnabledByDefault, $instr->isEnabled());
252255
}
253256
$dbgCtx->popSubScope();
254257
}

Diff for: tests/ElasticApmTests/ComponentTests/Util/HttpAppCodeRequestParams.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(HttpServerHandle $httpServerHandle, AppCodeTarget $a
4242

4343
$this->urlParts = new UrlParts();
4444
$this->urlParts->scheme('http')
45-
->host(HttpServerHandle::DEFAULT_HOST)
45+
->host(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS)
4646
->port($httpServerHandle->getMainPort())
4747
->path('/');
4848
}

Diff for: tests/ElasticApmTests/ComponentTests/Util/HttpServerHandle.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class HttpServerHandle implements LoggableInterface
3838
{
3939
use LoggableTrait;
4040

41-
public const DEFAULT_HOST = '127.0.0.1';
41+
public const CLIENT_LOCALHOST_ADDRESS = '127.0.0.1';
42+
public const SERVER_LOCALHOST_ADDRESS = self::CLIENT_LOCALHOST_ADDRESS;
4243
public const STATUS_CHECK_URI_PATH = '/elastic_apm_php_tests_status_check';
4344
public const PID_KEY = 'pid';
4445

Diff for: tests/ElasticApmTests/ComponentTests/Util/HttpServerStarter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function () use ($port, $dataPerRequest, $logger, &$lastThrown, &$pid) {
223223
try {
224224
$response = HttpClientUtilForTests::sendRequest(
225225
HttpConstantsForTests::METHOD_GET,
226-
(new UrlParts())->host(HttpServerHandle::DEFAULT_HOST)
226+
(new UrlParts())->host(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS)
227227
->port($port)
228228
->path(HttpServerHandle::STATUS_CHECK_URI_PATH),
229229
$dataPerRequest

Diff for: tests/ElasticApmTests/ComponentTests/Util/TestCaseHandle.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ private function setMandatoryOptions(AppCodeHostParams $params): void
214214
$escalatedLogLevelForProdCodeAsString = LogLevel::intToName($this->escalatedLogLevelForProdCode);
215215
$params->setAgentOption(AmbientContextForTests::testConfig()->escalatedRerunsProdCodeLogLevelOptionName ?? OptionNames::LOG_LEVEL_SYSLOG, $escalatedLogLevelForProdCodeAsString);
216216
}
217-
$params->setAgentOption(OptionNames::SERVER_URL, 'http://localhost:' . $this->mockApmServer->getPortForAgent());
217+
/** @noinspection HttpUrlsUsage */
218+
$params->setAgentOption(OptionNames::SERVER_URL, 'http://' . HttpServerHandle::CLIENT_LOCALHOST_ADDRESS . ':' . $this->mockApmServer->getPortForAgent());
218219

219220
if (!$this->isTestSpanCompressionCompatible) {
220221
$params->setAgentOption(OptionNames::SPAN_COMPRESSION_ENABLED, false);

Diff for: tests/ElasticApmTests/ComponentTests/Util/TestInfraHttpServerProcessBase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private function runHttpServer(): void
167167
$this->reactLoop = Loop::get();
168168
TestCase::assertNotEmpty(AmbientContextForTests::testConfig()->dataPerProcess->thisServerPorts);
169169
foreach (AmbientContextForTests::testConfig()->dataPerProcess->thisServerPorts as $port) {
170-
$uri = HttpServerHandle::DEFAULT_HOST . ':' . $port;
170+
$uri = HttpServerHandle::SERVER_LOCALHOST_ADDRESS . ':' . $port;
171171
$serverSocket = new SocketServer($uri, /* context */ [], $this->reactLoop);
172172
$socketIndex = count($this->serverSockets);
173173
$this->serverSockets[] = $serverSocket;

0 commit comments

Comments
 (0)