Test scripts for Win32::SqlServer

This text gives some information on the test suite for Win32::SqlServer. I have tried to forsee differences your environment that may in relation to mine, but it is likely you will see errors if your ANSI Code Page is not Windows Latin-1. Which does not mean that Win32::SqlServer only runs with Latin-1. It only means that the test script are not perfect. Or so I hope.

Requirements for Running the Scripts

Obviously you need SQL Server. It can be any version of SQL Server supported by Win32::SqlServer. Which tests that are performed depends on the SQL Server version: Generally, the higher the version, the more tests. You will not see very much "Skipped" though, as the test scripts mainly skips even that part when a test cannot be performed because of the server version.

One thing is a must for running the entire test suite: you must be running with sysadmin privileges. Three of the test scripts create databases and one creates a login. Many scripts also create tables and executable objects in tempdb. If the script terminates normally, it drops everything it creates. But if a script crashes, you may have to clean up manually. Below, I detail what each script creates. It goes without saying that you should not run the test scripts on a production server.

Running the Test Scripts

All test scripts looks at the environment variable OLLEDBTEST. This variable controls which server(s) the test scripts should access. OLLEDBTEST has this format:

    Server1;User1;Pwd1;Server2;User2;Pwd2

If you don't specify Server1, the test script uses the default instance on the local machine. If you don't specify User1, the test scripts logs in with Windows authentication. Server2 is a second server, and is needed for some tests in the script 9_loginproperties. If you don't specify Server2, or it is the same as Server1, those tests are skipped. Example: to run the test at the server DEVSERVER with Windows authentication, and skip tests that requre a second server, simply say:

   SET OLLEDBTEST=DEVSERVER

To run the test on your local server and DEVSERVER as a second server, now with SQL authentication, you would say:

   SET OLLEDBTEST=.;;;DEVSERVER;sa;notstrong

The simplest way to run the scripts is to run them with MAKE test. You can also run them from the source directory as:

   perl t/1_resultsets.t > test.out 2>&1

The search the output file for "not ok". Some test scripts run a awful lot of tests (because they iterate over combinations), so you really need to catch the output in a file.

Reporting Errors from Tests

If you run a test script and one or more tests fail, please don't just tell me that test 324 in some script failed, put please send me the full output from the script. The test numbers are assigned dynamically in several of the scripts, so I will not be able to find which is test 324.

The Test Scripts

1_resultsets.t

Tests: the various row and result styles.

Number of tests: 160.

Creates in SQL Server: Temporary tables only.

2_datatypes.t

Tests: that Win32::SqlServer handle all SQL Server data types correctly. As a side effect it also tests sql_sp(), sql_insert() and that the log file is correctly constructed.

Number of tests: Many. From a little below 1100 on SQL 6.5 to over 2700 on SQL 2005 when you have SQL Native Client and the CLR enabled.

Creates in SQL Server: Tables and stored procedures in tempdb, and on SQL 2005 also an XML schema colletcion and three CLR user-defined types (the latter only if CLR is enabled).

3_retvalues.t

Tests: retrun values of different data types from stored procedures and user-defined functions for sql_sp().

Number of tests: 7 (on SQL 6.5 and SQL 7), 33-43 (SQL 2000 and SQL 2005).

Creates in SQL Server: stored procedures and user-defined function in tempdb, and on SQL 2005 also an XML schema collection and CLR user-defined types (if the CLR is enabled).

4_conversion_t

Tests: the charset conversion you can set up with sql_set_conversion(). If your OEM code page is not CP850 or CP437, this script is skipped entirely.

Notes: the script requires Win32::Registry and will not compile if this module is not available. The script assumes that the default character set of your server is Latin-1. If it is not, it is likely that several tests will fail.

Number of tests: 23.

Creates in SQL Server: temporary objects only.

5_errors.t

Tests: the error handling.

Number of tests: 141. Some are skipped on SQL 6.5.

Creates in SQL Server: temporary objects only.

6_paramsql.t

Tests: passing parameters to sql().

Number of tests: From 12 (on SQL 6.5) to 47 (on SQL 2005 with Native Client and CLR enabled).

Creates in SQL Server: On SQL 2000 and earlier, this script does not create any objects. On SQL 2005, it creates an XML schema collection in tempdb, as well as three CLR user-defined types, if the CLR is enabled.

7_objectnames.t

Tests: how Win32::SqlServerlooks up the procedure and table names for sql_sp() and sql_insert(), and also how it parses the "typeinfo" argument for the UDT and xml data types in SQL 2005.

Number of tests: 52 (SQL 6.5), 553 (SQL 7, SQL 2000 and SQL 2005 with SQLOLEDB), 917 (SQL 2005 with SQL Native Client).

Creates in SQL Server: This script creates no less than five databases (two on SQL 6.5). Four of them have names starting in "OlleDB" or Olle$DB", and the fifth has all Greek letters, Ρεκσμοερνγως. The script also creates objects in these databases and adds guest as user.

8_threads.t

Tests: Win32::SqlServer with Perl threads.

Number of tests: 24.

Creates in SQL Server: nothing.

9_loginproperties.t

Tests: setloginproperty() and other connection routines.

Notes: to perform all tests, this script requires that you have defined a second test server with the OLLEDBTEST environment variable.

Number of tests: 33, whereof three will be skipped if no second server is defined. Some tests are skipped depedning on the SQL Server and the provider. Only with SQL 2005 and SQL Native Client and a second server all tests will be performed. And even then two tests will be skipped if SQL Server is configured for Windows authentication only.

Creates in SQL Server: Creates a database which it detaches and then reattaches with a different names. Both names start with "OlleDB". On SQL 2005, if SQL Server authenticiation is enabled, the script creates a login with the name starting in "Olle" followed by random digits. The script creates the login with CHECK_POLICY = OFF. As all other objects the test script creates, the login is dropped if the script terminates normally. No objects are created in the second server.

A_rowsetprops.t

Tests the properties CommandTimeout and QueryNotification.

Notes: This script runs for almost a minute, because of a 45-second WAITFOR to test CommandTimeout.

Number of tests: 11 (With SQLOLEDB), 9 (SQL Native Client and SQL 2000 or earlier), 16 (With SQL Native Client and SQL 2005).

Creates in SQL Server: On SQL 2005 when you have SQL Native Client. the script creates a database, OlleQN, in which it creates a broker service service and a queue. In the other test cases, no objects are created.

Subdirectories to t

There are two subdirectories in the t directory:

Helpers - Here you find the source code for the three CLR types that are used in the test, and a Perl script to create them. Here is also a short program in VB6 which is used to generate and interpret date in regional settings for the DATETIME_REGIONAL setting.

Output - This directory holds output files from some of the test scripts. Most of them comes from 5_errors.t, but also 2_datatypes.t and 8_threads.t generate output files.


Last updated 06-04-17 21:42