Skip to content

Commit

Permalink
Fix Telemetry Service SQL Server pipeline flaky test (#734)
Browse files Browse the repository at this point in the history
* change tag to 2022-RTM-GDR1-ubuntu-20.04

* modified users

* add docker health check

* use docker health check for mysql
  • Loading branch information
Yunxe authored Oct 22, 2023
1 parent cc64637 commit a6cb885
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
7 changes: 5 additions & 2 deletions azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,16 @@ stages:
displayName: docker run tdengine and checkoutput
- script: |
set -e
docker run -itd --network host --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:8.1.0
docker run -itd --network host --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
--health-cmd='mysqladmin ping -h localhost -uroot' --health-interval=5s --health-timeout=5s --health-retries=20 \
mysql:8.1.0
bash $(System.DefaultWorkingDirectory)/examples/telemetryservice/mysql/checkoutput.sh
displayName: docker run mysql and checkoutput
- script: |
set -e
docker run -itd --network host --name sqlserver -e ACCEPT_EULA=Y -e SA_PASSWORD=Some_Strong_Password \
mcr.microsoft.com/mssql/server:2022-CU7-ubuntu-20.04
--health-cmd="/opt/mssql-tools/bin/sqlcmd -U sa -P Some_Strong_Password -Q 'select name from sys.databases'" --health-interval=5s --health-timeout=5s --health-retries=20 \
mcr.microsoft.com/mssql/server:2022-CU7-ubuntu-20.04
bash $(System.DefaultWorkingDirectory)/examples/telemetryservice/sqlserver/checkoutput.sh
displayName: docker run sqlserver and checkoutput
Expand Down
17 changes: 4 additions & 13 deletions examples/telemetryservice/mysql/checkoutput.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#!/bin/bash
MySQLOutput=2
sleep 3
for i in {1..50}
do
output=$(docker exec mysql mysql -u root -e "Show databases;" 2>&1 | grep 'ERROR' | wc -l)
#echo $output
if [[ $output -eq 0 ]]
then
echo $output
break
elif [[ $i -eq 50 ]]
then
exit 1
fi
echo "Waiting for MySQL to be ready..."
while [[ "$(docker inspect --format='{{.State.Health.Status}}' mysql)" != "healthy" ]]; do
sleep 5
done
echo "MySQL is ready."

# init MySQL Table
docker exec mysql mysql -u root \
Expand Down
24 changes: 7 additions & 17 deletions examples/telemetryservice/sqlserver/checkoutput.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
#!bin/bash
SQLServerOutput=2
sleep 6
for i in {1..50}
do
output=$(docker exec sqlserver /opt/mssql-tools/bin/sqlcmd \
-S localhost -U sa -P Some_Strong_Password \
-Q "select name from sys.databases" | grep 'Error' | wc -l)
echo $output
if [[ $output -eq 0 ]]
then
break
elif [[ $i -eq 50 ]]
then
exit 1
fi
echo "Waiting for SQL Server to be ready..."
while [[ "$(docker inspect --format='{{.State.Health.Status}}' sqlserver)" != "healthy" ]]; do
sleep 5
done
echo "SQL Server is ready."

# init SQLServer Table
docker exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Some_Strong_Password \
docker exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Some_Strong_Password \
-Q "Create database shifu;"

docker exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Some_Strong_Password \
docker exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Some_Strong_Password \
-d shifu -Q "CREATE TABLE testTable ( TelemetryID INT IDENTITY(1,1) PRIMARY KEY, DeviceName VARCHAR(255), TelemetryData TEXT, TelemetryTimeStamp DATETIME );"

docker exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Some_Strong_Password \
docker exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Some_Strong_Password \
-d shifu -Q "Select * from shifu.dbo.testTable;"

for i in {1..30}
Expand Down

0 comments on commit a6cb885

Please sign in to comment.