File tree Expand file tree Collapse file tree 2 files changed +47
-10
lines changed
tests/Integrations/SQLSRV Expand file tree Collapse file tree 2 files changed +47
-10
lines changed Original file line number Diff line number Diff line change 998998 - sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
999999 - sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
10001000 - sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
1001- - yum update -y --nogpgcheck
1001+ - |
1002+ # Retry yum update as vault.centos.org can be slow/unreliable
1003+ for i in 1 2 3; do
1004+ if yum update -y; then
1005+ echo "yum update succeeded on attempt $i"
1006+ break
1007+ fi
1008+ echo "yum update failed (attempt $i/3), retrying in 5 seconds..."
1009+ sleep 5
1010+ if [ $i -eq 3 ]; then
1011+ echo "yum update failed after 3 attempts, exiting"
1012+ exit 1
1013+ fi
1014+ done
10021015
10031016"verify debian":
10041017 extends: .verify_job
Original file line number Diff line number Diff line change @@ -502,15 +502,39 @@ public function testNoFakeServices()
502502
503503 private function createConnection ()
504504 {
505- $ conn = sqlsrv_connect (
506- self ::$ host . ', ' . self ::$ port ,
507- [
508- 'PWD ' => self ::$ password ,
509- 'Database ' => self ::$ db ,
510- 'UID ' => self ::$ user ,
511- 'TrustServerCertificate ' => true
512- ]
513- );
505+ // Retry connection to handle SQL Server container startup time
506+ $ maxAttempts = 30 ;
507+ $ attempt = 0 ;
508+ $ conn = false ;
509+ $ lastError = null ;
510+
511+ while ($ attempt < $ maxAttempts && $ conn === false ) {
512+ $ attempt ++;
513+ $ conn = sqlsrv_connect (
514+ self ::$ host . ', ' . self ::$ port ,
515+ [
516+ 'PWD ' => self ::$ password ,
517+ 'Database ' => self ::$ db ,
518+ 'UID ' => self ::$ user ,
519+ 'TrustServerCertificate ' => true ,
520+ ]
521+ );
522+
523+ if ($ conn === false ) {
524+ $ errors = sqlsrv_errors ();
525+ $ lastError = $ errors ? json_encode ($ errors ) : 'Unknown error ' ;
526+
527+ if ($ attempt < $ maxAttempts ) {
528+ usleep (500000 );
529+ }
530+ }
531+ }
532+
533+ if ($ conn === false ) {
534+ throw new \RuntimeException (
535+ "Failed to connect to SQL Server after {$ maxAttempts } attempts. Last error: {$ lastError }"
536+ );
537+ }
514538
515539 return $ conn ;
516540 }
You can’t perform that action at this time.
0 commit comments