Megatest

Check-in [97e7119428]
Login
Overview
Comment:Made -cleanup-db remove test_steps and tests from deleted runs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.80-revolution
Files: files | file ages | folders
SHA1: 97e7119428d335bb3b6df7b04b381b1a8c982c72
User & Date: mmgraham on 2023-12-22 13:52:20
Other Links: branch diff | manifest | tags
Context
2023-12-22
14:17
Added -regen-testfiles and added pre/post test triggers. [setup] precmd, postcmd. User responsible for blocking/non-blocking, i.e. use nbfake for non-blocking. check-in: 215b2cc63b user: mrwellan tags: v1.80-revolution
13:52
Made -cleanup-db remove test_steps and tests from deleted runs. check-in: 97e7119428 user: mmgraham tags: v1.80-revolution
2023-12-21
11:18
Cherry picked 1e29e5e90e to fix db syncing. check-in: 4d3f148ed5 user: mmgraham tags: v1.80-revolution
Changes

Modified db.scm from [4c9582503f] to [678efe323e].

1187
1188
1189
1190
1191
1192
1193
1194

1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215

1216
1217
1218


1219
1220
1221
1222
1223
1224
1225
1226



1227
1228
1229
1230
1231
1232
1233
1234




1235
1236
1237



1238

1239
1240
1241


1242
1243
1244
1245
1246
1247
1248
1249
1187
1188
1189
1190
1191
1192
1193

1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214

1215
1216
1217

1218
1219
1220
1221
1222
1223




1224
1225
1226
1227

1228
1229
1230
1231
1232

1233
1234
1235
1236
1237
1238
1239
1240
1241
1242

1243
1244


1245
1246

1247
1248
1249
1250
1251
1252
1253







-
+




















-
+


-
+
+




-
-
-
-
+
+
+

-





-
+
+
+
+



+
+
+
-
+

-
-
+
+
-







;;    a. If have tests that are not deleted, set state='unknown'
;;    b. ....
;;
(define (db:clean-up run-id dbdat)
  (if run-id
    (begin
      (debug:print 0 *default-log-port* "Cleaning run DB " run-id)
      (db:clean-up-rundb dbdat)
      (db:clean-up-rundb dbdat run-id)
    )
    (begin
      (debug:print 0 *default-log-port* "Cleaning main DB ")
      (db:clean-up-maindb dbdat)
    )
  )
)


;; Clean out old junk and vacuum the database
;;
;; Ultimately do something like this:
;;
;; 1. Look at test records either deleted or part of deleted run:
;;    a. If test dir exists, set the the test to state='UNKNOWN', Set the run to 'unknown'
;;    b. If test dir gone, delete the test record
;; 2. Look at run records
;;    a. If have tests that are not deleted, set state='unknown'
;;    b. ....
;;
(define (db:clean-up-rundb dbdat)
(define (db:clean-up-rundb dbdat run-id)
  ;; (debug:print 0 *default-log-port* "WARNING: db clean up not fully ported to v1.60, cleanup action will be on megatest.db")
  (let* ((db         (dbr:dbdat-dbh dbdat))
	 (count-stmt (sqlite3:prepare db "SELECT (SELECT count(id) FROM tests);"))
	 (test-count-stmt (sqlite3:prepare db "SELECT (SELECT count(id) FROM tests);"))
       	 (step-count-stmt (sqlite3:prepare db "SELECT (SELECT count(id) FROM test_steps);"))
	(statements
	 (map (lambda (stmt)
		(sqlite3:prepare db stmt))
	      (list
	       ;; delete all tests that belong to runs that are 'deleted'
	       ;; (conc "DELETE FROM tests WHERE run_id NOT IN (" (string-intersperse (map conc valid-runs) ",") ");")
	       ;; delete all tests that are 'DELETED'
	       "DELETE FROM tests WHERE state='DELETED';"
	       "DELETE FROM tests WHERE state='DELETED';"
               "DELETE FROM test_steps WHERE status = 'DELETED';"
               "DELETE FROM tests WHERE run_id IN (SELECT id FROM runs WHERE state = 'deleted');"
	       ))))
    ;; (db:delay-if-busy dbdat)
    (sqlite3:with-transaction 
     db
     (lambda ()
       (sqlite3:for-each-row (lambda (tot)
			       (debug:print-info 0 *default-log-port* "Test records count before clean: " tot))
			     count-stmt)
			     test-count-stmt)
       (sqlite3:for-each-row (lambda (tot)
			       (debug:print-info 0 *default-log-port* "Test_step records count before clean: " tot))
			     step-count-stmt)
       (map sqlite3:execute statements)
       (sqlite3:for-each-row (lambda (tot)
			       (debug:print-info 0 *default-log-port* "Test records count after clean: " tot))
			     test-count-stmt)
       (sqlite3:for-each-row (lambda (tot)
			       (debug:print-info 0 *default-log-port* "Test_step records count after clean: " tot))
			     count-stmt)))
			     step-count-stmt)))
    (map sqlite3:finalize! statements)
    (sqlite3:finalize! count-stmt)
    ;; (db:find-and-mark-incomplete db)
    (sqlite3:finalize! test-count-stmt)
    (sqlite3:finalize! step-count-stmt)
    ;; (db:delay-if-busy dbdat)
    (sqlite3:execute db "VACUUM;")))

;; Clean out old junk and vacuum the database
;;
;; Ultimately do something like this:
;;
;; 1. Look at test records either deleted or part of deleted run: