Skip to content

Commit 87a6fae

Browse files
authored
CHORE: Make ADO pipelines public (#474)
* CHORE: Make ADO pipelines public * added resources * changed endpoint * disabled self checkout * disabled none checkout * commented out explicit service connection mapping * commented out explicit service connection mapping * restored ADO SSO connection * checking reasons and where builds are coming from * recreated pipeline, cleanup done * readded resources * cleanup of resources * triggering * triggering * triggers changed * removed echo statements * waiting for sql server to start * waiting for sql server to start * test pass issues * test pass issues * test pass issues * test pass issues * test pass issues * increase timeout for sql server * add a test step * add a retry auth step * pull latest sql server and add extended retry for auth * switch to sql server 2019 * forcefully redirect localhost * cleanup and ready for review
1 parent 0408bfd commit 87a6fae

File tree

1 file changed

+70
-6
lines changed

1 file changed

+70
-6
lines changed

azure-pipelines.yml

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
trigger:
2-
- master
32
- dev
4-
- 1ES
53

64
pr:
75
branches:
@@ -16,9 +14,6 @@ schedules:
1614
- dev
1715
always: true
1816

19-
variables:
20-
- group: DjangoTestApp
21-
2217
jobs:
2318
- job: Windows
2419
pool:
@@ -149,7 +144,7 @@ jobs:
149144
displayName: Restart SQL Server
150145
151146
- powershell: |
152-
(Get-Content -ReadCount 0 testapp\settings.py) -replace 'MyPassword42', '$(TestAppPassWord)' | Set-Content testapp\settings.py
147+
(Get-Content -ReadCount 0 testapp\settings.py) -replace 'MyPassword42', '$(TestAppPassword)' | Set-Content testapp\settings.py
153148
displayName: Change PASSWORD in settings.py
154149
155150
- powershell: |
@@ -266,6 +261,33 @@ jobs:
266261
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=$(TestAppPassword)' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
267262
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
268263
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
264+
265+
# Wait for SQL Server to be ready with increased timeout
266+
echo "Waiting for SQL Server to start..."
267+
268+
# Extended wait for the container to be running and SQL Server service to be listening
269+
for i in {1..60}; do
270+
if docker logs $(docker ps -q --filter ancestor=mcr.microsoft.com/mssql/server:2022-latest) 2>&1 | grep -q "SQL Server is now ready for client connections"; then
271+
echo "SQL Server service is ready after $i attempts ($(($i * 3)) seconds)"
272+
break
273+
fi
274+
echo "Attempt $i: Waiting for SQL Server service to be ready, checking again in 3 seconds..."
275+
sleep 3
276+
done
277+
278+
# Increased wait to ensure full initialization for database operations
279+
echo "Waiting additional 60 seconds for full SQL Server initialization..."
280+
sleep 60
281+
282+
# Verify we can connect using a simple network test first
283+
echo "Testing SQL Server connectivity..."
284+
if ! timeout 30 bash -c 'until echo > /dev/tcp/localhost/1433; do sleep 1; done'; then
285+
echo "Cannot connect to SQL Server on port 1433"
286+
docker logs $(docker ps -q --filter ancestor=mcr.microsoft.com/mssql/server:2022-latest)
287+
exit 1
288+
fi
289+
290+
echo "SQL Server is ready and accepting connections"
269291
displayName: Install SQL Server
270292
271293
- script: |
@@ -303,6 +325,41 @@ jobs:
303325
fi
304326
displayName: Install ODBC Driver
305327
328+
- script: |
329+
# Install mssql-tools to get sqlcmd
330+
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools
331+
332+
# Wait for SQL Server authentication to be ready (retry loop)
333+
echo "Waiting for SQL Server authentication to be ready..."
334+
export PATH="$PATH:/opt/mssql-tools/bin"
335+
336+
# Retry authentication until SQL Server finishes its internal upgrade process
337+
for i in {1..30}; do
338+
echo "Authentication attempt $i of 30..."
339+
# Force IPv4 TCP to avoid potential localhost/IPv6 resolution issues on agents
340+
if sqlcmd -S "tcp:127.0.0.1,1433" -U sa -P "$(TestAppPassword)" -Q "SELECT 1 AS test" -l 10 >/dev/null 2>&1; then
341+
echo "✅ SQL Server authentication successful after $i attempts!"
342+
break
343+
else
344+
if [ $i -eq 30 ]; then
345+
echo "❌ SQL Server authentication FAILED after 30 attempts!"
346+
echo "Final attempt with verbose output:"
347+
sqlcmd -S "tcp:127.0.0.1,1433" -U sa -P "$(TestAppPassword)" -Q "SELECT 1 AS test" -l 10
348+
echo ""
349+
echo "Container logs:"
350+
docker logs $(docker ps -q --filter ancestor=mcr.microsoft.com/mssql/server:2022-latest)
351+
exit 1
352+
else
353+
echo "Authentication failed (attempt $i), waiting 10 seconds before retry..."
354+
echo "This is normal - SQL Server may still be upgrading internal databases..."
355+
sleep 10
356+
fi
357+
fi
358+
done
359+
360+
echo "SQL Server is fully ready for authentication!"
361+
displayName: Wait for SQL Server Authentication
362+
306363
- script: |
307364
# Since pylibmc isn't supported for Python 3.12+
308365
# We need to install libmemcached-dev to build it - dependency for Django test suite
@@ -323,6 +380,13 @@ jobs:
323380
sed -i 's/MyPassword42/$(TestAppPassword)/g' testapp/settings.py
324381
displayName: Change PASSWORD in settings.py
325382
383+
- script: |
384+
# Force Django DB host to IPv4 loopback to avoid IPv6 localhost resolution issues
385+
sed -i "s|\"HOST\": \"localhost\"|\"HOST\": \"127.0.0.1\"|g" testapp/settings.py
386+
echo "Updated DB HOST to 127.0.0.1"
387+
grep -n "\"HOST\"" -n testapp/settings.py
388+
displayName: Use IPv4 loopback for DB host
389+
326390
- script: tox -e $(tox.env)
327391
displayName: Run tox
328392

0 commit comments

Comments
 (0)