Megatest

Check-in [98f64a4ebc]
Login
Overview
Comment:Merged in v1.65
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65-code-cleanup
Files: files | file ages | folders
SHA1: 98f64a4ebcd4886ec21ca4028dbc09110d23287b
User & Date: mrwellan on 2019-08-28 13:22:23
Other Links: branch diff | manifest | tags
Context
2019-09-16
16:37
Merged stuff from v1.65 Closed-Leaf check-in: aa7059651c user: mrwellan tags: v1.65-code-cleanup
2019-08-28
13:22
Merged in v1.65 check-in: 98f64a4ebc user: mrwellan tags: v1.65-code-cleanup
11:25
Fix bad call to rmt: in db, updated Makefile with dependency on mtest for unittests and commented out a db: call in all-rmt.scm check-in: b2688e2769 user: mrwellan tags: v1.65
2019-08-27
14:12
Merged from v1.65 check-in: 9e659a12a0 user: mrwellan tags: v1.65-code-cleanup
Changes

Modified db.scm from [579fd43a32] to [560d632862].

2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
  (let* ((keyvals (db:get-key-vals dbstruct run-id))
	 (thekey  (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/")))
    thekey))

;; Get run-ids for runs with same target but different runnames and NOT run-id
;;
(define (db:get-prev-run-ids dbstruct run-id)
  (let* ((keyvals (rmt:get-key-val-pairs run-id))
	 (kvalues (map cadr keyvals))
	 (keys    (rmt:get-keys))
	 (qrystr  (string-intersperse (map (lambda (x)(conc x "=?")) keys) " AND ")))
    (let ((prev-run-ids '()))
      (if (null? keyvals)
          '()
          (begin







|







2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
  (let* ((keyvals (db:get-key-vals dbstruct run-id))
	 (thekey  (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/")))
    thekey))

;; Get run-ids for runs with same target but different runnames and NOT run-id
;;
(define (db:get-prev-run-ids dbstruct run-id)
  (let* ((keyvals (db:get-key-val-pairs dbstruct run-id))
	 (kvalues (map cadr keyvals))
	 (keys    (rmt:get-keys))
	 (qrystr  (string-intersperse (map (lambda (x)(conc x "=?")) keys) " AND ")))
    (let ((prev-run-ids '()))
      (if (null? keyvals)
          '()
          (begin

Modified tests/Makefile from [540b3dc4db] to [3c36aa006d].

14
15
16
17
18
19
20

21

22
23
24
25
26
27
28
# 
#     You should have received a copy of the GNU General Public License
#     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.
#
# run some tests

BINPATH   = $(shell readlink -m $(PWD)/../bin)

MEGATEST  = $(BINPATH)/megatest

DASHBOARD = $(BINPATH)/dashboard
PATH     := $(BINPATH):$(PATH)
RUNNAME  := $(shell date +w%V.%u.%H.%M)
IPADDR   := "-"
RUNID    := 1
SERVER    = 
DEBUG     = 1







>

>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 
#     You should have received a copy of the GNU General Public License
#     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.
#
# run some tests

BINPATH   = $(shell readlink -m $(PWD)/../bin)
LSBR      = $(shell lsb_release -sr)
MEGATEST  = $(BINPATH)/megatest
MTEST     = $(BINPATH)/.$(LSBR)/mtest
DASHBOARD = $(BINPATH)/dashboard
PATH     := $(BINPATH):$(PATH)
RUNNAME  := $(shell date +w%V.%u.%H.%M)
IPADDR   := "-"
RUNID    := 1
SERVER    = 
DEBUG     = 1
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

rel : 
	cd release;dashboard -rows 25 &

## basicserver.log : unittests/basicserver.scm
## 	script -c "./rununittest.sh basicserver $(DEBUG)" basicserver.log

%.log : build unittests/%.scm
	script -c "./rununittest.sh $* $(DEBUG)" $*.log
	if logpro unit.logpro $*.html < $*.log > /dev/null;then echo ALLPASS;else echo ALLFAIL;mv $*.log $*.log.FAIL;fi

server :
	cd fullrun;$(MEGATEST) -server - -debug $(DEBUG) -run-id $(RUNID)

stopserver :







|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

rel : 
	cd release;dashboard -rows 25 &

## basicserver.log : unittests/basicserver.scm
## 	script -c "./rununittest.sh basicserver $(DEBUG)" basicserver.log

%.log : build unittests/%.scm $(MTEST)
	script -c "./rununittest.sh $* $(DEBUG)" $*.log
	if logpro unit.logpro $*.html < $*.log > /dev/null;then echo ALLPASS;else echo ALLFAIL;mv $*.log $*.log.FAIL;fi

server :
	cd fullrun;$(MEGATEST) -server - -debug $(DEBUG) -run-id $(RUNID)

stopserver :

Modified tests/unittests/all-api.scm from [621fc8cc57] to [a91f2ca1b8].

27
28
29
30
31
32
33























34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

158
;;  ./rununittest.sh all-api 1

;; Definitions:
;;   NTN - no test needed
;;   DEP - function is deprecated, no point in testing
;;   NED - function nested under others, no test needed.
;;   DEF - deferred
























(define my-dbstruct (db:setup #t))
(define toppath (current-directory))
(define keypatts '(("SYSTEM" "ubuntu")("RELEASE" "v1.234")) )
(define keys (db:get-keys my-dbstruct))

;;(test #f #t (string?(server:start-and-wait *toppath*)))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'start-server (list *toppath* ))) 0))

(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-val-pairs (list 0 ))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-var (list "LAST_UPDATE"  1234567))) 0))
(test #f 1234567 (vector-ref (api:execute-requests my-dbstruct (vector 'get-var (list "LAST_UPDATE" ))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'del-var (list "LAST_UPDATE" ))) 0))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys (list ))) 1))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-vals (list 1 ))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "test-toplevel-num-items" (list 1 "foo"))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-test-info-by-id (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-steps-info-by-id (list 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-data-info-by-id (list 1))) 0))

(test #f  '(#t "successful login") (vector-ref (api:execute-requests my-dbstruct (vector 'login (list toppath megatest-version "Fred"))) 1))
(test #f '(-1 . 0) (vector-ref (api:execute-requests my-dbstruct (vector 'get-latest-host-load (list "localhost"))) 1))

(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-changed-record-ids (list 0))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-run-record-ids (list "%" 1 keys "%/%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-not-completed-cnt (list 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-tags (list ))) 0))
;; no such query supported in api.scm, but it is is the list of read-only queries.
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-times (list ))) 0))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys-write (list ))) 1))
(test #f  (vector '("SYSTEM" "RELEASE") '())(vector-ref (api:execute-requests my-dbstruct (vector 'get-targets (list 1 ))) 1))
(test #f "" (vector-ref (api:execute-requests my-dbstruct (vector 'get-target (list 1 ))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'general-call (list 'register-test 1 1 "foo" ""))) 0))
(test #f 1 (vector-ref (api:execute-requests my-dbstruct (vector 'get-test-id (list 1 "foo" ""))) 1))
(test #f "/tmp/badname" (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-rundir-from-test-id (list 1 1))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-tests-state-status (list 1 '("foo") "COMPLETED" "PASS" "NOT_STARTED" "PASS"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-set-state-status-by-id (list 1 1 "COMPLETED" "PASS" "Just testing!"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-run (list 1 "%" '() '() #f #f #f #f #f #f 0 #f))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-run-mindata (list 1  "%" '("COMPLETED") '("PASS") #f ))) 0))
;; api.scm calls db:get-tests-for-runs-mindata, which does not exist.
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-runs-mindata (list 1  "%" '("COMPLETED") '("PASS") #f ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "delete-test-records" (list 1 2 ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-set-state-status" (list 1 1 "COMPLETED" "FAIL" "Another message" ))) 0))
;; api.scm calls db:get-previous-test-run-record, which does not exist.
;;(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector "get-previous-test-run-record" (list 1 ))) 1))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector "get-matching-previous-test-run-records" (list 1 "foo" ""))) 1))
(test #f '("/tmp/badname" "logs/final.log") (vector-ref (api:execute-requests my-dbstruct (vector "test-get-logfile-info" (list 1 "foo"))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-get-records-for-index-file" (list 1 "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-testinfo-state-status" (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "general-call" (list 'test-set-log 1 "/tmp/another/logfile/eh" 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-set-archive-block-id" (list 1 1 123))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-set-top-process-pid" (list 1 1 123))) 0))
(test #f 123 (vector-ref (api:execute-requests my-dbstruct (vector "test-get-top-process-pid" (list 1 1))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-run-ids-matching-target" (list keys "%/%" #f "%" "%" "%" "%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-get-paths-matching-keynames-target-new" (list 1 keys "%/%" #f "%" "%" "%" "%"))) 0))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector "get-prereqs-not-met" (list 1 '() "foo" "" '(normal) '()))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "get-count-tests-running-for-run-id" (list 1))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "get-count-tests-running" (list 1))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "get-count-tests-running-for-testname" (list 1 "foo"))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "get-count-tests-running-in-jobgroup" (list 1 "nada"))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "set-state-status-and-roll-up-items" (list 1 "foo" "" "COMPLETED" "FAIL" "Just yet another message"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "set-state-status-and-roll-up-run" (list 1 "COMPLETED" "FAIL"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "top-test-set-per-pf-counts" (list 1 "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-raw-run-stats" (list 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-run-info" (list 1))) 0))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "get-num-runs" (list "%"))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "get-runs-cnt-by-patt" (list "%" "%/%" keys))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "register-run" (list '(("SYSTEM" "ubuntu")("RELEASE" "v1.234")) "bar" "NEW" "JUSTFINE" "bobafett" "quick" ))) 0))
(test #f #(#t "bar") (api:execute-requests my-dbstruct (vector "get-run-name-from-id" '(1))))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "delete-run" (list 2))) 0)) ;; delete a non-existant run
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "update-run-stats" (list 1 '()))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-main-run-stats" (list 1 ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "delete-old-deleted-test-records" '())) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-runs" (list "%" 10 0 keypatts))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "simple-get-runs" (list "%" 10 0 keypatts))) 0))
(test #f #(#t (1))(api:execute-requests my-dbstruct (vector "get-all-run-ids" '())))
(test #f #(#t ()) (api:execute-requests my-dbstruct (vector "get-prev-run-ids" '(1))))
(test #f #(#t "JUSTFINE") (api:execute-requests my-dbstruct (vector "get-run-status" '(1))))
(test #f #(#t "NEW") (api:execute-requests my-dbstruct (vector "get-run-state" '(1))))
(test #f #(#t (("Totals" "UNKNOWN" 1) ("bar" "UNKNOWN" 1))) (api:execute-requests my-dbstruct (vector "get-run-stats" '())))
(test #f #(#t ()) (api:execute-requests my-dbstruct (vector "get-run-times" '(1 1 ))))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'lock/unlock-run '(1 #t #f "mikey"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-run-status '(1 "NOTFINE" "A message"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-run-state-status '(1 "NOTFINE" "AMESS"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'update-run-event_time '(1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-runs-by-patt" (list keys "%" "%/%" #f #f #f #f "ASC"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-steps-data" (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "get-steps-for-test" (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "delete-steps-for-test!" (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "teststep-set-status!" (list 1 1 "step1" "COMPLETED" "PASS" "force pass" "/tmp/logfile"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-data-rollup" (list 1 1 "COMPLETED"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "csv->test-data" (list 1 1 "some,data"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "read-test-data" (list 1 1 "%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "read-test-data*" (list 1 1 "%" "%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "tasks-add" (list "run" "Fred" "%" "foo" "%/%" #f))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "tasks-set-state-given-param-key" (list "mykey" "COMPLETED"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "tasks-get-last" (list "%" "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "find-task-queue-records" (list "%" "myrun" "%/%" "RUNNING" "run"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "testmeta-add-record" (list "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "testmeta-update-field" (list "foo" "description" "junk"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "testmeta-get-record" (list "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "have-incompletes?" (list 1 12000))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "mark-incomplete" (list 1 12000))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "no-sync-set" (list "field1" "value1"))) 0))
(test #f "value1" (vector-ref (api:execute-requests my-dbstruct (vector "no-sync-get/default" (list "field1" #f))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "no-sync-del!" (list "field1"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "no-sync-get-lock" (list "mykey"))) 0))
(test #f 1 (vector-ref (api:execute-requests my-dbstruct (vector "archive-register-disk" (list "mydisk" "/usr/mydisk" 10000000))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "archive-register-block-name" (list 1 "/usr/mydisk/myblock"))) 0))
;;This api function calls db:archive-allocate-testsuite/area-to-block, which does not exist.
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "archive-allocate-testsuite/area-to-block" (list 1 "/usr/mydisk/myblock"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "test-get-archive-block-info" (list 1 ))) 0))


;;debug this: ERROR: parameter last-update for db:sync-tables must be a pair or a number, received: (0 . last_update)
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "sync-inmem->db" (list 1))) 0))

;;debug this. Error: bad argument count - received 0 but expected 5: #<procedure (db:get-runs dbstruct3787 runpatt3788 count3789 offset3790 keypatts3...
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "synchash-get" (list 1 (db:get-runs) "foo" 1 (list "%" 10 0 keypatts)))) 0))

;debug this. Call of non-procedure
;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "sdb-qry" (list "sdb-db"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector "ping" (list ))) 0))


(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'kill-server (list ))) 0))







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






<

<






|



<


<


















|
|


|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|




|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|

<

|


|

|
<
|

>

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63

64
65
66
67
68
69
70
71
72
73

74
75

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165

166
167
168
169
170
171
172

173
174
175
176
;;  ./rununittest.sh all-api 1

;; Definitions:
;;   NTN - no test needed
;;   DEP - function is deprecated, no point in testing
;;   NED - function nested under others, no test needed.
;;   DEF - deferred


;; Issues:
;; 1. Most of the API calls accept a string or symbol for the function name, but at least one requires a symbol.
;;    Should we decide one way or the other, symbol or string, (seems symbol is best) and enforce that in the API? Current code:
;;            (cmd               (if (symbol? cmd-in)
;;				   cmd-in
;;				   (string->symbol cmd-in)))
;;    Just accept symbol
;;    In the refactor, change execute-requests to only accept a symbol.

;; 2. Some functions return <unspecified> in element 1 of the vector. What to do about this? Fix them to return a measurable value? 
;;    Or is there a way to make test accept <unspecified>? - No.
;;    This is why I had to use vector-ref and look at one value or the other.
;;    Look at why functions are returning unspecified.
;;    The last function they call returns nothing.

;; 3. Some API functions call non-existent db functions. 
;;    Delete these API functions after checking that they are not called?
;;    Comment them out and give a date to delete. (in the refactor branch?)

;; 4. get-tests-times:  no such query supported in api.scm, but it is in the list of read-only queries. Remove it? Or implement it if it's in db.scm?


(define my-dbstruct (db:setup #t))
(define toppath (current-directory))
(define keypatts '(("SYSTEM" "ubuntu")("RELEASE" "v1.234")) )
(define keys (db:get-keys my-dbstruct))


(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'start-server (list *toppath* ))) 0))

(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-val-pairs (list 0 ))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-var (list "LAST_UPDATE"  1234567))) 0))
(test #f 1234567 (vector-ref (api:execute-requests my-dbstruct (vector 'get-var (list "LAST_UPDATE" ))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'del-var (list "LAST_UPDATE" ))) 0))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys (list ))) 1))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-vals (list 1 ))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'test-toplevel-num-items (list 1 "foo"))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-test-info-by-id (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-steps-info-by-id (list 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-data-info-by-id (list 1))) 0))

(test #f  '(#t "successful login") (vector-ref (api:execute-requests my-dbstruct (vector 'login (list toppath megatest-version "Fred"))) 1))
(test #f '(-1 . 0) (vector-ref (api:execute-requests my-dbstruct (vector 'get-latest-host-load (list "localhost"))) 1))

(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-changed-record-ids (list 0))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-run-record-ids (list "%" 1 keys "%/%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-not-completed-cnt (list 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-tags (list ))) 0))
;; no such query supported in api.scm, but it is is the list of read-only queries.
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-times (list ))) 0))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys-write (list ))) 1))
(test #f  (vector '("SYSTEM" "RELEASE") '())(vector-ref (api:execute-requests my-dbstruct (vector 'get-targets (list 1 ))) 1))
(test #f "" (vector-ref (api:execute-requests my-dbstruct (vector 'get-target (list 1 ))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'general-call (list 'register-test 1 1 "foo" ""))) 0))
(test #f 1 (vector-ref (api:execute-requests my-dbstruct (vector 'get-test-id (list 1 "foo" ""))) 1))
(test #f "/tmp/badname" (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-rundir-from-test-id (list 1 1))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-tests-state-status (list 1 '("foo") "COMPLETED" "PASS" "NOT_STARTED" "PASS"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-set-state-status-by-id (list 1 1 "COMPLETED" "PASS" "Just testing!"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-run (list 1 "%" '() '() #f #f #f #f #f #f 0 #f))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-run-mindata (list 1  "%" '("COMPLETED") '("PASS") #f ))) 0))
;; api.scm calls db:get-tests-for-runs-mindata, which does not exist.
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-runs-mindata (list 1  "%" '("COMPLETED") '("PASS") #f ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'delete-test-records (list 1 2 ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-set-state-status (list 1 1 "COMPLETED" "FAIL" "Another message" ))) 0))
;; api.scm calls db:get-previous-test-run-record, which does not exist.
;;(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector "get-previous-test-run-record" (list 1 ))) 1))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-matching-previous-test-run-records (list 1 "foo" ""))) 1))
(test #f '("/tmp/badname" "logs/final.log") (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-logfile-info (list 1 "foo"))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-records-for-index-file (list 1 "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-testinfo-state-status (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'general-call (list 'test-set-log 1 "/tmp/another/logfile/eh" 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-set-archive-block-id (list 1 1 123))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-set-top-process-pid (list 1 1 123))) 0))
(test #f 123 (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-top-process-pid (list 1 1))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-run-ids-matching-target (list keys "%/%" #f "%" "%" "%" "%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-paths-matching-keynames-target-new (list 1 keys "%/%" #f "%" "%" "%" "%"))) 0))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-prereqs-not-met (list 1 '() "foo" "" '(normal) '()))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'get-count-tests-running-for-run-id (list 1))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'get-count-tests-running (list 1))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'get-count-tests-running-for-testname (list 1 "foo"))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'get-count-tests-running-in-jobgroup (list 1 "nada"))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-state-status-and-roll-up-items (list 1 "foo" "" "COMPLETED" "FAIL" "Just yet another message"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-state-status-and-roll-up-run (list 1 "COMPLETED" "FAIL"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'top-test-set-per-pf-counts (list 1 "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-raw-run-stats (list 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-run-info (list 1))) 0))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'get-num-runs (list "%"))) 1))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector 'get-runs-cnt-by-patt (list "%" "%/%" keys))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'register-run (list '(("SYSTEM" "ubuntu")("RELEASE" "v1.234")) "bar" "NEW" "JUSTFINE" "bobafett" "quick" ))) 0))
(test #f #(#t "bar") (api:execute-requests my-dbstruct (vector 'get-run-name-from-id '(1))))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'delete-run (list 2))) 0)) ;; delete a non-existant run
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'update-run-stats (list 1 '()))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-main-run-stats (list 1 ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'delete-old-deleted-test-records '())) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-runs (list "%" 10 0 keypatts))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'simple-get-runs (list "%" 10 0 keypatts))) 0))
(test #f #(#t (1))(api:execute-requests my-dbstruct (vector 'get-all-run-ids '())))
(test #f #(#t ()) (api:execute-requests my-dbstruct (vector 'get-prev-run-ids '(1))))
(test #f #(#t "JUSTFINE") (api:execute-requests my-dbstruct (vector 'get-run-status '(1))))
(test #f #(#t "NEW") (api:execute-requests my-dbstruct (vector 'get-run-state '(1))))
(test #f #(#t (("Totals" "UNKNOWN" 1) ("bar" "UNKNOWN" 1))) (api:execute-requests my-dbstruct (vector 'get-run-stats '())))
(test #f #(#t ()) (api:execute-requests my-dbstruct (vector 'get-run-times '(1 1 ))))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'lock/unlock-run '(1 #t #f "mikey"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-run-status '(1 "NOTFINE" "A message"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'set-run-state-status '(1 "NOTFINE" "AMESS"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'update-run-event_time '(1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-runs-by-patt (list keys "%" "%/%" #f #f #f #f "ASC"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-steps-data (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-steps-for-test (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'delete-steps-for-test! (list 1 1))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'teststep-set-status! (list 1 1 "step1" "COMPLETED" "PASS" "force pass" "/tmp/logfile"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-data-rollup (list 1 1 "COMPLETED"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'csv->test-data (list 1 1 "some,data"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'read-test-data (list 1 1 "%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'read-test-data* (list 1 1 "%" "%"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'tasks-add (list "run" "Fred" "%" "foo" "%/%" #f))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'tasks-set-state-given-param-key (list "mykey" "COMPLETED"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'tasks-get-last (list "%" "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'find-task-queue-records (list "%" "myrun" "%/%" "RUNNING" "run"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'testmeta-add-record (list "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'testmeta-update-field (list "foo" "description" "junk"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'testmeta-get-record (list "foo"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'have-incompletes? (list 1 12000))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'mark-incomplete (list 1 12000))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'no-sync-set (list "field1" "value1"))) 0))
(test #f "value1" (vector-ref (api:execute-requests my-dbstruct (vector 'no-sync-get/default (list "field1" #f))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'no-sync-del! (list "field1"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'no-sync-get-lock (list "mykey"))) 0))
(test #f 1 (vector-ref (api:execute-requests my-dbstruct (vector 'archive-register-disk (list "mydisk" "/usr/mydisk" 10000000))) 1))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'archive-register-block-name (list 1 "/usr/mydisk/myblock"))) 0))
;;This api function calls db:archive-allocate-testsuite/area-to-block, which does not exist.
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'archive-allocate-testsuite/area-to-block (list 1 "/usr/mydisk/myblock"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'test-get-archive-block-info (list 1 ))) 0))


;;debug this: ERROR: parameter last-update for db:sync-tables must be a pair or a number, received: (0 . last_update)
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'sync-inmem->db (list 1))) 0))

;;debug this. Error: bad argument count - received 0 but expected 5: #<procedure (db:get-runs dbstruct3787 runpatt3788 count3789 offset3790 keypatts3...
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'synchash-get (list 1 (db:get-runs) "foo" 1 (list "%" 10 0 keypatts)))) 0))

;;debug this. Call of non-procedure

;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'sdb-qry (list "sdb-db"))) 0))

(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'ping (list ))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'kill-server (list ))) 0))

Modified tests/unittests/all-rmt.scm from [fae915643d] to [08927c7296].

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(test #f '() (rmt:get-key-vals 1))
(test #f (vector '("SYSTEM" "RELEASE") '()) (rmt:get-targets))
(test #f "" (rmt:get-target 1))
(test #f #t (rmt:register-test 1 "foo" ""))
(test #f 1  (rmt:get-test-id 1 "foo" ""))
(test #f "foo" (vector-ref (rmt:get-test-info-by-id 1 1) 2))
(test #f "/tmp/badname" (rmt:test-get-rundir-from-test-id 1 1))
(test #f '(1) (db:set-tests-state-status *db* 1 '("foo")  "COMPLETED" "PASS" "NOT_STARTED" "PASS"))
(test #f '(1) (rmt:set-tests-state-status 1 '("foo") "COMPLETED" "PASS" "NOT_STARTED" "PASS"))
(test #f #t (mt:test-set-state-status-by-id 1 1 "COMPLETED" "PASS" "Just testing!"))
(test #f #t (list? (rmt:get-tests-for-run 1 "%" '() '() #f #f #f #f #f #f 0 #f)))
(test #f #t (list? (rmt:get-tests-for-runs-mindata '(1) "%" '() '() #f)))
(test #f #f (begin (rmt:delete-test-records 1 2) #f))
(test #f #t (begin (rmt:test-set-state-status 1 1 "COMPLETED" "FAIL" "Another message") #t))
(test #f 0  (rmt:test-toplevel-num-items 1 "foo"))







|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(test #f '() (rmt:get-key-vals 1))
(test #f (vector '("SYSTEM" "RELEASE") '()) (rmt:get-targets))
(test #f "" (rmt:get-target 1))
(test #f #t (rmt:register-test 1 "foo" ""))
(test #f 1  (rmt:get-test-id 1 "foo" ""))
(test #f "foo" (vector-ref (rmt:get-test-info-by-id 1 1) 2))
(test #f "/tmp/badname" (rmt:test-get-rundir-from-test-id 1 1))
;; (test #f '(1) (db:set-tests-state-status *db* 1 '("foo")  "COMPLETED" "PASS" "NOT_STARTED" "PASS")) ;; trust that this was tested in all-api
(test #f '(1) (rmt:set-tests-state-status 1 '("foo") "COMPLETED" "PASS" "NOT_STARTED" "PASS"))
(test #f #t (mt:test-set-state-status-by-id 1 1 "COMPLETED" "PASS" "Just testing!"))
(test #f #t (list? (rmt:get-tests-for-run 1 "%" '() '() #f #f #f #f #f #f 0 #f)))
(test #f #t (list? (rmt:get-tests-for-runs-mindata '(1) "%" '() '() #f)))
(test #f #f (begin (rmt:delete-test-records 1 2) #f))
(test #f #t (begin (rmt:test-set-state-status 1 1 "COMPLETED" "FAIL" "Another message") #t))
(test #f 0  (rmt:test-toplevel-num-items 1 "foo"))