Skip to content

Commit 83f1c97

Browse files
committed
ci(random-tests): run Oracle sequentially and increase per-component timeout to 600s
1 parent 72a35f5 commit 83f1c97

3 files changed

Lines changed: 59 additions & 51 deletions

File tree

‎.github/workflows/test-random-execution.yml‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ on:
5151
description: Per-component timeout in seconds (0 disables)
5252
type: string
5353
required: false
54-
default: '300'
54+
default: '600'
5555

5656
concurrency:
5757
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -212,16 +212,24 @@ jobs:
212212
args+=("--component" "${{ inputs.component }}")
213213
fi
214214
215-
# Add --max-jobs flag if specified (empty means auto-detect)
216-
if [[ -n "${{ inputs.max-jobs }}" ]]; then
217-
args+=("--max-jobs" "${{ inputs.max-jobs }}")
215+
# OCI8 connects to a single shared schema (FREEPDB1) via DSN, so
216+
# components cannot be isolated with per-component databases like
217+
# MySQLi/Postgre/SQLSRV. Running components in parallel makes
218+
# e.g. Commands' migrate:rollback drop tables that Database tests
219+
# rely on (ORA-00942/04043/08103). Run Oracle sequentially with
220+
# default repeat 2 to avoid schema collisions and timeouts.
221+
if [[ "${{ matrix.db-platform }}" == "Oracle" ]]; then
222+
args+=("--max-jobs" "1")
223+
args+=("--repeat" "${{ inputs.repeat || '2' }}")
224+
else
225+
if [[ -n "${{ inputs.max-jobs }}" ]]; then
226+
args+=("--max-jobs" "${{ inputs.max-jobs }}")
227+
fi
228+
args+=("--repeat" "${{ inputs.repeat || '10' }}")
218229
fi
219230
220-
# Add --repeat flag (always, default is 10)
221-
args+=("--repeat" "${{ inputs.repeat || '10' }}")
222-
223-
# Add --timeout flag (always, default is 300)
224-
args+=("--timeout" "${{ inputs.timeout || '300' }}")
231+
# Add --timeout flag (always, default is 600)
232+
args+=("--timeout" "${{ inputs.timeout || '600' }}")
225233
226234
.github/scripts/run-random-tests.sh "${args[@]}"
227235
env:

‎system/Database/Postgre/Connection.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ private function convertDSN()
151151
protected function _close()
152152
{
153153
if ($this->connID !== false) {
154-
@pg_close($this->connID);
155-
$this->connID = false;
154+
try {
155+
@pg_close($this->connID);
156+
} catch (Throwable) {
157+
} finally {
158+
$this->connID = false;
159+
}
156160
}
157161
}
158162

‎tests/_support/Config/Registrar.php‎

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static function Database(): array
147147

148148
$dbParams = self::$dbConfig[$group] ?? [];
149149

150-
if (! empty($dbParams) && $group !== 'SQLite3') {
150+
if (! empty($dbParams) && ! in_array($group, ['SQLite3', 'OCI8'], true)) {
151151
$componentName = '';
152152

153153
foreach ($_SERVER['argv'] ?? [] as $arg) {
@@ -161,47 +161,43 @@ public static function Database(): array
161161
}
162162

163163
if ($componentName !== '') {
164-
if ($group === 'OCI8') {
165-
$dbParams['DBPrefix'] = 'c_' . strtolower(substr($componentName, 0, 10)) . '_';
166-
} else {
167-
$dbParams['database'] = 'test_' . strtolower($componentName);
168-
169-
try {
170-
if ($group === 'MySQLi') {
171-
$conn = new mysqli(
172-
$dbParams['hostname'],
173-
$dbParams['username'],
174-
$dbParams['password'],
175-
'',
176-
(int) $dbParams['port'],
177-
);
178-
if (! $conn->connect_error) {
179-
$conn->query('CREATE DATABASE IF NOT EXISTS ' . $conn->real_escape_string($dbParams['database']));
180-
$conn->close();
181-
}
182-
} elseif ($group === 'Postgre') {
183-
$dsn = 'pgsql:host=' . $dbParams['hostname'] . ';port=' . $dbParams['port'] . ';user=' . $dbParams['username'] . ';password=' . $dbParams['password'];
184-
$pdo = new PDO($dsn);
185-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
186-
$stmt = $pdo->prepare('SELECT 1 FROM pg_database WHERE datname = ?');
187-
$stmt->execute([$dbParams['database']]);
188-
if (! $stmt->fetchColumn()) {
189-
$dbName = str_replace('"', '""', $dbParams['database']);
190-
$pdo->exec('CREATE DATABASE "' . $dbName . '"');
191-
}
192-
} elseif ($group === 'SQLSRV') {
193-
$dsn = 'sqlsrv:Server=' . $dbParams['hostname'] . ',' . $dbParams['port'] . ';Encrypt=False;TrustServerCertificate=True';
194-
$pdo = new PDO($dsn, $dbParams['username'], $dbParams['password']);
195-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
196-
$stmt = $pdo->prepare('SELECT 1 FROM sys.databases WHERE name = ?');
197-
$stmt->execute([$dbParams['database']]);
198-
if (! $stmt->fetchColumn()) {
199-
$pdo->exec('CREATE DATABASE [' . str_replace(']', ']]', $dbParams['database']) . '] COLLATE Latin1_General_100_CS_AS_SC_UTF8');
200-
}
164+
$dbParams['database'] = 'test_' . strtolower($componentName);
165+
166+
try {
167+
if ($group === 'MySQLi') {
168+
$conn = new mysqli(
169+
$dbParams['hostname'],
170+
$dbParams['username'],
171+
$dbParams['password'],
172+
'',
173+
(int) $dbParams['port'],
174+
);
175+
if (! $conn->connect_error) {
176+
$conn->query('CREATE DATABASE IF NOT EXISTS ' . $conn->real_escape_string($dbParams['database']));
177+
$conn->close();
178+
}
179+
} elseif ($group === 'Postgre') {
180+
$dsn = 'pgsql:host=' . $dbParams['hostname'] . ';port=' . $dbParams['port'] . ';user=' . $dbParams['username'] . ';password=' . $dbParams['password'];
181+
$pdo = new PDO($dsn);
182+
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
183+
$stmt = $pdo->prepare('SELECT 1 FROM pg_database WHERE datname = ?');
184+
$stmt->execute([$dbParams['database']]);
185+
if (! $stmt->fetchColumn()) {
186+
$dbName = str_replace('"', '""', $dbParams['database']);
187+
$pdo->exec('CREATE DATABASE "' . $dbName . '"');
188+
}
189+
} elseif ($group === 'SQLSRV') {
190+
$dsn = 'sqlsrv:Server=' . $dbParams['hostname'] . ',' . $dbParams['port'] . ';Encrypt=False;TrustServerCertificate=True';
191+
$pdo = new PDO($dsn, $dbParams['username'], $dbParams['password']);
192+
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
193+
$stmt = $pdo->prepare('SELECT 1 FROM sys.databases WHERE name = ?');
194+
$stmt->execute([$dbParams['database']]);
195+
if (! $stmt->fetchColumn()) {
196+
$pdo->exec('CREATE DATABASE [' . str_replace(']', ']]', $dbParams['database']) . '] COLLATE Latin1_General_100_CS_AS_SC_UTF8');
201197
}
202-
} catch (Throwable) {
203-
// Ignore any error and let the connection fail naturally
204198
}
199+
} catch (Throwable) {
200+
// Ignore any error and let the connection fail naturally
205201
}
206202
}
207203
}

0 commit comments

Comments
 (0)