Skip to content

Add MSSQL setup to Azure Pipelines build #6569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
1 change: 1 addition & 0 deletions azure/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ steps:
postgresql-contrib \
snmpd \
snmp-mibs-downloader \
freetds-dev \
unixodbc-dev \
llvm \
libc-client-dev \
Expand Down
1 change: 1 addition & 0 deletions azure/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ steps:
--with-imap-ssl \
--with-pdo-odbc=unixODBC,/usr \
--with-pdo-firebird \
--with-pdo-dblib \
--enable-werror \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d
Expand Down
1 change: 1 addition & 0 deletions azure/coverage_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
pool:
vmImage: 'ubuntu-18.04'
steps:
- template: mssql.yml
- template: apt.yml
- script: |
sudo -H pip install gcovr
Expand Down
1 change: 1 addition & 0 deletions azure/file_cache_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
pool:
vmImage: 'ubuntu-18.04'
steps:
- template: mssql.yml
- template: apt.yml
- template: configure.yml
parameters:
Expand Down
1 change: 1 addition & 0 deletions azure/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
pool:
vmImage: 'ubuntu-20.04'
steps:
- template: mssql.yml
- template: apt.yml
- template: configure.yml
parameters:
Expand Down
5 changes: 5 additions & 0 deletions azure/mssql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# this template should be included close to the beginning, before setup.yml
# the container needs time to come up or the sqlcmd operation in setup.yml will have a login timeout
steps:
- script: docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" -p 1433:1433 --name sql1 -h sql1 -d mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04
displayName: 'Start MSSQL container'
1 change: 1 addition & 0 deletions azure/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ steps:
mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo -u postgres psql -c "CREATE DATABASE test;"
docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U SA -P "<YourStrong@Passw0rd>" -Q "create login pdo_test with password='password', check_policy=off; create user pdo_test for login pdo_test; grant alter, control to pdo_test;"
displayName: 'Setup'
- script: ./azure/setup-slapd.sh
displayName: 'Configure slapd'
Expand Down
3 changes: 3 additions & 0 deletions azure/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ steps:
export PDO_MYSQL_TEST_DSN="mysql:host=localhost;dbname=test"
export PDO_MYSQL_TEST_USER=root
export PDO_MYSQL_TEST_PASS=root
export PDO_DBLIB_TEST_DSN="dblib:host=127.0.0.1;dbname=master;version=7.0"
export PDO_DBLIB_TEST_USER="pdo_test"
export PDO_DBLIB_TEST_PASS="password"
export TEST_PHP_JUNIT=junit.xml
export REPORT_EXIT_STATUS=no
export SKIP_IO_CAPTURE_TESTS=1
Expand Down
11 changes: 10 additions & 1 deletion ext/pdo/tests/bug_73234.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';

$db = PDOTest::factory();
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$db->exec('CREATE TABLE test(id INT)');

switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'dblib':
$sql = 'CREATE TABLE test(id INT NULL)';
break;
default:
$sql = 'CREATE TABLE test(id INT)';
break;
}
$db->exec($sql);

$stmt = $db->prepare('INSERT INTO test VALUES(:value)');

Expand Down
11 changes: 11 additions & 0 deletions ext/pdo_dblib/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The pdo_mysql extension tests

This extension can be tested using Microsoft's Docker image for [SQL Server on Linux](https://hub.docker.com/_/microsoft-mssql-server):

```bash
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" -p 1433:1433 --name sql1 -h sql1 -d mcr.microsoft.com/mssql/server:2019-latest
docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U SA -P "<YourStrong@Passw0rd>" -Q "create login pdo_test with password='password', check_policy=off; create user pdo_test for login pdo_test; grant alter, control to pdo_test;"

# and then from the root of php-src
PDO_DBLIB_TEST_DSN="dblib:host=127.0.0.1;dbname=master;version=7.0" PDO_DBLIB_TEST_USER="pdo_test" PDO_DBLIB_TEST_PASS="password" TESTS=ext/pdo_dblib make test
```
2 changes: 1 addition & 1 deletion ext/pdo_dblib/tests/bug_45876.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ array(10) {
["native_usertype_id"]=>
int(%d)
["pdo_type"]=>
int(2)
int(3)
["name"]=>
string(13) "TABLE_CATALOG"
["len"]=>
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_dblib/tests/pdo_dblib_param_str_natl.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Key: Name: [6] :value
paramno=-1
name=[6] ":value"
is_param=1
param_type=1073741826
param_type=1073741827
NULL
2 changes: 1 addition & 1 deletion ext/pdo_dblib/tests/types.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ string(19) "2030-01-01 23:59:59"
string(1) "0"
bool(true)
string(4) "1000"
string(5) "10.50"
string(7) "10.5000"
string(19) "1950-01-18 23:00:00"
string(1) "1"