2
0

README 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. Test Framework for Ado.NET
  2. December 23, 2004
  3. Table of Contents
  4. 1.0 Overview
  5. 2.0 Requirements
  6. 3.0 Design
  7. 3.1 Various Components
  8. 3.2 Low Level Design
  9. 4.0 Setup
  10. 4.1 Database Setup
  11. 4.2 Configuration
  12. 4.3 How to add new database / tables / values
  13. 5.0 DataReader tests:
  14. 5.1 Control Flow
  15. 5.2 Configuration files
  16. 5.3 How to add new queries
  17. 6.0 DataAdapter tests
  18. 6.1 Control Flow
  19. 6.2 Configuration files
  20. 6.3 How to add new queries
  21. 7.0 Running the tests
  22. 8.0 ToDo List
  23. 1.0 Overview
  24. This framework aims at testing various database providers
  25. using a common set of testcases and comparing the results
  26. with a static list. This framework abstracts
  27. the connection, table- creation and other user operations.
  28. 2.0 Requirements
  29. These are the high-level requirements :
  30. * The framework should abstract database, table,
  31. sql queries and other user operations.
  32. * The framework should provide for the setup of
  33. database tables and store procedures required
  34. before the actual tests start.
  35. * The framework should provide for comparison of
  36. results.
  37. * One should be able to run the tests for any or all
  38. of the databases
  39. * Should be extensible for newer databases
  40. 3.0 Design
  41. 3.1 Various Components:
  42. The various components of the framework are :
  43. a) Setup / Teardown of database Tables / Stored Procedures :
  44. This component is used to create test database for each of
  45. the databases to be tested. It will create tables / stored
  46. procedures /views based on testing requirements. After
  47. creating tables, it also populates values (including
  48. negative/border values) in the tables.
  49. b) Tests for DataProvider Code :
  50. The tests contained in this component try to connect
  51. to database, create commands, execute them, and retrieve
  52. results. In this component, the retrieved results are
  53. placed in a DataReader and are processed from there only.
  54. c) Tests for System.Data Code :
  55. These tests are similar to tests in (c) , except that the
  56. results retrieved from the database are populated in a
  57. DataSet, which represents an in-memory cache of data.
  58. Changes made to this DataSet are re-conciliated with the
  59. database.
  60. d) Results comparison:
  61. This does not exist as a independent component, but is
  62. an inevitable part of (c) and (d). This involves comparing
  63. the values retrieved from the database with the actual
  64. values entered.
  65. 3.2 Low Level Design
  66. Setup/Teardown of database tables/stored procedures :
  67. * All the operations to be performed on the database (like
  68. creating, dropping, inserting values ) are specified in
  69. a config file. All the data necessary for carrying out these
  70. operations (like the connection parameters, table description,
  71. column values, column types) are also specified in the
  72. config (XML) file.
  73. * The first column of each table is the serial no and is
  74. essentially the primary key. This is done to enforce
  75. ordering while data retrieval.
  76. * If any constraints have to be defined, they also have to be
  77. added to this config file.
  78. * Generic stored procedures (that are same for all tables,
  79. e.g. retrieving values from a table) are also described in
  80. the config file in the form of a template. This template has
  81. appropriate tags for table names and columns. By replacing these
  82. tags with actual names, we get the script for a stored
  83. procedure. These kinds of stored procedures, if defined, are
  84. created for all the tables described in the config file.
  85. * For stored procedures using two or more tables, appropriate
  86. tags have to be mentioned in the template. For example,
  87. the tag [[TAB2]] will have to be replaced by the name of
  88. the second table, the tag [[TAB2-COL1]] will have to replaced
  89. by the name of first column of the second table and so on. This
  90. is yet to be implemented.
  91. * For tests involving DataAdapter, Dataset, the changes that
  92. need to be done to the dataset and reconciled back to the
  93. database are also mentioned in the config file.
  94. Data Provider Tests :
  95. There is a base class which defines those members and methods
  96. that would be common for all databases. This class essentially
  97. contains members to hold the connection, commands, data readers,
  98. dataset, data adapter, etc. and has methods to query / update
  99. the database and compare the retrieved data against the actual
  100. data entered (as in the config file).
  101. We then derive a class specific to each database from this base
  102. class. These derived classes have code specific to each database.
  103. 4.0 Setup
  104. 4.1 Database Setup
  105. As mentioned in section 3.2, all the database operations and
  106. the required data has to be specified in a config file.
  107. Right now, this framework supports only four databases :
  108. * MySql
  109. * MsSql
  110. * Oracle
  111. * Postgres
  112. 4.2 Configuration
  113. The configuration file is an XML file in which there is a
  114. configuration section corresponding to each database. Under each
  115. such section, we have the following data :
  116. 1) User operations : Create/Drop tables or Insert data
  117. 2) Connection parameters : Connection strings (for connecting
  118. through ODBC and in the normal way)
  119. 3) Table definition :
  120. a) Table name
  121. b) Names and Types of columns
  122. c) Any other constraints
  123. 4) Data to be inserted into each table :
  124. a) Table number in which to enter data
  125. b) number of rows
  126. c) value to be entered in each column of various rows
  127. 5) StoredProcedures:
  128. a) Type of stored procedure (only 'generic' type is
  129. supported as of now)
  130. b) Name of the stored procedure
  131. c) Number of statements it has
  132. d) Template of the stored procedure body
  133. 4.3 How to add new database / tables / values
  134. For adding new databases, we will have to add appropriate
  135. data to the config file. Also we need to add code for connecting
  136. to the new database using appropriate providers.
  137. Adding a new table to an existing database or additional rows
  138. to an existing table, is just a config file change. While
  139. changing the config file, one must make sure that the number
  140. of tables/columns/rows are consistent with the data.
  141. 5.0 DataReader tests:
  142. 5.1 Configuration :
  143. Apart from the configuration parameteres listed in sec 4.2,
  144. here the config file also contains the queries to be run on
  145. each table.
  146. 5.2 Control Flow
  147. The control flow goes like this :
  148. 1) Create a database connection and command
  149. 2) Run each of the query and retrieve the data using a DataReader
  150. 3) Parse the query to find out what all columns were selected
  151. and from which table
  152. 4) Verify the data in the DataReader against the ones in the
  153. config file.
  154. 5.3 How to add new queries
  155. Add appropriate entries to the config file.
  156. 6.0 DataAdapter tests
  157. 6.1 Configuration files
  158. In addition to the configuration parameters mentioned in sec 5.1,
  159. we also have a list of changes to be done to each table. These
  160. are the changes that have to done to a DataSet before updating
  161. the database.
  162. A change description contains the row and the column number to
  163. be changed and the value.
  164. 6.2 Control Flow
  165. The control flow goes like this :
  166. 1) Create a database connection and command
  167. 2) Fill a DataSet by running each of the query specified
  168. in the config file
  169. 3) Parse the query to find out what all columns were selected
  170. and from which table
  171. 4) Verify the data in the DataSet against the ones in the
  172. config file.
  173. 5) Select all data from each table.
  174. 6) Make appropriate changes to the DataSet and update
  175. the database
  176. 7) Clear and Fill the DataSet again.
  177. 8) Verify the data in the DataSet against the ones in the
  178. config file considering the changes done.
  179. 6.3 How to add new queries
  180. Config file change.
  181. 7.0 Running the tests
  182. The setup and the tests can be done by issuing a
  183. 'make run-test'
  184. under 'System.Data/Test/DataProviderTests' directory. Doing this will
  185. first do the setup of databases and run tests for data readers and
  186. data adapters.
  187. Doing a 'make run-test' under any of the subdirectories 'datadaptertests'
  188. or 'datareadertests' will run the tests for Data Apadters and
  189. DataReaders only.
  190. To run tests for a specific database, one needs to do a :
  191. 'make DATABASE=<db> run-test'
  192. 8.0 ToDo List
  193. * To make the framework more extensible
  194. * Right now the framework understands simple queries (like select) only.
  195. Also querying from only one table is supported as of now. The frameowrk
  196. should be a able to understand other kinds of queries too.
  197. * Only generic stored procedures (common for all tables) are supported
  198. as of now. We might want to extend this to be able to write stored-procedures
  199. spanning more than one table, etc
  200. * Integrate with the daily tests
  201. * Better error reporting