dataops-testgen 2.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. dataops_testgen-2.2.0.dist-info/LICENSE +203 -0
  2. dataops_testgen-2.2.0.dist-info/METADATA +287 -0
  3. dataops_testgen-2.2.0.dist-info/NOTICE +5 -0
  4. dataops_testgen-2.2.0.dist-info/RECORD +270 -0
  5. dataops_testgen-2.2.0.dist-info/WHEEL +5 -0
  6. dataops_testgen-2.2.0.dist-info/entry_points.txt +2 -0
  7. dataops_testgen-2.2.0.dist-info/top_level.txt +1 -0
  8. testgen/__init__.py +0 -0
  9. testgen/__main__.py +770 -0
  10. testgen/commands/__init__.py +0 -0
  11. testgen/commands/queries/__init__.py +0 -0
  12. testgen/commands/queries/execute_cat_tests_query.py +95 -0
  13. testgen/commands/queries/execute_tests_query.py +160 -0
  14. testgen/commands/queries/generate_tests_query.py +94 -0
  15. testgen/commands/queries/profiling_query.py +366 -0
  16. testgen/commands/queries/test_parameter_validation_query.py +88 -0
  17. testgen/commands/run_execute_cat_tests.py +162 -0
  18. testgen/commands/run_execute_tests.py +168 -0
  19. testgen/commands/run_generate_tests.py +107 -0
  20. testgen/commands/run_get_entities.py +122 -0
  21. testgen/commands/run_launch_db_config.py +84 -0
  22. testgen/commands/run_observability_exporter.py +330 -0
  23. testgen/commands/run_profiling_bridge.py +495 -0
  24. testgen/commands/run_quick_start.py +168 -0
  25. testgen/commands/run_setup_profiling_tools.py +96 -0
  26. testgen/commands/run_test_definition.py +146 -0
  27. testgen/commands/run_test_parameter_validation.py +135 -0
  28. testgen/commands/run_upgrade_db_config.py +156 -0
  29. testgen/common/__init__.py +8 -0
  30. testgen/common/clean_sql.py +53 -0
  31. testgen/common/credentials.py +25 -0
  32. testgen/common/database/__init__.py +0 -0
  33. testgen/common/database/database_service.py +629 -0
  34. testgen/common/database/flavor/__init__.py +0 -0
  35. testgen/common/database/flavor/flavor_service.py +75 -0
  36. testgen/common/database/flavor/mssql_flavor_service.py +34 -0
  37. testgen/common/database/flavor/postgresql_flavor_service.py +5 -0
  38. testgen/common/database/flavor/redshift_flavor_service.py +22 -0
  39. testgen/common/database/flavor/snowflake_flavor_service.py +69 -0
  40. testgen/common/database/flavor/trino_flavor_service.py +21 -0
  41. testgen/common/date_service.py +68 -0
  42. testgen/common/display_service.py +85 -0
  43. testgen/common/docker_service.py +76 -0
  44. testgen/common/encrypt.py +55 -0
  45. testgen/common/get_pipeline_parms.py +57 -0
  46. testgen/common/logs.py +79 -0
  47. testgen/common/process_service.py +62 -0
  48. testgen/common/read_file.py +69 -0
  49. testgen/settings.py +440 -0
  50. testgen/template/dbsetup/010_create_base_schema.sql +2 -0
  51. testgen/template/dbsetup/020_create_standard_functions_sprocs.sql +179 -0
  52. testgen/template/dbsetup/030_initialize_new_schema_structure.sql +735 -0
  53. testgen/template/dbsetup/040_populate_new_schema_project.sql +59 -0
  54. testgen/template/dbsetup/050_populate_new_schema_metadata.sql +1517 -0
  55. testgen/template/dbsetup/060_create_standard_views.sql +248 -0
  56. testgen/template/dbsetup/070_create_default_users.sql +17 -0
  57. testgen/template/dbsetup/075_grant_role_rights.sql +43 -0
  58. testgen/template/dbsetup/080_set_current_revision.sql +5 -0
  59. testgen/template/dbupgrade/0100_incremental_upgrade.sql +5 -0
  60. testgen/template/dbupgrade/0101_incremental_upgrade.sql +15 -0
  61. testgen/template/dbupgrade/0102_incremental_upgrade.sql +4 -0
  62. testgen/template/dbupgrade/0103_incremental_upgrade.sql +22 -0
  63. testgen/template/dbupgrade/0104_incremental_upgrade.sql +44 -0
  64. testgen/template/dbupgrade/0105_incremental_upgrade.sql +1 -0
  65. testgen/template/dbupgrade/0106_incremental_upgrade.sql +5 -0
  66. testgen/template/dbupgrade/0107_incremental_upgrade.sql +3 -0
  67. testgen/template/dbupgrade_helpers/get_tg_revision.sql +2 -0
  68. testgen/template/exec_cat_tests/ex_cat_build_agg_table_tests.sql +116 -0
  69. testgen/template/exec_cat_tests/ex_cat_get_distinct_tables.sql +11 -0
  70. testgen/template/exec_cat_tests/ex_cat_results_parse.sql +69 -0
  71. testgen/template/exec_cat_tests/ex_cat_retrieve_agg_test_parms.sql +6 -0
  72. testgen/template/exec_cat_tests/ex_cat_test_query.sql +8 -0
  73. testgen/template/execution/ex_finalize_test_run_results.sql +37 -0
  74. testgen/template/execution/ex_get_tests_non_cat.sql +47 -0
  75. testgen/template/execution/ex_update_test_record_in_testrun_table.sql +27 -0
  76. testgen/template/execution/ex_write_test_record_to_testrun_table.sql +6 -0
  77. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_no_drops_generic.sql +48 -0
  78. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_num_incr_generic.sql +34 -0
  79. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_above_generic.sql +49 -0
  80. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_within_generic.sql +49 -0
  81. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_same_generic.sql +49 -0
  82. testgen/template/flavors/generic/exec_query_tests/ex_custom_query_generic.sql +39 -0
  83. testgen/template/flavors/generic/exec_query_tests/ex_data_match_2way_generic.sql +58 -0
  84. testgen/template/flavors/generic/exec_query_tests/ex_data_match_generic.sql +44 -0
  85. testgen/template/flavors/generic/exec_query_tests/ex_prior_match_generic.sql +37 -0
  86. testgen/template/flavors/generic/exec_query_tests/ex_relative_entropy_generic.sql +53 -0
  87. testgen/template/flavors/generic/exec_query_tests/ex_window_match_no_drops_generic.sql +46 -0
  88. testgen/template/flavors/generic/exec_query_tests/ex_window_match_same_generic.sql +59 -0
  89. testgen/template/flavors/generic/profiling/contingency_counts.sql +3 -0
  90. testgen/template/flavors/generic/validate_tests/ex_get_project_column_list_generic.sql +3 -0
  91. testgen/template/flavors/mssql/exec_query_tests/ex_relative_entropy_mssql.sql +53 -0
  92. testgen/template/flavors/mssql/profiling/project_ddf_query_mssql.sql +35 -0
  93. testgen/template/flavors/mssql/profiling/project_profiling_query_mssql.yaml +246 -0
  94. testgen/template/flavors/mssql/profiling/project_secondary_profiling_query_mssql.sql +36 -0
  95. testgen/template/flavors/mssql/setup_profiling_tools/00_drop_existing_functions_mssql.sql +8 -0
  96. testgen/template/flavors/mssql/setup_profiling_tools/01_create_functions_mssql.sql +12 -0
  97. testgen/template/flavors/mssql/setup_profiling_tools/02_create_functions_mssql.sql +54 -0
  98. testgen/template/flavors/mssql/setup_profiling_tools/create_qc_schema_mssql.sql +4 -0
  99. testgen/template/flavors/mssql/setup_profiling_tools/grant_execute_privileges_mssql.sql +1 -0
  100. testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_no_drops_postgresql.sql +46 -0
  101. testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_same_postgresql.sql +59 -0
  102. testgen/template/flavors/postgresql/profiling/project_ddf_query_postgresql.sql +42 -0
  103. testgen/template/flavors/postgresql/profiling/project_profiling_query_postgresql.yaml +225 -0
  104. testgen/template/flavors/postgresql/profiling/project_secondary_profiling_query_postgresql.sql +28 -0
  105. testgen/template/flavors/postgresql/setup_profiling_tools/create_functions_postgresql.sql +157 -0
  106. testgen/template/flavors/postgresql/setup_profiling_tools/create_qc_schema_postgresql.sql +1 -0
  107. testgen/template/flavors/postgresql/setup_profiling_tools/grant_execute_privileges_postgresql.sql +2 -0
  108. testgen/template/flavors/redshift/profiling/project_ddf_query_redshift.sql +38 -0
  109. testgen/template/flavors/redshift/profiling/project_profiling_query_redshift.yaml +221 -0
  110. testgen/template/flavors/redshift/profiling/project_secondary_profiling_query_redshift.sql +29 -0
  111. testgen/template/flavors/redshift/setup_profiling_tools/create_functions_redshift.sql +115 -0
  112. testgen/template/flavors/redshift/setup_profiling_tools/create_qc_schema_redshift.sql +1 -0
  113. testgen/template/flavors/redshift/setup_profiling_tools/grant_execute_privileges_redshift.sql +2 -0
  114. testgen/template/flavors/snowflake/profiling/project_ddf_query_snowflake.sql +38 -0
  115. testgen/template/flavors/snowflake/profiling/project_profiling_query_snowflake.yaml +220 -0
  116. testgen/template/flavors/snowflake/profiling/project_secondary_profiling_query_snowflake.sql +29 -0
  117. testgen/template/flavors/snowflake/setup_profiling_tools/create_functions_snowflake.sql +69 -0
  118. testgen/template/flavors/snowflake/setup_profiling_tools/create_qc_schema_snowflake.sql +1 -0
  119. testgen/template/flavors/snowflake/setup_profiling_tools/grant_execute_privileges_snowflake.sql +6 -0
  120. testgen/template/flavors/trino/profiling/project_profiling_query_trino.yaml +219 -0
  121. testgen/template/flavors/trino/setup_profiling_tools/create_functions_trino.sql +92 -0
  122. testgen/template/flavors/trino/setup_profiling_tools/create_qc_schema_trino.sql +1 -0
  123. testgen/template/gen_funny_cat_tests/gen_test_constant.sql +104 -0
  124. testgen/template/gen_funny_cat_tests/gen_test_distinct_value_ct.sql +98 -0
  125. testgen/template/gen_funny_cat_tests/gen_test_row_ct.sql +57 -0
  126. testgen/template/gen_funny_cat_tests/gen_test_row_ct_pct.sql +59 -0
  127. testgen/template/generation/gen_delete_old_tests.sql +5 -0
  128. testgen/template/generation/gen_insert_test_suite.sql +5 -0
  129. testgen/template/generation/gen_retrieve_or_insert_test_suite.sql +58 -0
  130. testgen/template/generation/gen_standard_test_type_list.sql +13 -0
  131. testgen/template/generation/gen_standard_tests.sql +48 -0
  132. testgen/template/get_entities/get_connection.sql +21 -0
  133. testgen/template/get_entities/get_connections_list.sql +9 -0
  134. testgen/template/get_entities/get_latest.sql +4 -0
  135. testgen/template/get_entities/get_profile.sql +12 -0
  136. testgen/template/get_entities/get_profile_info.sql +17 -0
  137. testgen/template/get_entities/get_profile_list.sql +17 -0
  138. testgen/template/get_entities/get_profile_screen.sql +275 -0
  139. testgen/template/get_entities/get_project_list.sql +6 -0
  140. testgen/template/get_entities/get_table_group_list.sql +10 -0
  141. testgen/template/get_entities/get_test_generation_list.sql +18 -0
  142. testgen/template/get_entities/get_test_info.sql +41 -0
  143. testgen/template/get_entities/get_test_results_for_run_cli.sql +16 -0
  144. testgen/template/get_entities/get_test_run_list.sql +24 -0
  145. testgen/template/get_entities/get_test_suite.sql +13 -0
  146. testgen/template/get_entities/get_test_suite_list.sql +18 -0
  147. testgen/template/get_entities/list_test_types.sql +4 -0
  148. testgen/template/observability/get_event_data.sql +23 -0
  149. testgen/template/observability/get_test_results.sql +41 -0
  150. testgen/template/observability/update_test_results_exported_to_observability.sql +12 -0
  151. testgen/template/parms/parms_profiling.sql +34 -0
  152. testgen/template/parms/parms_test_execution.sql +13 -0
  153. testgen/template/parms/parms_test_gen.sql +23 -0
  154. testgen/template/profiling/contingency_columns.sql +7 -0
  155. testgen/template/profiling/datatype_suggestions.sql +56 -0
  156. testgen/template/profiling/functional_datatype.sql +523 -0
  157. testgen/template/profiling/functional_tabletype_stage.sql +48 -0
  158. testgen/template/profiling/functional_tabletype_update.sql +8 -0
  159. testgen/template/profiling/pii_flag.sql +133 -0
  160. testgen/template/profiling/profile_anomalies_screen_column.sql +22 -0
  161. testgen/template/profiling/profile_anomalies_screen_multi_column.sql +58 -0
  162. testgen/template/profiling/profile_anomalies_screen_table.sql +22 -0
  163. testgen/template/profiling/profile_anomalies_screen_table_dates.sql +30 -0
  164. testgen/template/profiling/profile_anomalies_screen_variants.sql +40 -0
  165. testgen/template/profiling/profile_anomaly_types_get.sql +3 -0
  166. testgen/template/profiling/project_get_table_sample_count.sql +22 -0
  167. testgen/template/profiling/project_profile_run_record_insert.sql +8 -0
  168. testgen/template/profiling/project_profile_run_record_update.sql +5 -0
  169. testgen/template/profiling/project_profile_run_record_update_status.sql +5 -0
  170. testgen/template/profiling/project_update_profile_results_to_estimates.sql +32 -0
  171. testgen/template/profiling/refresh_anomalies.sql +33 -0
  172. testgen/template/profiling/refresh_data_chars_from_profiling.sql +156 -0
  173. testgen/template/profiling/secondary_profiling_columns.sql +12 -0
  174. testgen/template/profiling/secondary_profiling_delete.sql +4 -0
  175. testgen/template/profiling/secondary_profiling_update.sql +18 -0
  176. testgen/template/quick_start/populate_target_data.sql +1077 -0
  177. testgen/template/quick_start/recreate_target_data_schema.sql +167 -0
  178. testgen/template/quick_start/update_target_data.sql +100 -0
  179. testgen/template/updates/create_tmp_test_definition.sql +19 -0
  180. testgen/template/updates/get_test_def_parms.sql +38 -0
  181. testgen/template/updates/populate_stg_test_definitions.sql +184 -0
  182. testgen/template/validate_tests/ex_disable_tests_test_definitions.sql +5 -0
  183. testgen/template/validate_tests/ex_flag_tests_test_definitions.sql +64 -0
  184. testgen/template/validate_tests/ex_get_project_column_list_generic.sql +3 -0
  185. testgen/template/validate_tests/ex_get_test_column_list_tg.sql +65 -0
  186. testgen/template/validate_tests/ex_write_test_val_errors.sql +22 -0
  187. testgen/ui/__init__.py +0 -0
  188. testgen/ui/app.py +98 -0
  189. testgen/ui/assets/dk_logo.svg +46 -0
  190. testgen/ui/assets/question_mark.png +0 -0
  191. testgen/ui/assets/scripts.js +68 -0
  192. testgen/ui/assets/style.css +140 -0
  193. testgen/ui/bootstrap.py +109 -0
  194. testgen/ui/components/__init__.py +0 -0
  195. testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 +0 -0
  196. testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 +0 -0
  197. testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu4mxK.woff2 +0 -0
  198. testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 +0 -0
  199. testgen/ui/components/frontend/css/material-symbols-rounded.css +24 -0
  200. testgen/ui/components/frontend/css/material-symbols-rounded.woff2 +0 -0
  201. testgen/ui/components/frontend/css/roboto-font-faces.css +35 -0
  202. testgen/ui/components/frontend/css/shared.css +36 -0
  203. testgen/ui/components/frontend/img/dk_logo.svg +46 -0
  204. testgen/ui/components/frontend/index.html +17 -0
  205. testgen/ui/components/frontend/js/components/breadcrumbs.js +86 -0
  206. testgen/ui/components/frontend/js/components/button.js +66 -0
  207. testgen/ui/components/frontend/js/components/location.js +62 -0
  208. testgen/ui/components/frontend/js/components/select.js +75 -0
  209. testgen/ui/components/frontend/js/components/sidebar.js +358 -0
  210. testgen/ui/components/frontend/js/main.js +99 -0
  211. testgen/ui/components/frontend/js/streamlit.js +19 -0
  212. testgen/ui/components/frontend/js/van.min.js +1 -0
  213. testgen/ui/components/utils/__init__.py +0 -0
  214. testgen/ui/components/utils/callbacks.py +51 -0
  215. testgen/ui/components/utils/component.py +13 -0
  216. testgen/ui/components/widgets/__init__.py +6 -0
  217. testgen/ui/components/widgets/breadcrumbs.py +32 -0
  218. testgen/ui/components/widgets/location.py +65 -0
  219. testgen/ui/components/widgets/modal.py +97 -0
  220. testgen/ui/components/widgets/sidebar.py +69 -0
  221. testgen/ui/navigation/__init__.py +0 -0
  222. testgen/ui/navigation/menu.py +42 -0
  223. testgen/ui/navigation/page.py +20 -0
  224. testgen/ui/navigation/router.py +63 -0
  225. testgen/ui/queries/__init__.py +0 -0
  226. testgen/ui/queries/authentication_queries.py +47 -0
  227. testgen/ui/queries/connection_queries.py +121 -0
  228. testgen/ui/queries/profiling_queries.py +148 -0
  229. testgen/ui/queries/project_queries.py +9 -0
  230. testgen/ui/queries/table_group_queries.py +186 -0
  231. testgen/ui/queries/test_definition_queries.py +270 -0
  232. testgen/ui/queries/test_run_queries.py +32 -0
  233. testgen/ui/queries/test_suite_queries.py +145 -0
  234. testgen/ui/scripts/__init__.py +0 -0
  235. testgen/ui/scripts/patch_streamlit.py +111 -0
  236. testgen/ui/services/__init__.py +0 -0
  237. testgen/ui/services/authentication_service.py +119 -0
  238. testgen/ui/services/connection_service.py +220 -0
  239. testgen/ui/services/database_service.py +282 -0
  240. testgen/ui/services/form_service.py +1008 -0
  241. testgen/ui/services/javascript_service.py +44 -0
  242. testgen/ui/services/query_service.py +316 -0
  243. testgen/ui/services/string_service.py +12 -0
  244. testgen/ui/services/table_group_service.py +130 -0
  245. testgen/ui/services/test_definition_service.py +117 -0
  246. testgen/ui/services/test_run_service.py +13 -0
  247. testgen/ui/services/test_suite_service.py +76 -0
  248. testgen/ui/services/toolbar_service.py +77 -0
  249. testgen/ui/session.py +46 -0
  250. testgen/ui/views/__init__.py +0 -0
  251. testgen/ui/views/app_log_modal.py +92 -0
  252. testgen/ui/views/connections.py +72 -0
  253. testgen/ui/views/connections_base.py +367 -0
  254. testgen/ui/views/login.py +40 -0
  255. testgen/ui/views/not_found.py +16 -0
  256. testgen/ui/views/overview.py +34 -0
  257. testgen/ui/views/profiling_anomalies.py +501 -0
  258. testgen/ui/views/profiling_details.py +335 -0
  259. testgen/ui/views/profiling_modal.py +40 -0
  260. testgen/ui/views/profiling_results.py +206 -0
  261. testgen/ui/views/profiling_summary.py +177 -0
  262. testgen/ui/views/project_settings.py +74 -0
  263. testgen/ui/views/table_groups.py +530 -0
  264. testgen/ui/views/test_definitions.py +1020 -0
  265. testgen/ui/views/test_results.py +908 -0
  266. testgen/ui/views/test_runs.py +195 -0
  267. testgen/ui/views/test_suites.py +545 -0
  268. testgen/utils/__init__.py +0 -0
  269. testgen/utils/plugins.py +17 -0
  270. testgen/utils/singleton.py +14 -0
@@ -0,0 +1,168 @@
1
+ import logging
2
+ import subprocess
3
+ import threading
4
+ import uuid
5
+
6
+ import testgen.common.process_service as process_service
7
+ from testgen import settings
8
+ from testgen.commands.queries.execute_tests_query import CTestExecutionSQL
9
+ from testgen.common import (
10
+ AssignConnectParms,
11
+ RetrieveDBResultsToDictList,
12
+ RetrieveTestExecParms,
13
+ RunActionQueryList,
14
+ RunThreadedRetrievalQueryList,
15
+ WriteListToDB,
16
+ date_service,
17
+ )
18
+ from testgen.common.database.database_service import empty_cache
19
+
20
+ from .run_execute_cat_tests import run_cat_test_queries
21
+ from .run_test_parameter_validation import run_parameter_validation_queries
22
+
23
+ LOG = logging.getLogger("testgen")
24
+
25
+
26
+ def run_test_queries(strTestRunID, strTestTime, strProjectCode, strTestSuite, minutes_offset=0, spinner=None):
27
+ booErrors = False
28
+ error_msg = ""
29
+
30
+ LOG.info("CurrentStep: Retrieving TestExec Parameters")
31
+ dctParms = RetrieveTestExecParms(strProjectCode, strTestSuite)
32
+
33
+ # Set Project Connection Parms in common.db_bridgers from retrieved parms
34
+ LOG.info("CurrentStep: Assigning Connection Parms")
35
+
36
+ AssignConnectParms(
37
+ dctParms["project_code"],
38
+ dctParms["connection_id"],
39
+ dctParms["project_host"],
40
+ dctParms["project_port"],
41
+ dctParms["project_db"],
42
+ dctParms["table_group_schema"],
43
+ dctParms["project_user"],
44
+ dctParms["sql_flavor"],
45
+ dctParms["url"],
46
+ dctParms["connect_by_url"],
47
+ dctParms["connect_by_key"],
48
+ dctParms["private_key"],
49
+ dctParms["private_key_passphrase"],
50
+ "PROJECT",
51
+ )
52
+
53
+ LOG.info("CurrentStep: Initializing Query Generator")
54
+
55
+ clsExecute = CTestExecutionSQL(strProjectCode, dctParms["sql_flavor"], strTestSuite, minutes_offset)
56
+ clsExecute.run_date = strTestTime
57
+ clsExecute.test_run_id = strTestRunID
58
+ clsExecute.process_id = process_service.get_current_process_id()
59
+ booClean = False
60
+
61
+ # Add a record in Test Run table for the new Test Run
62
+ strTestRunQuery = clsExecute.AddTestRecordtoTestRunTable()
63
+ lstTestRunQuery = [strTestRunQuery]
64
+ RunActionQueryList("DKTG", lstTestRunQuery)
65
+
66
+ try:
67
+ # Retrieve non-CAT Queries
68
+ LOG.info("CurrentStep: Retrieve Non-CAT Queries")
69
+ strQuery = clsExecute.GetTestsNonCAT(booClean)
70
+ lstTestSet = RetrieveDBResultsToDictList("DKTG", strQuery)
71
+
72
+ if len(lstTestSet) == 0:
73
+ LOG.debug("0 non-CAT Queries retrieved.")
74
+
75
+ if lstTestSet:
76
+ LOG.info("CurrentStep: Preparing Non-CAT Tests")
77
+ lstTestQueries = []
78
+ for dctTest in lstTestSet:
79
+ # Set Test Parms
80
+ clsExecute.ClearTestParms()
81
+ clsExecute.dctTestParms = dctTest
82
+ lstTestQueries.append(clsExecute.GetTestQuery(booClean))
83
+ if spinner:
84
+ spinner.next()
85
+
86
+ # Execute list, returning test results
87
+ LOG.info("CurrentStep: Executing Non-CAT Test Queries")
88
+ lstTestResults, colResultNames, intErrors = RunThreadedRetrievalQueryList(
89
+ "PROJECT", lstTestQueries, dctParms["max_threads"], spinner
90
+ )
91
+
92
+ # Copy test results to DK DB
93
+ LOG.info("CurrentStep: Saving Non-CAT Test Results")
94
+ if lstTestResults:
95
+ WriteListToDB("DKTG", lstTestResults, colResultNames, "test_results")
96
+ if intErrors > 0:
97
+ booErrors = True
98
+ error_msg = (
99
+ f"Errors were encountered executing Referential Tests. ({intErrors} errors occurred.) "
100
+ "Please check log. "
101
+ )
102
+ LOG.warning(error_msg)
103
+ else:
104
+ LOG.info("No tests found")
105
+
106
+ except Exception as e:
107
+ sqlsplit = e.args[0].split("[SQL", 1)
108
+ errorline = sqlsplit[0].replace("'", "''") if len(sqlsplit) > 0 else "unknown error"
109
+ clsExecute.exception_message = f"{type(e).__name__}: {errorline}"
110
+ LOG.info("Updating the test run record with exception message")
111
+ lstTestRunQuery = [clsExecute.PushTestRunStatusUpdateSQL()]
112
+ RunActionQueryList("DKTG", lstTestRunQuery)
113
+ raise
114
+
115
+ else:
116
+ return booErrors, error_msg
117
+
118
+
119
+ def run_execution_steps_in_background(project_code, test_suite):
120
+ msg = f"Starting run_execution_steps_in_background against test suite: {test_suite}"
121
+ if settings.IS_DEBUG:
122
+ LOG.info(msg + ". Running in debug mode (new thread instead of new process).")
123
+ empty_cache()
124
+ background_thread = threading.Thread(
125
+ target=run_execution_steps,
126
+ args=(
127
+ project_code,
128
+ test_suite
129
+ ),
130
+ )
131
+ background_thread.start()
132
+ else:
133
+ LOG.info(msg)
134
+ script = ["testgen", "run-tests", "--project-key", project_code, "--test-suite-key", test_suite]
135
+ subprocess.Popen(script) # NOQA S603
136
+
137
+
138
+ def run_execution_steps(strProjectCode, strTestSuite, minutes_offset=0, spinner=None):
139
+ # Initialize required parms for all three steps
140
+ booErrors = False
141
+ error_msg = ""
142
+
143
+ strTestRunID = str(uuid.uuid4())
144
+ strTestTime = date_service.get_now_as_string_with_offset(minutes_offset)
145
+
146
+ if spinner:
147
+ spinner.next()
148
+
149
+ LOG.info("CurrentStep: Execute Step - Test Validation")
150
+ run_parameter_validation_queries(strTestRunID, strTestTime, strProjectCode, strTestSuite, True)
151
+
152
+ LOG.info("CurrentStep: Execute Step - Test Execution")
153
+ booErrors, error_msg = run_test_queries(
154
+ strTestRunID, strTestTime, strProjectCode, strTestSuite, minutes_offset, spinner
155
+ )
156
+
157
+ LOG.info("CurrentStep: Execute Step - CAT Test Execution")
158
+ if run_cat_test_queries(
159
+ strTestRunID, strTestTime, strProjectCode, strTestSuite, error_msg, minutes_offset, spinner
160
+ ):
161
+ booErrors = True
162
+
163
+ if booErrors:
164
+ str_error_status = "with errors. Check log for details."
165
+ else:
166
+ str_error_status = "successfully."
167
+ message = f"Test Execution completed {str_error_status}"
168
+ return message
@@ -0,0 +1,107 @@
1
+ import logging
2
+
3
+ from testgen.commands.queries.generate_tests_query import CDeriveTestsSQL
4
+ from testgen.common import AssignConnectParms, RetrieveDBResultsToDictList, RetrieveTestGenParms, RunActionQueryList
5
+
6
+ LOG = logging.getLogger("testgen")
7
+
8
+
9
+ def run_test_gen_queries(strTableGroupsID, strTestSuite, strGenerationSet=None):
10
+ if strTableGroupsID is None:
11
+ raise ValueError("Table Group ID was not specified")
12
+
13
+ clsTests = CDeriveTestsSQL()
14
+
15
+ # Set General Parms
16
+ booClean = False
17
+
18
+ LOG.info("CurrentStep: Retrieving General Parameters for Test Suite " + strTestSuite)
19
+ dctParms = RetrieveTestGenParms(strTableGroupsID, strTestSuite)
20
+
21
+ # Set Project Connection Parms from retrieved parms
22
+ LOG.info("CurrentStep: Assigning Connection Parameters")
23
+ AssignConnectParms(
24
+ dctParms["project_code"],
25
+ dctParms["connection_id"],
26
+ dctParms["project_host"],
27
+ dctParms["project_port"],
28
+ dctParms["project_db"],
29
+ dctParms["table_group_schema"],
30
+ dctParms["project_user"],
31
+ dctParms["sql_flavor"],
32
+ dctParms["url"],
33
+ dctParms["connect_by_url"],
34
+ dctParms["connect_by_key"],
35
+ dctParms["private_key"],
36
+ dctParms["private_key_passphrase"],
37
+ "PROJECT",
38
+ )
39
+
40
+ # Set static parms
41
+ clsTests.project_code = dctParms["project_code"]
42
+ clsTests.test_suite = strTestSuite
43
+ clsTests.test_suite_id = dctParms["test_suite_id"]
44
+ clsTests.generation_set = strGenerationSet if strGenerationSet is not None else ""
45
+ clsTests.connection_id = str(dctParms["connection_id"])
46
+ clsTests.table_groups_id = strTableGroupsID
47
+ clsTests.sql_flavor = dctParms["sql_flavor"]
48
+
49
+ clsTests.data_schema = dctParms["table_group_schema"]
50
+ if dctParms["profiling_as_of_date"] is not None:
51
+ clsTests.as_of_date = dctParms["profiling_as_of_date"].strftime("%Y-%m-%d %H:%M:%S")
52
+
53
+ if dctParms["test_suite"] is None:
54
+ LOG.info("CurrentStep: Creating new Test Suite")
55
+ strQuery = clsTests.GetInsertTestSuiteSQL(booClean)
56
+ if strQuery:
57
+ RunActionQueryList("DKTG", [strQuery])
58
+ else:
59
+ raise ValueError("Test Suite not found and could not be created")
60
+
61
+ LOG.info("CurrentStep: Compiling Test Gen Queries")
62
+
63
+ lstFunnyTemplateQueries = clsTests.GetTestDerivationQueriesAsList(booClean)
64
+ lstGenericTemplateQueries = []
65
+
66
+ # Delete old Tests
67
+ strDeleteQuery = clsTests.GetDeleteOldTestsQuery(booClean)
68
+
69
+ # Retrieve test_types as parms from list of dictionaries: test_type, selection_criteria, default_parm_columns,
70
+ # default_parm_values
71
+ strQuery = clsTests.GetTestTypesSQL(booClean)
72
+
73
+ # Execute Query
74
+ if strQuery:
75
+ lstTestTypes = RetrieveDBResultsToDictList("DKTG", strQuery)
76
+
77
+ if lstTestTypes is None:
78
+ raise ValueError("Test Type Parameters not found")
79
+ elif (
80
+ lstTestTypes[0]["test_type"] == ""
81
+ or lstTestTypes[0]["selection_criteria"] == ""
82
+ or lstTestTypes[0]["default_parm_columns"] == ""
83
+ or lstTestTypes[0]["default_parm_values"] == ""
84
+ ):
85
+ raise ValueError("Test Type parameters not correctly set")
86
+ else:
87
+ raise ValueError("Test Type Queries were not generated")
88
+
89
+ for dctTestParms in lstTestTypes:
90
+ clsTests.ClearTestParms()
91
+ clsTests.dctTestParms = dctTestParms
92
+ strQuery = clsTests.GetTestQueriesFromGenericFile(booClean)
93
+
94
+ if strQuery:
95
+ lstGenericTemplateQueries.append(strQuery)
96
+
97
+ LOG.info("TestGen CAT Queries were compiled")
98
+
99
+ # Make sure delete, then generic templates run before the funny templates
100
+ lstQueries = [strDeleteQuery, *lstGenericTemplateQueries, *lstFunnyTemplateQueries]
101
+
102
+ if lstQueries:
103
+ LOG.info("Running Test Generation Template Queries")
104
+ RunActionQueryList("DKTG", lstQueries)
105
+ return "Test generation completed successfully."
106
+ else:
107
+ return "No TestGen Queries were compiled."
@@ -0,0 +1,122 @@
1
+ import logging
2
+
3
+ from testgen.common import RetrieveDBResultsToList, read_template_sql_file
4
+ from testgen.common.encrypt import DecryptText
5
+
6
+ LOG = logging.getLogger("testgen")
7
+
8
+
9
+ def run_list_profiles(table_groups_id):
10
+ sql_template = read_template_sql_file("get_profile_list.sql", "get_entities")
11
+
12
+ sql_template = sql_template.replace("{TABLE_GROUPS_ID}", table_groups_id)
13
+
14
+ return RetrieveDBResultsToList("DKTG", sql_template)
15
+
16
+
17
+ def run_list_test_types():
18
+ sql_template = read_template_sql_file("list_test_types.sql", "get_entities")
19
+ return RetrieveDBResultsToList("DKTG", sql_template)
20
+
21
+
22
+ def run_list_projects():
23
+ sql_template = read_template_sql_file("get_project_list.sql", "get_entities")
24
+ return RetrieveDBResultsToList("DKTG", sql_template)
25
+
26
+
27
+ def run_list_connections():
28
+ sql_template = read_template_sql_file("get_connections_list.sql", "get_entities")
29
+ return RetrieveDBResultsToList("DKTG", sql_template)
30
+
31
+
32
+ def run_get_connection(connection_id):
33
+ sql_template = read_template_sql_file("get_connection.sql", "get_entities")
34
+ sql_template = sql_template.replace("{CONNECTION_ID}", str(connection_id))
35
+ rows, _ = RetrieveDBResultsToList("DKTG", sql_template)
36
+ connection = rows.pop()._asdict()
37
+ connection["password"] = DecryptText(connection["project_pw_encrypted"]) if connection["project_pw_encrypted"] else None
38
+ connection["private_key"] = DecryptText(connection["private_key"]) if connection["private_key"] else None
39
+ connection["private_key_passphrase"] = DecryptText(connection["private_key_passphrase"]) if connection["private_key_passphrase"] else ""
40
+ return connection
41
+
42
+
43
+ def run_table_group_list(project_code):
44
+ sql_template = read_template_sql_file("get_table_group_list.sql", "get_entities")
45
+ sql_template = sql_template.replace("{PROJECT_CODE}", project_code)
46
+ return RetrieveDBResultsToList("DKTG", sql_template)
47
+
48
+
49
+ def run_list_test_suites(project_code):
50
+ sql_template = read_template_sql_file("get_test_suite_list.sql", "get_entities")
51
+ sql_template = sql_template.replace("{PROJECT_CODE}", project_code)
52
+ return RetrieveDBResultsToList("DKTG", sql_template)
53
+
54
+
55
+ def run_get_test_suite(project_code, test_suite):
56
+ sql_template = read_template_sql_file("get_test_suite.sql", "get_entities")
57
+
58
+ sql_template = sql_template.replace("{PROJECT_CODE}", project_code)
59
+ sql_template = sql_template.replace("{TEST_SUITE}", test_suite)
60
+
61
+ return RetrieveDBResultsToList("DKTG", sql_template)
62
+
63
+
64
+ def run_profile_info(profile_run, table_name=None):
65
+ if not table_name:
66
+ table_name = "%" # if no table_name, we select all the tables
67
+ sql_template = read_template_sql_file("get_profile_info.sql", "get_entities")
68
+
69
+ sql_template = sql_template.replace("{PROFILE_RUN}", str(profile_run))
70
+ sql_template = sql_template.replace("{TABLE_NAME}", table_name)
71
+
72
+ return RetrieveDBResultsToList("DKTG", sql_template)
73
+
74
+
75
+ def run_profile_screen(profile_run, table_name=None):
76
+ if not table_name:
77
+ table_name = "%"
78
+ sql_template = read_template_sql_file("get_profile_screen.sql", "get_entities")
79
+
80
+ sql_template = sql_template.replace("{PROFILE_RUN}", profile_run)
81
+ sql_template = sql_template.replace("{TABLE_NAME}", table_name)
82
+
83
+ return RetrieveDBResultsToList("DKTG", sql_template)
84
+
85
+
86
+ def run_list_test_generation(project_code, test_suite):
87
+ sql_template = read_template_sql_file("get_test_generation_list.sql", "get_entities")
88
+
89
+ sql_template = sql_template.replace("{PROJECT_CODE}", project_code)
90
+ sql_template = sql_template.replace("{TEST_SUITE}", test_suite)
91
+
92
+ return RetrieveDBResultsToList("DKTG", sql_template)
93
+
94
+
95
+ def run_test_info(project_code, test_suite):
96
+ sql_template = read_template_sql_file("get_test_info.sql", "get_entities")
97
+
98
+ sql_template = sql_template.replace("{PROJECT_CODE}", project_code)
99
+ sql_template = sql_template.replace("{TEST_SUITE}", test_suite)
100
+
101
+ return RetrieveDBResultsToList("DKTG", sql_template)
102
+
103
+
104
+ def run_list_test_runs(project_code, test_suite):
105
+ sql_template = read_template_sql_file("get_test_run_list.sql", "get_entities")
106
+
107
+ sql_template = sql_template.replace("{PROJECT_CODE}", project_code)
108
+ sql_template = sql_template.replace("{TEST_SUITE}", test_suite)
109
+
110
+ return RetrieveDBResultsToList("DKTG", sql_template)
111
+
112
+
113
+ def run_get_results(test_run_id, booErrorsOnly):
114
+ sql_template = read_template_sql_file("get_test_results_for_run_cli.sql", "get_entities")
115
+
116
+ sql_template = sql_template.replace("{TEST_RUN_ID}", test_run_id)
117
+ if booErrorsOnly:
118
+ sql_template = sql_template.replace("{ERRORS_ONLY}", "AND result_code = 0")
119
+ else:
120
+ sql_template = sql_template.replace("{ERRORS_ONLY}", "")
121
+
122
+ return RetrieveDBResultsToList("DKTG", sql_template)
@@ -0,0 +1,84 @@
1
+ import logging
2
+ import os
3
+
4
+ from testgen import settings
5
+ from testgen.common import CreateDatabaseIfNotExists, RunActionQueryList, date_service
6
+ from testgen.common.credentials import get_tg_db, get_tg_schema
7
+ from testgen.common.database.database_service import get_queries_for_command
8
+ from testgen.common.encrypt import EncryptText, encrypt_ui_password
9
+ from testgen.common.read_file import get_template_files
10
+
11
+ LOG = logging.getLogger("testgen")
12
+
13
+
14
+ def _get_latest_revision_number():
15
+ files = sorted(get_template_files(mask=r"^.*sql$", sub_directory="dbupgrade"), key=lambda key: str(key))
16
+ last_file = os.path.basename(str(files[-1]))
17
+ return str(int(last_file.split("_")[0])) # Drop leading zeroes via str-->int-->str
18
+
19
+
20
+ def _get_params_mapping() -> dict:
21
+ ui_user_encrypted_password = encrypt_ui_password(settings.PASSWORD)
22
+
23
+ now = date_service.get_now_as_string()
24
+ return {
25
+ "UI_USER_NAME": settings.USERNAME,
26
+ "UI_USER_USERNAME": settings.USERNAME,
27
+ "UI_USER_EMAIL": "",
28
+ "UI_USER_ENCRYPTED_PASSWORD": ui_user_encrypted_password,
29
+ "SCHEMA_NAME": get_tg_schema(),
30
+ "START_DATE": now,
31
+ "PROJECT_CODE": settings.PROJECT_KEY,
32
+ "CONNECTION_ID": 1,
33
+ "SQL_FLAVOR": settings.PROJECT_SQL_FLAVOR,
34
+ "PROJECT_NAME": settings.PROJECT_NAME,
35
+ "PROJECT_DB": settings.PROJECT_DATABASE_NAME,
36
+ "PROJECT_USER": settings.PROJECT_DATABASE_USER,
37
+ "PROJECT_PORT": settings.PROJECT_DATABASE_PORT,
38
+ "PROJECT_HOST": settings.PROJECT_DATABASE_HOST,
39
+ "PROJECT_SCHEMA": settings.PROJECT_DATABASE_SCHEMA,
40
+ "PROFILING_TABLE_SET": settings.DEFAULT_PROFILING_TABLE_SET,
41
+ "PROFILING_INCLUDE_MASK": settings.DEFAULT_PROFILING_INCLUDE_MASK,
42
+ "PROFILING_EXCLUDE_MASK": settings.DEFAULT_PROFILING_EXCLUDE_MASK,
43
+ "PROFILING_ID_COLUMN_MASK": settings.DEFAULT_PROFILING_ID_COLUMN_MASK,
44
+ "PROFILING_SK_COLUMN_MASK": settings.DEFAULT_PROFILING_SK_COLUMN_MASK,
45
+ "PROFILING_USE_SAMPLING": settings.DEFAULT_PROFILING_USE_SAMPLING,
46
+ "PROFILING_SAMPLE_PERCENT": "",
47
+ "PROFILING_SAMPLE_MIN_COUNT": "",
48
+ "PROFILING_DELAY_DAYS": "",
49
+ "CONNECTION_NAME": settings.PROJECT_CONNECTION_NAME,
50
+ "PROJECT_QC_SCHEMA": settings.PROJECT_QC_SCHEMA,
51
+ "TABLE_GROUPS_NAME": settings.DEFAULT_TABLE_GROUPS_NAME,
52
+ "TEST_SUITE": settings.DEFAULT_TEST_SUITE_KEY,
53
+ "TEST_SUITE_DESCRIPTION": settings.DEFAULT_TEST_SUITE_DESCRIPTION,
54
+ "MAX_THREADS": settings.PROJECT_CONNECTION_MAX_THREADS,
55
+ "MAX_QUERY_CHARS": settings.PROJECT_CONNECTION_MAX_QUERY_CHAR,
56
+ "PROJECT_PW_ENCRYPTED": EncryptText(settings.PROJECT_DATABASE_PASSWORD),
57
+ "OBSERVABILITY_API_URL": settings.OBSERVABILITY_API_URL,
58
+ "OBSERVABILITY_API_KEY": settings.OBSERVABILITY_API_KEY,
59
+ "OBSERVABILITY_COMPONENT_KEY": settings.OBSERVABILITY_DEFAULT_COMPONENT_KEY,
60
+ "OBSERVABILITY_COMPONENT_TYPE": settings.OBSERVABILITY_DEFAULT_COMPONENT_TYPE,
61
+ "TESTGEN_ADMIN_USER": settings.DATABASE_ADMIN_USER,
62
+ "TESTGEN_ADMIN_PASSWORD": settings.DATABASE_ADMIN_PASSWORD,
63
+ "TESTGEN_USER": settings.DATABASE_EXECUTE_USER,
64
+ "TESTGEN_PASSWORD": settings.DATABASE_PASSWORD,
65
+ "TESTGEN_REPORT_USER": settings.DATABASE_REPORT_USER,
66
+ "TESTGEN_REPORT_PASSWORD": settings.DATABASE_PASSWORD,
67
+ "DB_REVISION": _get_latest_revision_number(),
68
+ }
69
+
70
+
71
+ def run_launch_db_config(delete_db: bool) -> None:
72
+ params_mapping = _get_params_mapping()
73
+
74
+ CreateDatabaseIfNotExists(get_tg_db(), params_mapping, delete_db)
75
+
76
+ queries = get_queries_for_command("dbsetup", params_mapping)
77
+
78
+ RunActionQueryList(
79
+ "DKTG",
80
+ queries,
81
+ "S",
82
+ user_override=params_mapping["TESTGEN_ADMIN_USER"],
83
+ pwd_override=params_mapping["TESTGEN_ADMIN_PASSWORD"],
84
+ )