Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitlab/dockerhub-login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ if ! command -v jq > /dev/null 2>&1; then
export PATH="/tmp:${PATH}"
fi

# Install unzip if not already available
if ! command -v unzip > /dev/null 2>&1; then
echo "Installing unzip..."
if command -v apt-get > /dev/null 2>&1; then
apt-get update -qq && apt-get install -y -qq unzip > /dev/null 2>&1 || {
echo "Warning: Failed to install unzip. Skipping Docker Hub authentication." >&2
exit 0
}
elif command -v apk > /dev/null 2>&1; then
apk add --no-cache unzip > /dev/null 2>&1 || {
echo "Warning: Failed to install unzip. Skipping Docker Hub authentication." >&2
exit 0
}
else
echo "Warning: No package manager found to install unzip. Skipping Docker Hub authentication." >&2
exit 0
fi
fi

# Install Vault if not already available
vault_cmd="vault"
if ! command -v vault > /dev/null 2>&1; then
Expand Down
15 changes: 14 additions & 1 deletion .gitlab/generate-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,20 @@
- sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
- sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
- sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
- yum update -y
- |
# Retry yum update as vault.centos.org can be slow/unreliable
for i in 1 2 3; do
if yum update -y; then
echo "yum update succeeded on attempt $i"
break
fi
echo "yum update failed (attempt $i/3), retrying in 5 seconds..."
sleep 5
if [ $i -eq 3 ]; then
echo "yum update failed after 3 attempts, exiting"
exit 1
fi
done

"verify debian":
extends: .verify_job
Expand Down
39 changes: 38 additions & 1 deletion tests/Integrations/SQLSRV/SQLSRVTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,43 @@ public static function ddSetUpBeforeClass()
{
parent::ddSetUpBeforeClass();
self::putenv('DD_SQLSRV_ANALYTICS_ENABLED=true');
self::waitForSqlServerReady();
}

private static function waitForSqlServerReady()
{
$maxAttempts = 30;
$attempt = 0;
$conn = false;

while ($attempt < $maxAttempts && $conn === false) {
$attempt++;
$conn = @sqlsrv_connect(
self::$host . ', ' . self::$port,
[
'PWD' => self::$password,
'Database' => self::$db,
'UID' => self::$user,
'TrustServerCertificate' => true,
]
);

if ($conn === false) {
if ($attempt < $maxAttempts) {
usleep(500000);
}
}
}

if ($conn === false) {
$errors = sqlsrv_errors();
$lastError = $errors ? json_encode($errors) : 'Unknown error';
throw new \RuntimeException(
"SQL Server not ready after {$maxAttempts} attempts. Last error: {$lastError}"
);
}

sqlsrv_close($conn);
}

public static function ddTearDownAfterClass()
Expand Down Expand Up @@ -508,7 +545,7 @@ private function createConnection()
'PWD' => self::$password,
'Database' => self::$db,
'UID' => self::$user,
'TrustServerCertificate' => true
'TrustServerCertificate' => true,
]
);

Expand Down
33 changes: 33 additions & 0 deletions tests/Nginx/NginxServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ final class NginxServer
*/
private $rootPath;

/**
* @var string
*/
private $serverHost;

/**
* @var int
*/
private $hostPort;

/**
* @param string $indexFile
* @param string $serverHost
Expand All @@ -35,6 +45,8 @@ final class NginxServer
public function __construct($indexFile, $serverHost, $hostPort, $fastCGIHost, $fastCGIPort)
{
$this->rootPath = dirname($indexFile);
$this->serverHost = $serverHost;
$this->hostPort = $hostPort;
$replacements = [
'{{root_path}}' => $this->rootPath,
'{{index_file}}' => basename($indexFile),
Expand Down Expand Up @@ -76,6 +88,27 @@ public function start()

$this->process = new Process($processCmd);
$this->process->start();

if (!$this->waitUntilServerRunning()) {
error_log("[nginx] Server never came up...");
return;
}
error_log("[nginx] Server is up and responding...");
}

public function waitUntilServerRunning()
{
//Let's wait until nginx is accepting connections
for ($try = 0; $try < 40; $try++) {
$socket = @fsockopen($this->serverHost, $this->hostPort);
if ($socket !== false) {
fclose($socket);
return true;
}
usleep(50000);
}

return false;
}

public function stop()
Expand Down
41 changes: 39 additions & 2 deletions tests/Sapi/OctaneServer/OctaneServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function __construct($artisanFile, $host, $port, array $envs = [], array

public function start()
{
//Avoid previous tests
$this->waitUntilServerIsNotRunning();

if (getenv('PHPUNIT_COVERAGE')) {
$xdebugExtension = glob(PHP_EXTENSION_DIR . '/xdebug*.so');
$xdebugExtension = end($xdebugExtension);
Expand Down Expand Up @@ -86,8 +89,41 @@ public function start()

$this->process = new Process($processCmd);
$this->process->start();
sleep(1);
echo $this->process->getErrorOutput();

if (!$this->waitUntilServerRunning()) {
error_log("[octane-server] Server never came up...");
echo $this->process->getErrorOutput();
return;
}
error_log("[octane-server] Server is up and responding...");
}

public function waitUntilServerIsNotRunning()
{
//Let's wait until server is not accepting connections
for ($try = 0; $try < 40; $try++) {
$socket = @fsockopen($this->host, $this->port);
if ($socket == false) {
return true;
}
usleep(50000);
}

return false;
}

public function waitUntilServerRunning()
{
//Let's wait until server is accepting connections
for ($try = 0; $try < 40; $try++) {
$socket = @fsockopen($this->host, $this->port);
if ($socket !== false) {
return true;
}
usleep(50000);
}

return false;
}

public function stop()
Expand All @@ -101,6 +137,7 @@ public function stop()
);
$process = new Process($cmd);
$process->run();
$this->waitUntilServerIsNotRunning();
}

public function isFastCgi()
Expand Down
33 changes: 33 additions & 0 deletions tests/Sapi/PhpFpm/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ final class PhpFpm implements Sapi
*/
private $logFile;

/**
* @var string
*/
private $host;

/**
* @var int
*/
private $port;

/**
* @param string $rootPath
* @param string $host
Expand All @@ -45,6 +55,8 @@ public function __construct($rootPath, $host, $port, array $envs = [], array $in
{
$this->envs = $envs;
$this->inis = $inis;
$this->host = $host;
$this->port = $port;

$logPath = $rootPath . '/' . self::ERROR_LOG;

Expand Down Expand Up @@ -88,6 +100,27 @@ public function start()

$this->process = new Process($processCmd);
$this->process->start();

if (!$this->waitUntilServerRunning()) {
error_log("[php-fpm] Server never came up...");
return;
}
error_log("[php-fpm] Server is up and responding...");
}

public function waitUntilServerRunning()
{
//Let's wait until PHP-FPM is accepting connections
for ($try = 0; $try < 40; $try++) {
$socket = @fsockopen($this->host, $this->port);
if ($socket !== false) {
fclose($socket);
return true;
}
usleep(50000);
}

return false;
}

public function stop()
Expand Down
7 changes: 4 additions & 3 deletions tests/WebServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ public function start()
}
}

// Start PHP-FPM first (if FastCGI), as nginx depends on it
$this->sapi->start();

// Then start nginx (if needed)
if ($this->sapi->isFastCgi()) {
$this->server = new NginxServer(
$this->indexFile,
Expand All @@ -234,9 +238,6 @@ public function start()
);
$this->server->start();
}

$this->sapi->start();
usleep(500000);
}

public function reload()
Expand Down
Loading