Random Bits of Open Code

Check-in [fe6adf7d20]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added debug stuff
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fe6adf7d2003ce332c94a11beb15cf5479130082
User & Date: mrwellan 2018-05-04 23:09:51
Context
2018-05-06
05:01
Fixed problem where using adat1 run-id where needed adat2 run-id, added ability to continue sync. check-in: 10e54d0c7e user: matt tags: trunk
2018-05-04
23:09
Added debug stuff check-in: fe6adf7d20 user: mrwellan tags: trunk
2018-05-02
22:39
Iterate over areas (not 100% sure this is a good idea). check-in: a76a9c267b user: matt tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to misc/runme.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

project=Megatest

for f in $(
    for x in $(find . -type f);do
        if [[ $(file $x|grep text) ]];then
            echo -n "$x ";
        fi;
    done);do
    if [[ $(wc -l $f | awk '{print $1}') -gt 10 ]];then
        if ! $(grep -q ${project}' is free software' $f);then
            echo "$f ";
        fi;
    fi
done






|

|

|
|




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

project=Megatest

for f in $(
    for x in $(find . -type f);do
        # if [[ $(file $x|grep text) ]];then
            echo -n "$x ";
        # fi;
    done);do
    if [[ $(wc -l $f | awk '{print $1}') -gt -1 ]];then
        if ! $(grep -q ${project}' is free software' $f) || ! $(egrep -q 'Copyright.*Matthew Welland.' $f);then
            echo "$f ";
        fi;
    fi
done

Changes to mtutils/mtdb/mtdb.scm.

102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
...
292
293
294
295
296
297
298

299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
....
1115
1116
1117
1118
1119
1120
1121


1122
1123
1124
1125
1126
1127
1128
....
1176
1177
1178
1179
1180
1181
1182

1183
1184
1185
1186
1187
1188
1189
....
1231
1232
1233
1234
1235
1236
1237
1238

1239
1240
1241
1242
1243


1244
1245
1246
1247
1248
1249
1250
     get-last-run-version-number
     set-last-run-version
 
     )

(import scheme chicken data-structures extras ports srfi-69 srfi-1)
(use regex srfi-13 matchable
     (prefix sql-de-lite s:)

     (prefix dbi dbi:) posix typed-records
     (prefix mtcommon common:)
     (prefix mtconfigf configf:))

;; (use trace)

(define *default-log-port* (current-error-port))
................................................................................
        #f)))

;; open and if needed init a sqlite3 db with the schema
;; 
(define (mtdb-sqlite3-open path fbase)
  (let* ((fulln   (conc path "/" fbase ".db"))
	 (fexists (file-exists? fulln))

	 (dbispec `((dbname . ,fulln)))
	 (dbh     (dbi:open 'sql-de-lite dbispec))
	 (db      (dbi:db-conn dbh)))
    ;; WARNING: Race condition exists here.
    (if (not fexists)
	(s:with-transaction
	 db
	 (lambda ()
	   (for-each
	    (lambda (stmt)
	      (s:exec (s:sql db stmt)))
	    *sql-de-lite-schema* ))))
    (s:exec (s:sql db "PRAGMA journal_mode=WAL"))
    (s:exec (s:sql db "PRAGMA synchronous=0"))
    dbh))

;; do NOT close the db in the following three routines.

;; for sql-de-lite access we keep main and runs in separate files
;;
(define (with-common-db adat proc . params)
  (let* ((dbh-main (if (adat-common-db adat)
................................................................................
			(hash-table-set! test-ht test-id pgdb-test-id))
		      (print "WARNING: Skipping run with run-id:" run-id ". This run was created after previous sync and removed before this sync.")))))
	     tests)))
	 (print "INFO: sync for run " run-id " completed in " (- (current-seconds) start-time) " seconds.")
	 ))
     run-ids)))



(define (add-area-tag dbh area-info tag) 
  (let* ((tag-info (get-tag-info-by-name dbh tag)))
    (if (not tag-info)
	(begin   
	  (if (handle-exceptions
		  exn
		  (begin 
................................................................................
	    '(runs targets tests steps data))
  cached-info)

;; target conversion from independent fields to / sep. string
;; in the adat-path location propagate megatest.db data to main.d and 1.db ... N.db
;; 
(define (mt1-sync-to-mt2 adat1 adat2 #!key (area-tag #f)(cached-info #f))

  (let* ((area-path   (adat-path        adat2))
	 (common-dbh  (with-common-db   adat2 #f)) ;; opens the db
	 (mt-dbh      (with-megatest-db adat1 #f))
	 (main-dbh    common-dbh) ;; (with-main-db     adat2 #f))
	 (area-info   (get-area-by-path common-dbh area-path))
	 (cached-info (or cached-info (make-hash-table)))
	 (start       (current-seconds))
................................................................................
		  ;; not syncing run stats at this time as they can be derived from tests table.
		  (sync-tests-data adat1 adat2 cached-info test-ids area-info)
					;(exit)   
		  ;; (sync-test-steps adat1 adat2 cached-info test-step-ids)
		  ;; (sync-test-gen-data adat1 adat2 cached-info test-data-ids))
		  ))
	    (write-sync-time common-dbh area-info start)
	    

	    ))) ;; NOTE: Need to extract the max time from the source db and use that
	(if (set-area adat2)
	    (mt1-sync-to-mt2 adat1 adat2)
	    (begin
	      (print-error "ERROR: unable to create an area record")


	      #f)))))

;;======================================================================
;;
;;======================================================================

;; get an alist of record ids changed since time since-time







|
>







 







>

|


|
|
|
|
|
|
|
|
|
|
|







 







>
>







 







>







 







|
>





>
>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
....
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
....
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
....
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
     get-last-run-version-number
     set-last-run-version
 
     )

(import scheme chicken data-structures extras ports srfi-69 srfi-1)
(use regex srfi-13 matchable
     ;; (prefix sql-de-lite s:)
     (prefix sqlite3 s:)
     (prefix dbi dbi:) posix typed-records
     (prefix mtcommon common:)
     (prefix mtconfigf configf:))

;; (use trace)

(define *default-log-port* (current-error-port))
................................................................................
        #f)))

;; open and if needed init a sqlite3 db with the schema
;; 
(define (mtdb-sqlite3-open path fbase)
  (let* ((fulln   (conc path "/" fbase ".db"))
	 (fexists (file-exists? fulln))
	 (dbtype  'sqlite3) ;; 'sql-de-lite
	 (dbispec `((dbname . ,fulln)))
	 (dbh     (dbi:open dbtype dbispec))
	 (db      (dbi:db-conn dbh)))
    ;; WARNING: Race condition exists here.
       (if (not fexists)
	   (dbi:with-transaction
	    dbh
	    (lambda ()
	      (for-each
	       (lambda (stmt)
		 (dbi:exec db stmt))
	       *sql-de-lite-schema*))))
       (dbi:exec dbh "PRAGMA journal_mode=WAL")
       (dbi:exec dbh "PRAGMA synchronous=0")
       dbh))

;; do NOT close the db in the following three routines.

;; for sql-de-lite access we keep main and runs in separate files
;;
(define (with-common-db adat proc . params)
  (let* ((dbh-main (if (adat-common-db adat)
................................................................................
			(hash-table-set! test-ht test-id pgdb-test-id))
		      (print "WARNING: Skipping run with run-id:" run-id ". This run was created after previous sync and removed before this sync.")))))
	     tests)))
	 (print "INFO: sync for run " run-id " completed in " (- (current-seconds) start-time) " seconds.")
	 ))
     run-ids)))

(use trace)(trace insert-test)(trace-call-sites #t)

(define (add-area-tag dbh area-info tag) 
  (let* ((tag-info (get-tag-info-by-name dbh tag)))
    (if (not tag-info)
	(begin   
	  (if (handle-exceptions
		  exn
		  (begin 
................................................................................
	    '(runs targets tests steps data))
  cached-info)

;; target conversion from independent fields to / sep. string
;; in the adat-path location propagate megatest.db data to main.d and 1.db ... N.db
;; 
(define (mt1-sync-to-mt2 adat1 adat2 #!key (area-tag #f)(cached-info #f))
  (close-all-dbs adat1) ;; pre-clean the situation
  (let* ((area-path   (adat-path        adat2))
	 (common-dbh  (with-common-db   adat2 #f)) ;; opens the db
	 (mt-dbh      (with-megatest-db adat1 #f))
	 (main-dbh    common-dbh) ;; (with-main-db     adat2 #f))
	 (area-info   (get-area-by-path common-dbh area-path))
	 (cached-info (or cached-info (make-hash-table)))
	 (start       (current-seconds))
................................................................................
		  ;; not syncing run stats at this time as they can be derived from tests table.
		  (sync-tests-data adat1 adat2 cached-info test-ids area-info)
					;(exit)   
		  ;; (sync-test-steps adat1 adat2 cached-info test-step-ids)
		  ;; (sync-test-gen-data adat1 adat2 cached-info test-data-ids))
		  ))
	    (write-sync-time common-dbh area-info start)
	    (close-all-dbs adat1)
	    (close-all-dbs adat2)
	    ))) ;; NOTE: Need to extract the max time from the source db and use that
	(if (set-area adat2)
	    (mt1-sync-to-mt2 adat1 adat2)
	    (begin
	      (print-error "ERROR: unable to create an area record")
	      (close-all-dbs adat1)
	      (close-all-dbs adat2)
	      #f)))))

;;======================================================================
;;
;;======================================================================

;; get an alist of record ids changed since time since-time