Updated tests to run against AE v2 server (#1305)

This commit is contained in:
Jenny Tam 2021-09-22 09:40:57 -07:00 коммит произвёл GitHub
Родитель 48b6a6013f
Коммит c87af63d57
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 60 добавлений и 21 удалений

Просмотреть файл

@ -206,10 +206,12 @@ jobs:
coveralls -i ./source/ -e ./source/shared/ -e ./test/ -e ./source/pdo_sqlsrv/shared/core_stream.cpp \
-E r'.*localization*' -E r'.*globalization*' --gcov-options '\-lp'
displayName: 'Invoke coveralls using repo token'
condition: false
env:
COVERALLS_REPO_TOKEN: $(repo_token)
TRAVIS_JOB_ID: $(Build.BuildId)
TRAVIS_BRANCH: $(Build.SourceBranchName)
PYTHONWARNINGS: ignore::yaml.YAMLLoadWarning
- script: |
cd $(Build.SourcesDirectory)/test/functional/

Просмотреть файл

@ -636,6 +636,25 @@ function IsDaasMode()
return ($daasMode ? true : false);
}
function isServerHGSEnabled()
{
$enabled = false;
try {
$conn = connect();
$tsql = "SELECT @@SERVERNAME";
$stmt = $conn->query($tsql);
$result = $stmt->fetch(PDO::FETCH_NUM);
$name = $result[0];
$enabled = (strpos($result[0], 'HGS') != false);
} catch (Exception $e) {
echo $e->getMessage();
die("Could not fetch server property.");
}
return $enabled;
}
function isSQLAzure()
{
// 'SQL Azure' indicates SQL Database or SQL Data Warehouse

Просмотреть файл

@ -3,7 +3,7 @@ Test some basics of Azure AD Access Token support
--DESCRIPTION--
This test also expects certain exceptions to be thrown under some conditions.
--SKIPIF--
<?php require('skipif.inc');
<?php require('skipif_azure.inc');
require('skipif_azure_ad_acess_token.inc'); ?>
--FILE--
<?php

Просмотреть файл

@ -8,21 +8,17 @@ the error message of one test case is not the same.
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
require_once("MsSetup.inc");
require_once('MsSetup.inc');
require_once('MsCommon_mid-refactor.inc');
$msodbcsqlMaj = "";
$hgsEnabled = true;
$hgsEnabled = isServerHGSEnabled();
try {
$conn = new PDO("sqlsrv:server = $server", $uid, $pwd);
$msodbcsqlVer = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)['DriverVer'];
$version = explode(".", $msodbcsqlVer);
$msodbcsqlMaj = $version[0];
// Next, check if the server is HGS enabled
$serverInfo = $conn->getAttribute(PDO::ATTR_SERVER_INFO);
if (strpos($serverInfo['SQLServerName'], 'PHPHGS') === false) {
$hgsEnabled = false;
}
} catch (PDOException $e) {
echo "Failed to connect\n";
print_r($e->getMessage());
@ -32,7 +28,6 @@ try {
testColumnEncryption($server, $uid, $pwd, $msodbcsqlMaj);
echo "Done";
function verifyOutput($PDOerror, $expected, $caseNum)
{
if (strpos($PDOerror->getMessage(), $expected) === false) {

Просмотреть файл

@ -1,7 +1,8 @@
--TEST--
Test PDO::__Construct by passing connection options and attributes.
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
<?php require('skipif_azure.inc');
require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
require_once("MsCommon_mid-refactor.inc");

Просмотреть файл

@ -1,7 +1,8 @@
--TEST--
Test PDO::__Construct by passing connection options
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
<?php require('skipif_azure.inc');
require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
require_once("MsCommon_mid-refactor.inc");

Просмотреть файл

@ -6,3 +6,9 @@ require 'MsSetup.inc';
if ($daasMode) {
die("skip test not applicable in Azure\n");
}
require_once('MsCommon_mid-refactor.inc');
if (isServerHGSEnabled()) {
die("skip test not applicable in Azure VM\n");
}
?>

Просмотреть файл

@ -34,7 +34,7 @@ if ($msodbcsqlMin < 4 and $msodbcsqlMaj == 17) {
// Get SQL Server
$serverInfo = $conn->getAttribute(PDO::ATTR_SERVER_INFO);
if (strpos($serverInfo['SQLServerName'], 'PHPHGS') === false) {
if (strpos($serverInfo['SQLServerName'], 'HGS') === false) {
die("skip Server is not HGS enabled");
}
?>

Просмотреть файл

@ -94,6 +94,21 @@ function isLocaleDisabled()
return ($daasMode || $localeDisabled);
}
function isServerHGSEnabled()
{
$conn = connect();
$tsql = "SELECT @@SERVERNAME";
$stmt = sqlsrv_query($conn, $tsql);
if (sqlsrv_fetch($stmt)) {
$name = sqlsrv_get_field($stmt, 0);
if (strpos($name, 'HGS') != false) {
return true;
}
}
return false;
}
function isSQLAzure()
{
// 'SQL Azure' indicates SQL Database or SQL Data Warehouse

Просмотреть файл

@ -7,4 +7,8 @@ if (!extension_loaded("sqlsrv")) {
require 'MsSetup.inc';
if ($daasMode) die("skip test not applicable in Azure\n");
require 'MsCommon.inc';
if (isServerHGSEnabled()) {
die("skip test not applicable in Azure VM\n");
}
?>

Просмотреть файл

@ -34,7 +34,7 @@ if ($msodbcsql_min < 4 and $msodbcsql_maj == 17) {
// Get SQL Server
$server_info = sqlsrv_server_info($conn);
if (strpos($server_info['SQLServerName'], 'PHPHGS') === false) {
if (strpos($server_info['SQLServerName'], 'HGS') === false) {
die("skip Server is not HGS enabled");
}
?>

Просмотреть файл

@ -3,7 +3,7 @@ Test some basics of Azure AD Access Token support
--DESCRIPTION--
This test also expects certain exceptions to be thrown under some conditions.
--SKIPIF--
<?php require('skipif.inc');
<?php require('skipif_azure.inc');
require('skipif_azure_ad_acess_token.inc'); ?>
--FILE--
<?php

Просмотреть файл

@ -9,7 +9,7 @@ the error message of one test case is not the same.
--FILE--
<?php
sqlsrv_configure('WarningsReturnAsErrors', 0);
require('MsSetup.inc');
require('MsCommon.inc');
$connectionOptions = array("Database"=>$database,"UID"=>$userName, "PWD"=>$userPassword);
testColumnEncryption($server, $connectionOptions);
@ -25,11 +25,7 @@ function testColumnEncryption($server, $connectionOptions)
$msodbcsqlMaj = explode(".", $msodbcsql_ver)[0];
// Next, check if the server is HGS enabled
$hgsEnabled = true;
$serverInfo = sqlsrv_server_info($conn);
if (strpos($serverInfo['SQLServerName'], 'PHPHGS') === false) {
$hgsEnabled = false;
}
$hgsEnabled = isServerHGSEnabled();
// Only works for ODBC 17
$connectionOptions['ColumnEncryption'] = 'Enabled';