Skip to content

Commit

Permalink
testen tegen mssql 2019 op travis-ci (#713)
Browse files Browse the repository at this point in the history
appveyor moet nog maar even wachten
  • Loading branch information
mprins authored Oct 19, 2019
1 parent d4c6527 commit 09b3b9f
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ matrix:
# kan vaak postgis niet installeren...
- name: "PostgreSQL 10"
- jdk: oraclejdk11
- name: "MS SQL server 2019"
include:
- name: "Oudste supported PostgreSQL"
dist: xenial
Expand Down Expand Up @@ -96,6 +97,16 @@ matrix:
- PG_VERSION=""
- PROFILE="mssql"
- MVN_ARGS="-Dmssql.instancename='' -Dit.test=!TopNLIntegrationTest"
- name: "MS SQL server 2019"
jdk: openjdk8
group: edge
dist: xenial
sudo: required
env:
- PG_VERSION=""
- MSSQL_VERSION="2019"
- PROFILE="mssql"
- MVN_ARGS="-Dmssql.instancename='' -Dit.test=!TopNLIntegrationTest"
- name: "database upgrades"
jdk: openjdk8
sudo: required
Expand Down Expand Up @@ -161,8 +172,12 @@ before_install:
- if [ "$PROFILE" == "postgresql" ]; then
sh ".travis/install-pgsql.sh";
elif [ "$PROFILE" == "mssql" ]; then
sudo service postgresql stop;
sh ".travis/install-mssql.sh";
sudo service postgresql stop;
if [ "$MSSQL_VERSION" == "2019" ]; then
sh ".travis/install-mssql2019.sh";
else
sh ".travis/install-mssql.sh";
fi
fi
- if [ "$TRAVIS_JOB_NAME" == "database upgrades" ]; then
sh ".travis/getlastRelease.sh";
Expand Down
119 changes: 119 additions & 0 deletions .travis/install-mssql2019.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash -e

# Use the following variables to control your install:

# Password for the SA user (required)
MSSQL_SA_PASSWORD='Password12!'

# Product ID of the version of SQL server you're installing
# Must be evaluation, developer, express, web, standard, enterprise, or your 25 digit product key
# Defaults to developer
MSSQL_PID='developer'

# Install SQL Server Agent (recommended)
# SQL_INSTALL_AGENT='y'

# Install SQL Server Full Text Search (optional)
# SQL_INSTALL_FULLTEXT='y'

# Create an additional user with sysadmin privileges (optional)
# SQL_INSTALL_USER='<Username>'
# SQL_INSTALL_USER_PASSWORD='<YourStrong!Passw0rd>'

if [ -z $MSSQL_SA_PASSWORD ]
then
echo Environment variable MSSQL_SA_PASSWORD must be set for unattended install
exit 1
fi

echo Adding Microsoft repositories...
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
repoargs="$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
sudo add-apt-repository "${repoargs}"
repoargs="$(curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
sudo add-apt-repository "${repoargs}"

echo Running apt-get update -y...
sudo apt-get update -y

echo Installing SQL Server...
sudo apt-get install -y mssql-server

echo Running mssql-conf setup...
sudo MSSQL_SA_PASSWORD=$MSSQL_SA_PASSWORD \
MSSQL_PID=$MSSQL_PID \
/opt/mssql/bin/mssql-conf -n setup accept-eula

echo Installing mssql-tools and unixODBC developer...
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev

# Add SQL Server tools to the path by default:
echo Adding SQL Server tools to your path...
echo PATH="$PATH:/opt/mssql-tools/bin" >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

# Optional SQL Server Agent installation:
if [ ! -z $SQL_INSTALL_AGENT ]
then
echo Installing SQL Server Agent...
sudo apt-get install -y mssql-server-agent
fi

# Optional SQL Server Full Text Search installation:
if [ ! -z $SQL_INSTALL_FULLTEXT ]
then
echo Installing SQL Server Full-Text Search...
sudo apt-get install -y mssql-server-fts
fi

# Configure firewall to allow TCP port 1433:
echo Configuring UFW to allow traffic on port 1433...
sudo ufw allow 1433/tcp
sudo ufw reload

# Optional example of post-installation configuration.
# Trace flags 1204 and 1222 are for deadlock tracing.
# echo Setting trace flags...
# sudo /opt/mssql/bin/mssql-conf traceflag 1204 1222 on

# Restart SQL Server after installing:
echo Restarting SQL Server...
sudo systemctl restart mssql-server

# Connect to server and get the version:
counter=1
errstatus=1
while [ $counter -le 5 ] && [ $errstatus = 1 ]
do
echo Waiting for SQL Server to start...
sleep 10s
/opt/mssql-tools/bin/sqlcmd \
-S localhost \
-U SA \
-P $MSSQL_SA_PASSWORD \
-Q "SELECT @@VERSION" 2>/dev/null
errstatus=$?
(($counter++))
done

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $MSSQL_SA_PASSWORD -Q "SELECT @@servername" 2>/dev/null

# Display error if connection failed:
if [ $errstatus = 1 ]
then
echo Cannot connect to SQL Server, installation aborted
exit $errstatus
fi

# Optional new user creation:
if [ ! -z $SQL_INSTALL_USER ] && [ ! -z $SQL_INSTALL_USER_PASSWORD ]
then
echo Creating user $SQL_INSTALL_USER
/opt/mssql-tools/bin/sqlcmd \
-S localhost \
-U SA \
-P $MSSQL_SA_PASSWORD \
-Q "CREATE LOGIN [$SQL_INSTALL_USER] WITH PASSWORD=N'$SQL_INSTALL_USER_PASSWORD', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=ON, CHECK_POLICY=ON; ALTER SERVER ROLE [sysadmin] ADD MEMBER [$SQL_INSTALL_USER]"
fi

echo Done!

0 comments on commit 09b3b9f

Please sign in to comment.