From 3a105548a9580edf1b541a17b3995c62f61079b8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 28 Sep 2025 10:09:59 -0700 Subject: [PATCH] [ticket/17555] Optimize windows tests PHPBB-17555 --- .github/phpunit-psql-windows-github.xml | 5 +- .github/workflows/tests.yml | 64 +++++++++++++++---- .../phpbb_functional_test_case.php | 16 +++-- 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/.github/phpunit-psql-windows-github.xml b/.github/phpunit-psql-windows-github.xml index 0b80da0774..179dfe6bd3 100644 --- a/.github/phpunit-psql-windows-github.xml +++ b/.github/phpunit-psql-windows-github.xml @@ -7,7 +7,10 @@ bootstrap="../tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" - backupStaticProperties="false"> + backupStaticProperties="false" + timeoutForSmallTests="60" + timeoutForMediumTests="300" + timeoutForLargeTests="600"> ../tests diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b1b5703d1..018b489193 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -544,6 +544,9 @@ jobs: GITHUB_WORKSPACE: ${{ github.workspace }} TEMP_DIR: ${{ runner.temp }} run: | + # Disable Windows Defender real-time monitoring early to improve performance + Set-MpPreference -DisableRealtimeMonitoring $true + Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All Set-Service wuauserv -StartupType Manual (Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("", "`n`t`n`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config @@ -564,16 +567,38 @@ jobs: New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either iisreset NET START W3SVC - mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\test" - mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\installer" - icacls "${env:GITHUB_WORKSPACE}\phpBB\cache" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\files" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\store" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\ext" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\vendor-ext" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\composer-ext.json" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\composer-ext.lock" /grant Users:F /T - icacls "${env:GITHUB_WORKSPACE}\phpBB\images\avatars\upload" /grant Users:F /T + + # Wait for IIS to be ready and test connectivity + Start-Sleep -Seconds 10 + try { + $response = Invoke-WebRequest -Uri "http://phpbb.test/" -UseBasicParsing -TimeoutSec 30 + Write-Host "Web server is responding: $($response.StatusCode)" + } catch { + Write-Host "Web server test failed: $_" + } + + # Create directories and set permissions more efficiently + $dirs = @("cache\test", "cache\installer") + foreach ($dir in $dirs) { + New-Item -Path "${env:GITHUB_WORKSPACE}\phpBB\$dir" -ItemType Directory -Force + } + + # Set permissions in batch for better performance + $paths = @("cache", "files", "store", "ext", "vendor-ext", "images\avatars\upload") + foreach ($path in $paths) { + if (Test-Path "${env:GITHUB_WORKSPACE}\phpBB\$path") { + icacls "${env:GITHUB_WORKSPACE}\phpBB\$path" /grant Users:F /T /Q + } + } + + # Set permissions for specific files + $files = @("composer-ext.json", "composer-ext.lock") + foreach ($file in $files) { + if (Test-Path "${env:GITHUB_WORKSPACE}\phpBB\$file") { + icacls "${env:GITHUB_WORKSPACE}\phpBB\$file" /grant Users:F /Q + } + } + $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow") $acl = Get-ACL "${env:TEMP_DIR}" $acl.AddAccessRule($accessRule) @@ -586,7 +611,7 @@ jobs: $postgreSqlSvc = Get-Service "postgresql*" Set-Service $postgreSqlSvc.Name -StartupType manual $runningStatus = [System.ServiceProcess.ServiceControllerStatus]::Running - $maxStartTimeout = New-TimeSpan -Seconds 30 + $maxStartTimeout = New-TimeSpan -Seconds 120 try { $postgreSqlSvc.Start() $postgreSqlSvc.WaitForStatus($runningStatus, $maxStartTimeout) @@ -595,12 +620,17 @@ jobs: } [System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";${env:PGBIN}") $env:PGPASSWORD = 'root' - psql -c 'ALTER SYSTEM SET hot_standby = on;' -U postgres - psql -c 'ALTER SYSTEM SET wal_level = minimal;' -U postgres + + # Optimize PostgreSQL for testing performance + psql -c "ALTER SYSTEM SET fsync = off;" -U postgres + psql -c "ALTER SYSTEM SET synchronous_commit = off;" -U postgres + psql -c "ALTER SYSTEM SET checkpoint_completion_target = 0.9;" -U postgres + psql -c "ALTER SYSTEM SET wal_buffers = '16MB';" -U postgres + psql -c "ALTER SYSTEM SET shared_buffers = '128MB';" -U postgres psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres psql -c 'create database phpbb_tests;' -U postgres + Set-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender - Set-MpPreference -DisableRealtimeMonitoring $true - name: Setup node uses: actions/setup-node@v4 @@ -615,5 +645,11 @@ jobs: phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --display-all-issues --stop-on-error --exclude-group functional,slow - name: Run functional tests if: ${{ matrix.type == 'functional' }} + timeout-minutes: 45 + env: + PHPBB_FUNCTIONAL_TIMEOUT: 30 + SYMFONY_DEPRECATIONS_HELPER: disabled + PHPBB_TEST_REDIS_HOST: '' + PHPBB_TEST_MEMCACHED_HOST: '' run: | phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --display-all-issues --stop-on-error --group functional diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 980f397a2a..022bbd1e0c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -129,11 +129,17 @@ class phpbb_functional_test_case extends phpbb_test_case $this->bootstrap(); self::$cookieJar = new CookieJar; - // Force native client on windows platform - self::$http_client = strtolower(substr(PHP_OS, 0, 3)) === 'win' ? new NativeHttpClient() : HttpClient::create(); - self::$http_client->withOptions([ - 'timeout' => 60, - ]); + // Optimize HTTP client for Windows platform + if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { + self::$http_client = new NativeHttpClient([ + 'timeout' => 30, + 'max_duration' => 60, + ]); + } else { + self::$http_client = HttpClient::create([ + 'timeout' => 60, + ]); + } self::$client = new HttpBrowser(self::$http_client, null, self::$cookieJar); // Clear the language array so that things