Skip to content

Commit

Permalink
Fix Centos7 EOL issue, fixed tests bind host (#1181)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
intuibase and SergeyKleyman authored Jul 22, 2024
1 parent 477431f commit 8cc6259
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 38 deletions.
2 changes: 1 addition & 1 deletion agent/native/ext/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ static void initOptionsMetadata( OptionMetadata* optsMeta )
buildBoolOptionMetadata,
astProcessEnabled,
ELASTIC_APM_CFG_OPT_NAME_AST_PROCESS_ENABLED,
/* defaultValue: */ true );
/* defaultValue: */ false );

ELASTIC_APM_INIT_METADATA(
buildBoolOptionMetadata,
Expand Down
2 changes: 1 addition & 1 deletion agent/php/ElasticApm/Impl/Config/AllOptionsMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function get(): array
/** @var array<string, OptionMetadata<mixed>> $value */
$value = [
OptionNames::API_KEY => new NullableStringOptionMetadata(),
OptionNames::AST_PROCESS_ENABLED => new BoolOptionMetadata(/* defaultValue: */ true),
OptionNames::AST_PROCESS_ENABLED => new BoolOptionMetadata(/* defaultValue: */ false),
OptionNames::AST_PROCESS_DEBUG_DUMP_CONVERTED_BACK_TO_SOURCE
=> new BoolOptionMetadata(/* defaultValue: */ true),
OptionNames::AST_PROCESS_DEBUG_DUMP_FOR_PATH_PREFIX => new NullableStringOptionMetadata(),
Expand Down
12 changes: 6 additions & 6 deletions packaging/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ tar-install: ## Install the tar installer to run some smoke tests
.PHONY: rpm-install
rpm-install: ## Install the rpm installer to run some smoke tests
@echo "::group::$@" # Helping to group logs in GitHub actions
TYPE=rpm $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1
TYPE=rpm $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.3
@echo "::endgroup::"

.PHONY: deb-install-in-apache
Expand Down Expand Up @@ -206,7 +206,7 @@ deb-install-release-github: ## Install the deb installer from a given release to
.PHONY: rpm-install-release-github
rpm-install-release-github: ## Install the rpm installer from a given release to run some smoke tests
@echo "::group::$@" # Helping to group logs in GitHub actions
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
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
@echo "::endgroup::"

.PHONY: tar-install-release-github
Expand Down Expand Up @@ -248,7 +248,7 @@ deb-lifecycle-testing-in-fpm: ## Lifecycle testing for the deb installer with fp
.PHONY: rpm-lifecycle-testing
rpm-lifecycle-testing: ## Lifecycle testing for the rpm installer
@echo "::group::$@" # Helping to group logs in GitHub actions
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
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
@echo "::endgroup::"

.PHONY: tar-lifecycle-testing
Expand All @@ -263,13 +263,13 @@ rpm-php-upgrade-testing: PHP_VERSION=7.2
rpm-php-upgrade-testing: ## PHP upgrade, from 7.2 to 7.4, testing for the rpm installer
@echo "::group::$@" # Helping to group logs in GitHub actions
echo "'$(PHP_VERSION)'"
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
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
@echo "::endgroup::"

.PHONY: rpm-agent-upgrade-testing
rpm-agent-upgrade-testing: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer
@echo "::group::$@" # Helping to group logs in GitHub actions
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
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
@echo "::endgroup::"

.PHONY: deb-agent-upgrade-testing
Expand All @@ -281,7 +281,7 @@ deb-agent-upgrade-testing: ## Agent upgrade, from 1.0.0 to the current generated
.PHONY: rpm-agent-upgrade-testing-local
rpm-agent-upgrade-testing-local: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer
@echo "::group::$@" # Helping to group logs in GitHub actions
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
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
@echo "::endgroup::"

.PHONY: deb-agent-upgrade-testing-local
Expand Down
31 changes: 31 additions & 0 deletions packaging/test/centos/CentOS-Base.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
2 changes: 2 additions & 0 deletions packaging/test/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM centos:centos7
ARG PHP_VERSION=7.2
ENV PHP_VERSION ${PHP_VERSION}

COPY CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo

RUN yum update -y \
&& yum install -y \
git \
Expand Down
14 changes: 7 additions & 7 deletions packaging/test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,49 +158,49 @@ services:
- PHP_VERSION=7.2

rpm-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.3-0.0.1
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.3-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=8.3
rpm-php82:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.2-0.0.1
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.2-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=8.2
rpm-php81:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.1-0.0.1
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.1-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=8.1
rpm-php80:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.0-0.0.1
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.0-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=8.0
rpm-php74:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.4-0.0.1
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.4-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=7.4
rpm-php73:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.3-0.0.1
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.3-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=7.3
rpm-php72:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.2-0.0.2
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.2-0.0.3
build:
context: centos
dockerfile: Dockerfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function appCodeClient(MixedMap $appCodeArgs): void
$curlHandle = null;
try {
$curlHandle = HttpClientUtilForTests::createCurlHandleToSendRequestToAppCode(
(new UrlParts())->host(HttpServerHandle::DEFAULT_HOST)->port($serverPort),
(new UrlParts())->host(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS)->port($serverPort),
$dataPerRequest,
self::buildResourcesClientForAppCode()
);
Expand Down
4 changes: 2 additions & 2 deletions tests/ElasticApmTests/ComponentTests/HttpTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ function (HttpAppCodeRequestParams $appCodeRequestParams) use ($httpMethod, &$ex
self::assertNotNull($tx->context->request);
self::assertSame($httpMethod, $tx->context->request->method);
self::assertNotNull($tx->context->request->url);
self::assertSame(HttpServerHandle::DEFAULT_HOST, $tx->context->request->url->domain);
self::assertSame(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS, $tx->context->request->url->domain);
self::assertNotNull($expectedUrlParts->port);
$expectedFullUrl
= $expectedUrlParts->scheme . '://' . HttpServerHandle::DEFAULT_HOST . ':' . $expectedUrlParts->port . '/';
= $expectedUrlParts->scheme . '://' . HttpServerHandle::CLIENT_LOCALHOST_ADDRESS . ':' . $expectedUrlParts->port . '/';
self::assertSame($expectedFullUrl, $tx->context->request->url->full);
self::assertSame($expectedFullUrl, $tx->context->request->url->original);
self::assertSame($expectedUrlParts->scheme, $tx->context->request->url->protocol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function buildCommandLine(array $ports): string
{
Assert::assertCount(1, $ports);
return InfraUtilForTests::buildAppCodePhpCmd($this->agentConfigSourceBuilder->getPhpIniFile())
. " -S 0.0.0.0:" . $ports[0]
. ' -S ' . HttpServerHandle::SERVER_LOCALHOST_ADDRESS . ':' . $ports[0]
. ' "' . FileUtilForTests::listToPath([__DIR__, self::APP_CODE_HOST_ROUTER_SCRIPT]) . '"';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace ElasticApmTests\ComponentTests\Util;

use Elastic\Apm\Impl\AutoInstrument\AutoInstrumentationBase;
use Elastic\Apm\Impl\Config\AllOptionsMetadata;
use Elastic\Apm\Impl\Config\OptionNames;
use Elastic\Apm\Impl\GlobalTracerHolder;
use Elastic\Apm\Impl\Log\Level as LogLevel;
Expand Down Expand Up @@ -197,7 +198,9 @@ protected static function implTestIsAutoInstrumentationEnabled(string $instrClas
$actualNames = $instr->keywords();
$actualNames[] = $instr->name();
self::assertEqualAsSets($expectedNames, $actualNames);
self::assertTrue($instr->isEnabled());
$astProcessEnabledDefaultValue = AllOptionsMetadata::get()[OptionNames::AST_PROCESS_ENABLED]->defaultValue();
$isEnabledByDefault = $astProcessEnabledDefaultValue || (!$instr->requiresUserlandCodeInstrumentation());
self::assertSame($isEnabledByDefault, $instr->isEnabled());

/**
* @param string $name
Expand Down Expand Up @@ -238,17 +241,17 @@ protected static function implTestIsAutoInstrumentationEnabled(string $instrClas
$dbgCtx->clearCurrentSubScope(['disableInstrumentationsOptVal' => $disableInstrumentationsOptVal]);
$tracer = self::buildTracerForTests()->withConfig(OptionNames::DISABLE_INSTRUMENTATIONS, $disableInstrumentationsOptVal)->build();
$instr = new $instrClassName($tracer);
self::assertTrue($instr->isEnabled());
self::assertSame($isEnabledByDefault, $instr->isEnabled());
}
$dbgCtx->popSubScope();

$dbgCtx->pushSubScope();
foreach ([true, false] as $astProcessEnabled) {
$dbgCtx->clearCurrentSubScope(['astProcessEnabled' => $astProcessEnabled]);
$expectedIsEnabled = $astProcessEnabled || (!$instr->requiresUserlandCodeInstrumentation());
$isEnabledByDefault = $astProcessEnabled || (!$instr->requiresUserlandCodeInstrumentation());
$tracer = self::buildTracerForTests()->withConfig(OptionNames::AST_PROCESS_ENABLED, BoolUtil::toString($astProcessEnabled))->build();
$instr = new $instrClassName($tracer);
self::assertSame($expectedIsEnabled, $instr->isEnabled());
self::assertSame($isEnabledByDefault, $instr->isEnabled());
}
$dbgCtx->popSubScope();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(HttpServerHandle $httpServerHandle, AppCodeTarget $a

$this->urlParts = new UrlParts();
$this->urlParts->scheme('http')
->host(HttpServerHandle::DEFAULT_HOST)
->host(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS)
->port($httpServerHandle->getMainPort())
->path('/');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class HttpServerHandle implements LoggableInterface
{
use LoggableTrait;

public const DEFAULT_HOST = '127.0.0.1';
public const CLIENT_LOCALHOST_ADDRESS = '127.0.0.1';
public const SERVER_LOCALHOST_ADDRESS = self::CLIENT_LOCALHOST_ADDRESS;
public const STATUS_CHECK_URI_PATH = '/elastic_apm_php_tests_status_check';
public const PID_KEY = 'pid';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function () use ($port, $dataPerRequest, $logger, &$lastThrown, &$pid) {
try {
$response = HttpClientUtilForTests::sendRequest(
HttpConstantsForTests::METHOD_GET,
(new UrlParts())->host(HttpServerHandle::DEFAULT_HOST)
(new UrlParts())->host(HttpServerHandle::CLIENT_LOCALHOST_ADDRESS)
->port($port)
->path(HttpServerHandle::STATUS_CHECK_URI_PATH),
$dataPerRequest
Expand Down
3 changes: 2 additions & 1 deletion tests/ElasticApmTests/ComponentTests/Util/TestCaseHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ private function setMandatoryOptions(AppCodeHostParams $params): void
$escalatedLogLevelForProdCodeAsString = LogLevel::intToName($this->escalatedLogLevelForProdCode);
$params->setAgentOption(AmbientContextForTests::testConfig()->escalatedRerunsProdCodeLogLevelOptionName ?? OptionNames::LOG_LEVEL_SYSLOG, $escalatedLogLevelForProdCodeAsString);
}
$params->setAgentOption(OptionNames::SERVER_URL, 'http://localhost:' . $this->mockApmServer->getPortForAgent());
/** @noinspection HttpUrlsUsage */
$params->setAgentOption(OptionNames::SERVER_URL, 'http://' . HttpServerHandle::CLIENT_LOCALHOST_ADDRESS . ':' . $this->mockApmServer->getPortForAgent());

if (!$this->isTestSpanCompressionCompatible) {
$params->setAgentOption(OptionNames::SPAN_COMPRESSION_ENABLED, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private function runHttpServer(): void
$this->reactLoop = Loop::get();
TestCase::assertNotEmpty(AmbientContextForTests::testConfig()->dataPerProcess->thisServerPorts);
foreach (AmbientContextForTests::testConfig()->dataPerProcess->thisServerPorts as $port) {
$uri = HttpServerHandle::DEFAULT_HOST . ':' . $port;
$uri = HttpServerHandle::SERVER_LOCALHOST_ADDRESS . ':' . $port;
$serverSocket = new SocketServer($uri, /* context */ [], $this->reactLoop);
$socketIndex = count($this->serverSockets);
$this->serverSockets[] = $serverSocket;
Expand Down
Loading

0 comments on commit 8cc6259

Please sign in to comment.