SaveResults2Database.rst 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. Save Testrun Results to Database
  2. ================================
  3. One of the options that ``baangt`` provides to save the results of the executed Testruns is using an SQL database.
  4. The identification of the database is implemented via the environmental variable BAANGT_RESULTS_DATABASE_URL.
  5. if ``baangt`` cannot retrieve BAANGT_RESULTS_DATABASE_URL it uses the default database URL:
  6. ``sqlite:///testrun.db``
  7. Tables
  8. ------
  9. Table: ``testruns``
  10. ^^^^^^^^^^^^^^^^^^^
  11. Table holds results of the executed Testruns: Testrun Logs
  12. .. list-table:: Testrun Logs
  13. :widths: 25 15 60
  14. :header-rows: 1
  15. * - Column
  16. - Data Type
  17. - Description
  18. * - id
  19. - BINARY
  20. - Testrun Log UUID. Primary key for Testrun Log.
  21. * - testrunName
  22. - VARCHAR
  23. - A name associated with the Testrun.
  24. * - logfileName
  25. - VARCHAR
  26. - Path to the logfile of the Testrun.
  27. * - startTime
  28. - DATETIME
  29. - Satrt time of the Testrun execution.
  30. * - endTime
  31. - DATETIME
  32. - End time of the Testrun execurtion.
  33. * - dataFile
  34. - VARCHAR
  35. - Path to the Data File of the Testrun.
  36. * - statusOk
  37. - INTEGER
  38. - Number of the successful test cases within the executed Testrun.
  39. * - statusFailed
  40. - INTEGER
  41. - Number of the failed test cases within the executed Testrun.
  42. * - statusPaused
  43. - INTEGER
  44. - Number of the paused test cases within the executed Testrun.
  45. Table: ``testCaseSequences``
  46. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  47. Table holds data on the executed test case sequences: TestCaseSequence Logs
  48. .. list-table:: TestCaseSequence Logs
  49. :widths: 25 15 60
  50. :header-rows: 1
  51. * - Column
  52. - Data Type
  53. - Description
  54. * - id
  55. - BINARY
  56. - TestCaseSequence Log UUID. Primary key for TestCaseSequence Log.
  57. * - testrun_id
  58. - INTEGER
  59. - Foreign key to ``testruns``
  60. Testrun that contains the test case sequence.
  61. Table: ``testCases``
  62. ^^^^^^^^^^^^^^^^^^^^
  63. Table holds data on the executed test cases: TestCase Logs
  64. .. list-table:: TestCase Logs
  65. :widths: 25 15 60
  66. :header-rows: 1
  67. * - Column
  68. - Data Type
  69. - Description
  70. * - id
  71. - BINARY
  72. - TestCase Log UUID. Primary key for TestCase Log.
  73. * - testcase_sequence_id
  74. - INTEGER
  75. - Foreign key to ``testCaseSequences``
  76. Test case sequence that contains the test case.
  77. Table: ``globals``
  78. ^^^^^^^^^^^^^^^^^^
  79. Table holds global variables of the executed Testruns
  80. .. list-table:: Globals
  81. :widths: 25 15 60
  82. :header-rows: 1
  83. * - Column
  84. - Data Type
  85. - Description
  86. * - id
  87. - INTEGER
  88. - Primary key for the global variable.
  89. * - name
  90. - VARCHAR
  91. - Name of the global variable.
  92. * - value
  93. - VARCHAR
  94. - Value of the global variable.
  95. * - testrun_id
  96. - INTEGER
  97. - Foreign key to ``testruns``
  98. Testrun that contains the global variable.
  99. Table: ``testCaseFields``
  100. ^^^^^^^^^^^^^^^^^^^^^^^^^
  101. Table holds log fields of the executed test cases
  102. .. list-table:: Testcase Fields
  103. :widths: 25 15 60
  104. :header-rows: 1
  105. * - Column
  106. - Data Type
  107. - Description
  108. * - id
  109. - INTEGER
  110. - Primary key for the field.
  111. * - name
  112. - VARCHAR
  113. - Name of the field.
  114. * - value
  115. - VARCHAR
  116. - Value of the field.
  117. * - testcase_id
  118. - INTEGER
  119. - Foreign key to ``testCases``
  120. Test case that contains the field.
  121. Table: ``networkInfo``
  122. ^^^^^^^^^^^^^^^^^^^^^^
  123. Table holds info on requests made while execution of the test cases
  124. .. list-table:: Network Info
  125. :widths: 25 15 60
  126. :header-rows: 1
  127. * - Column
  128. - Data Type
  129. - Description
  130. * - id
  131. - INTEGER
  132. - Primary key for the network info.
  133. * - browserName
  134. - VARCHAR
  135. - Browser name that was used to make the request.
  136. * - status
  137. - INTEGER
  138. - The status code of the HTTP response.
  139. * - method
  140. - VARCHAR
  141. - The request method.
  142. * - url
  143. - VARCHAR
  144. - The request URL.
  145. * - contentType
  146. - VARCHAR
  147. - Content-type header of the response.
  148. * - contentSize
  149. - INTEGER
  150. - The size of the response content.
  151. * - headers
  152. - VARCHAR
  153. - A string that represents a list of the response headers in format:
  154. ``{'name': HEADER_NAME, 'value': HEADER_VALUE}``
  155. * - params
  156. - VARCHAR
  157. - A string that represents a list of the request GET parameters in format:
  158. ``{'name': PARAMETER_NAME, 'value': PARAMETER_VALUE}``
  159. * - response
  160. - VARCHAR
  161. - The content of the response.
  162. * - startDateTime
  163. - DATETIME
  164. - The time when the request was sent.
  165. * - duration
  166. - INTEGER
  167. - The time (in ``ms``) that it took to receive the response after the request was sent.
  168. * - testcase_id
  169. - INTEGER
  170. - Foreign key to ``testCases``
  171. Test case that contains the network info.
  172. For Developers: ORM API
  173. --------------------------
  174. ``baangt`` provides ORM models to facilatate analysis of Testruns results.
  175. The models are located in module ``baangt.base.DataBaseORM``
  176. TestrunLog
  177. ^^^^^^^^^^^
  178. Provides interface with table ``testruns``
  179. .. list-table:: baangt.base.DataBaseORM.TestrunLog
  180. :widths: 30 70
  181. :header-rows: 1
  182. * - Attribute
  183. - Description
  184. * - id
  185. - Testrun Log UUID as a bianry string.
  186. * - testrunName
  187. - Name of the associated TestRun.
  188. * - logfileName
  189. - Path to the associated log file.
  190. * - startTime
  191. - TestRun start time as a ``datetime.datetime`` object.
  192. * - endTime
  193. - TestRun start time as a ``datetime.datetime`` object.
  194. * - dataFile
  195. - Path to the associated Data File.
  196. * - statusOk
  197. - Number of the successful test cases.
  198. * - statusFailed
  199. - Number of the failed test cases.
  200. * - statusPaused
  201. - Number of the paused test cases.
  202. * - globalVars
  203. - List of the global attributes (as ``GlobalAttribute`` instances) of the associated Testrun.
  204. * - testcase_sequences
  205. - List of the test case sequences (as ``TestCaseSequenceLog`` instances) within the associated Testrun.
  206. * - __str__()
  207. - Method. Returns Testrun Log UUID as a string.
  208. * - to_json()
  209. - Method. Returns Testrun Log as a dictionary object.
  210. TestCaseSequenceLog
  211. ^^^^^^^^^^^^^^^^^^^
  212. Provides interface with table ``testCaseSequences``
  213. .. list-table:: baangt.base.DataBaseORM.TestCaseSequenceLog
  214. :widths: 30 70
  215. :header-rows: 1
  216. * - Attribute
  217. - Description
  218. * - id
  219. - TestCase Sequence Log UUID as a bianry string.
  220. * - testrun
  221. - The associated Testrun (as a ``TestrunLog`` instance).
  222. * - testcases
  223. - List of the test cases (as ``TestCaseLog`` instances) within the associated Test Case Sequence.
  224. * - __str__()
  225. - Method. Returns TestCase Sequence Log UUID as a string.
  226. * - to_json()
  227. - Method. Returns TestCase Sequence Log as a dictionary object.
  228. TestCaseLog
  229. ^^^^^^^^^^^
  230. Provides interface with database table ``testCases``
  231. .. list-table:: baangt.base.DataBaseORM.TestCaseLog
  232. :widths: 30 70
  233. :header-rows: 1
  234. * - Attribute
  235. - Description
  236. * - id
  237. - TestCase Log UUID as a bianry string.
  238. * - testcase_sequence
  239. - The associated Test Case Sequence (as a ``TestCaseSequenceLog`` instance).
  240. * - fields
  241. - List of the attributes (as ``TestCaseField`` instances) of the associated Test Case.
  242. * - networkInfo
  243. - List of the network requests (as ``TestCaseNetworkInfo`` instances) made while executing the associated Test Case.
  244. * - __str__()
  245. - Method. Returns TestCase Log UUID as a string.
  246. * - to_json()
  247. - Method. Returns TestCase Log as a dictionary object.
  248. GlobalAttribute
  249. ^^^^^^^^^^^^^^^
  250. Provides interface with table ``globals``
  251. .. list-table:: baangt.base.DataBaseORM.GlobalAttribute
  252. :widths: 30 70
  253. :header-rows: 1
  254. * - Attribute
  255. - Description
  256. * - name
  257. - Name of the global attribute.
  258. * - value
  259. - Value of the global attribute as a string.
  260. * - testrun
  261. - The associated Testrun (as a ``TestrunLog`` instance).
  262. TestCaseField
  263. ^^^^^^^^^^^^^
  264. Provides interface with table ``testCaseFields``
  265. .. list-table:: baangt.base.DataBaseORM.TestCaseField
  266. :widths: 30 70
  267. :header-rows: 1
  268. * - Attribute
  269. - Description
  270. * - name
  271. - Name of the Test Case Field.
  272. * - value
  273. - Value of the Test Case Field as a string.
  274. * - testcase
  275. - The associated test case (as a ``TestCaseLog`` instance).
  276. TestCaseNetworkInfo
  277. ^^^^^^^^^^^^^^^^^^^
  278. Provides interface with table ``networkInfo``
  279. .. list-table:: baangt.base.DataBaseORM.TestCaseField
  280. :widths: 30 70
  281. :header-rows: 1
  282. * - Attribute
  283. - Description
  284. * - browserName
  285. - Browser name that mede the request.
  286. * - status
  287. - Status code of the request as an integer.
  288. * - method
  289. - The request method used.
  290. * - url
  291. - The request URL.
  292. * - contentType
  293. - Type of the response content as a string.
  294. * - contentSize
  295. - Size of the response content as an integer.
  296. * - headers
  297. - A lList of the response headers as a string.
  298. * - params
  299. - A list of the request GET parameters as a string.
  300. * - response
  301. - The response content as a string.
  302. * - startDateTime
  303. - The request start time as a ``datetime.datetime`` object.
  304. * - duration
  305. - The duration of the request in ``ms``.
  306. * - testcase
  307. - The associated test case (as a ``TestCaseLog`` instance).
  308. * - to_json()
  309. - Method. Returns the network info as a dictionary object.