Skip to content

Commit c778a38

Browse files
committed
Fix a test with a retry of the nightly paghe load on a cold cache
1 parent a7e9670 commit c778a38

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎tests/Functional/pages.php‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
['api/', 302, '', 'id="about"'],
1515
['beta/', 200, '', ''],
1616
['nightly/', 200, '', 'id="nightly"'],
17+
['nightly/?date=20261001', 200, '', 'id="nightly"'], // Past date: always goes through the waiting page on a cold cache
1718
['calendar/', 200, '', 'id="calendar_main"'],
1819
['calendar/monthly/', 200, '', 'id="calendar_monthly"'],
1920
['release/', 200, 'Release Owner', 'id="release_'], // could be release_beta or release_current after beta 1
@@ -67,9 +68,25 @@
6768
[$path, $http_code, $content, $content2] = $paths[$i];
6869

6970
$raw = curl_multi_getcontent($ch);
71+
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
72+
73+
// Pages preparing data display a waiting page that reloads itself once the
74+
// data is ready, do what a browser does and request the page again.
75+
for ($try = 0; $try < 3 && str_contains($raw, 'class="waitingpage"') && str_contains($raw, 'http-equiv="refresh"'); $try++) {
76+
$retry = curl_init('http://localhost:8083/' . $path);
77+
curl_setopt_array($retry, [
78+
CURLOPT_RETURNTRANSFER => true,
79+
CURLOPT_FOLLOWLOCATION => true,
80+
CURLOPT_HEADER => true,
81+
]);
82+
$raw = (string) curl_exec($retry);
83+
$header_size = curl_getinfo($retry, CURLINFO_HEADER_SIZE);
84+
curl_close($retry);
85+
}
86+
7087
preg_match('/HTTP\/\d[\d.]* (\d+)/', $raw, $matches);
7188
$first_code = isset($matches[1]) ? (int) $matches[1] : 0;
72-
$body = substr($raw, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
89+
$body = substr($raw, $header_size);
7390

7491
echo "\e[1;32m✓\e[0m " . ($path ?: '(empty string)') . "\n";
7592
$obj->setPath($path);

0 commit comments

Comments
 (0)