Skip to content

Commit a4d4c3f

Browse files
committed
Switch macOS to test against local server
1 parent b8e0c9f commit a4d4c3f

File tree

3 files changed

+101
-359
lines changed

3 files changed

+101
-359
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#################################################################################
2+
# Licensed to the .NET Foundation under one or more agreements. #
3+
# The .NET Foundation licenses this file to you under the MIT license. #
4+
# See the LICENSE file in the project root for more information. #
5+
#################################################################################
6+
parameters:
7+
- name: password
8+
type: string
9+
default: $(password)
10+
11+
- name: condition
12+
type: string
13+
default: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
14+
15+
steps:
16+
# Linux only steps
17+
- bash: |
18+
# The "user" pipeline variable conflicts with homebrew, causing errors during install. Set it back to the pipeline user.
19+
USER=`whoami`
20+
SQLCMD_ERRORS=$(Agent.TempDirectory)/sqlcmd_err.log
21+
echo $SQLCMD_ERRORS
22+
23+
brew install colima
24+
brew install --cask docker
25+
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
26+
brew update
27+
HOMEBREW_ACCEPT_EULA=Y brew install mssql-tools18
28+
colima start --arch x86_64
29+
docker --version
30+
docker pull mcr.microsoft.com/mssql/server:2022-latest
31+
32+
# Password for the SA user (required)
33+
MSSQL_SA_PW=${{parameters.password }}
34+
if [ "$MSSQL_SA_PW" = "generated_placeholder" ]; then
35+
exit 0
36+
fi
37+
38+
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_SA_PW" -p 1433:1433 -p 1434:1434 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest
39+
40+
sleep 5
41+
42+
docker ps -a
43+
44+
echo 0.0.0.0
45+
sqlcmd -S 0.0.0.0 -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION"
46+
echo 127.0.0.1
47+
sqlcmd -S 127.0.0.1 -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION"
48+
echo ::1
49+
sqlcmd -S ::1 -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION"
50+
echo localhost
51+
sqlcmd -S localhost -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION"
52+
echo "(default)"
53+
sqlcmd -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION"
54+
55+
# Connect to server and get the version:
56+
counter=1
57+
errstatus=1
58+
while [ $counter -le 20 ] && [ $errstatus = 1 ]
59+
do
60+
echo Waiting for SQL Server to start...
61+
sleep 3
62+
sqlcmd -S 0.0.0.0 -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION" 2>$SQLCMD_ERRORS
63+
errstatus=$?
64+
((counter++))
65+
done
66+
67+
# Display error if connection failed:
68+
if [ $errstatus = 1 ]
69+
then
70+
echo Cannot connect to SQL Server, installation aborted
71+
cat $SQLCMD_ERRORS
72+
rm -f $SQLCMD_ERRORS
73+
exit $errstatus
74+
else
75+
rm -f $SQLCMD_ERRORS
76+
fi
77+
78+
echo "Configuring Dedicated Administer Connections to allow remote connections..."
79+
sqlcmd -S 0.0.0.0 -No -U sa -P $MSSQL_SA_PW -Q "sp_configure 'remote admin connections', 1; RECONFIGURE;"
80+
if [ $? = 1 ]
81+
then
82+
echo "Error configuring DAC for remote access."
83+
exit $errstatus
84+
else
85+
echo "Configuration complete."
86+
fi
87+
88+
displayName: 'Configure SQL Server [macOS]'
89+
condition: ${{parameters.condition }}

eng/pipelines/common/templates/steps/configure-sql-server-step.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ steps:
9393
parameters:
9494
password: ${{parameters.password}}
9595

96+
- ${{ elseif eq(parameters.operatingSystem, 'Mac') }}:
97+
# macOS only steps
98+
- template: configure-sql-server-macos-step.yml@self
99+
parameters:
100+
password: ${{parameters.password}}
101+
96102
# Common steps
97103
- task: DotNetCoreCLI@2
98104
displayName: 'Build Ext Utilities'

0 commit comments

Comments
 (0)