Presentation is loading. Please wait.

Presentation is loading. Please wait.

Massive Stochastic Testing of SQL Don Slutz Microsoft Research Presented By Manan Shah.

Similar presentations


Presentation on theme: "Massive Stochastic Testing of SQL Don Slutz Microsoft Research Presented By Manan Shah."— Presentation transcript:

1 Massive Stochastic Testing of SQL Don Slutz Microsoft Research Presented By Manan Shah

2 Testing a Database Two Broad Aspects: Two Broad Aspects: Testing the correctness of the SQL Engine Testing the correctness of the SQL Engine Testing the correctness of the SQL output Testing the correctness of the SQL output Focus of this paper: Focus of this paper: Testing the correctness of the SQL Engine. Testing the correctness of the SQL Engine.

3 Test Coverage Problem All possible SQL Used by customers SQL test library Detectable software bugs

4 Background SQL test groups focus on deterministic testing to cover individual features of the language. Typical SQL test libraries require an estimated ½ person-hour per statement to compose. Software engineering requires a substantial investment Commercial SQL vendors with tight schedules tend to use a more ad hoc process.

5 Motivation Deterministic testing of SQL database systems is human intensive. The input domain, all SQL statements, from any number of users, with all states of the database, is gigantic. These test libraries cover an important, but tiny, fraction of the SQL input domain. Large increases in test coverage must come from automating the generation of tests.

6 Our Aim All possible SQL Used by customers SQL test library Detectable software bugs

7 Introduction This paper describes a method to rapidly create a very large number of SQL statements without human intervention. The SQL statements are generated stochastically. Stochastic testing has the advantage that the quality of the tests improves as the test size increases Introduces idea of cross-validation of query results against existing SQL implementations RAGS (Random Generation Of SQL) is currently used by the Microsoft SQL Server testing group.

8 SQL Grammar SELECT FROM SELECT FROM WHERE WHERE selectpartfrompart [TOP term] [DISTINCT | ALL] selectExpression [,...] * | expression [[AS] columnAlias] | tableAlias.* tableExpression [,...] {[schemaName.] tableName] [{{LEFT | RIGHT} [OUTER] | [INNER] | CROSS | NATURAL} JOIN tableExpression expression andcondition [OR andcondition] operand [conditionRightHandSide] | NOT condition | EXISTS (select)

9 Example Emp_noNameSexDept.JobSalaryComm 1JohnMR&DEngg.250002500 2MaryFSalesClerk150001500 3AndyMR&DMgr.500005000 4SamMSalesMgr.500005000 5PeteMR&DClerk150001500

10 Stochastic generation Select name salary + comm from Table Emp where and 10000salary > “sales”Dept =

11 SQL Statement Generation RAGS follows the semantic rules of SQL. Carries state information and directives on its walk down the tree and the results of stochastic outcomes as it walks up. RAGS makes all its stochastic decisions at the last possible moment

12 The RAGS System The RAGS approach is: 1. Greatly enlarge the shaded circle in the figure by stochastic SQL statement generation. 2. Make all aspects of the generated SQL statements configurable. 3. Experiment with configurations to maximize the bug detection rate.

13 The RAGS System cont… RAGS is an experiment to see how effective a million fold increase in the size of a SQL test library can be. RAGS can be used to drive an SQL system and look for observable errors The output of successful Select statements can be saved for regression testing.

14 The RAGS System Print Report Config. file DBMS1=SYS A DBMS2=SYS B 100000 Stmts 65% Select 35%Update Connect to DBMS’s Read Table Schema Loop Generate SQL Stmt Execute on SYS A Execute on SYS B Compare Results Record Errors SQL DBMS SYS A Read configuration SQL DBMS SYS B Report: 100000 Stmts exec. Stmt 156: error in SYS A Stmt 765: error in SYS B

15 Components of RAGS System The configuration file has several parameters: The configuration file has several parameters: 1. Frequency of occurrence of different statements 2. Limits (max no. of tables in a join, entries in group by, etc.) 3. Frequency of occurrence of features (group by, order by) 4. Execution Parameters (no. of rows to fetch per query) When the RAGS program is started, it first reads the configuration file. It then uses ODBC to connect to the first DBMS and read the schema information.

16 Execution of RAGS RAGS loops to generate SQL statements and optionally execute them. If the statement is executed on more than one system, the execution results are compared At the end of the run, RAGS produces a report. A utility is provided that compares the reports from several runs and summarizes the differences. The comparison can be between different vendors or different versions of the same system (regression testing).

17 Validation Issues If a SQL Select executes without errors, there is no easy method to validate the returned values The authors’ approach is to execute the same query on multiple vendor’s DBMSs and then compare the results. First, the number of rows returned is compared To avoid sorts, a special checksum over all the column values in all the rows is compared. The method only works for SQL statements that will execute on more than one vendor’s database.

18 Example RAGS Query

19 Execution Facts On a 200Mhz Pentium RAGS can generate 833 moderate size SQL statements per second. In one hour RAGS can generate 3 million different SQL statements The starting random seed for a RAGS run can be specified in the configuration file. If the starting seed is not specified, RAGS obtains a seed by hashing the time of day.

20 Testing Experiences Each of the 10 clients executed 2500 SQL statements in transactions that contained an average of 5 statements 86.1% of the statements executed without error, 13.8% had expected errors and 0.07% indicated possible bugs

21 Comparison Tests

22 Automatic Statement Simplification When a RAGS generated statement caused an error, the debugging process was difficult if the statement was complex The offending statement can usually be vastly simplified by hand. The simplification process itself was tedious, so RAGS was extended to simplify the statement automatically. RAGS walks a parse tree for the statement and tries to remove terms in expressions and certain clauses (Where and Having).

23

24 Visualization To investigate the relationship between two metrics, a set of sample pairs is collected and analyzed. RAGS presents an opportunity to scale up the size of such samples by several orders of magnitude. It allows one to plot the sample points and visualize the relationship.

25 Execution time of V2 (sec) Execution time of V1 (sec) 00.10.20.30.4 0.3 0.2 0.1

26 Summary RAGS is an experiment in massive stochastic testing of SQL systems. Its main contribution is to generate entire SQL statements stochastically The problem of validating outputs remains a tough issue. Output comparisons for different vendor’s database systems proved to be extremely useful, but only for the small set of common SQL. The outcome of the experiments was encouraging since RAGS could steadily generate errors in released SQL products.

27 Future Works SQL coverage can be extended to more data types, more DDL, stored procedures, utilities, etc. Robustness tests performed by stochastically generating a family of equivalent SQL statements and comparing their O/P Testing with equivalent statements has the important advantage of a method to help validate the outputs. The optimizer estimates of execution metrics, together with the measured execution metrics, can be compared.

28 Thank You!


Download ppt "Massive Stochastic Testing of SQL Don Slutz Microsoft Research Presented By Manan Shah."

Similar presentations


Ads by Google