Overview
Context
Changes
Added api.scm version [bb24492b2f].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
;;======================================================================
;; Copyright 2006-2013, Matthew Welland.
;;
;; This program is made available under the GNU GPL version 2.0 or
;; greater. See the accompanying file COPYING for details.
;;
;; This program is distributed WITHOUT ANY WARRANTY; without even the
;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE.
;;======================================================================
(declare (unit api))
(declare (uses rmt))
(declare (uses db))
;; These are called by the server on recipt of /api calls
(define (api:execute-requests db cmd params)
(debug:print-info 1 "api:execute-requests cmd=" cmd " params=" params)
(db:process-cached-writes db)
(case (string->symbol cmd)
;; KEYS
((get-key-val-pairs) (apply db:get-key-val-pairs db params))
;; TESTS
;; json doesn't do vectors, convert to list
((get-test-info-by-id) (vector->list (apply db:get-test-info-by-id db params)))
((test-get-rundir-from-test-id) (apply db:test-get-rundir-from-test-id db params))
((testmeta-get-record) (vector->list (apply db:testmeta-get-record db params)))
((test-set-state-status-by-id) (apply db:test-set-state-status-by-id db params))
;; RUNS
((get-run-info) (let ((res (apply db:get-run-info db params)))
(list (vector-ref res 0)
(vector->list (vector-ref res 1)))))
(else
(list "ERROR" 0))))
;; http-server send-response
;; api:process-request
;; db:*
;;
;; NB// Runs on the server as part of the server loop
;;
(define (api:process-request db $) ;; the $ is the request vars proc
(let* ((cmd ($ 'cmd))
(paramsj ($ 'params))
(params (rmt:json-str->dat paramsj))
(res (api:execute-requests db cmd params)))
(rmt:dat->json-str
(if (or (string? res)
(list? res)
(number? res)
(boolean? res))
res
(list "ERROR" 1 cmd params res)))))
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added dbwars/NOTES version [8f8ee6c6d0].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
Before using prepare:
matt@xena:/tmp/megatest/dbwars$ ./sqlite3-test insert
Adding 1047 test3 item/39 host0-0.3-200000-240-this one sucks eh? (added 51886 records so far)
Adding 1122 test5 item/52 host2-0.2-200000-120-this is a good one eh? (added 78889 records so far)
Adding 1050 test7 item/31 host1-0.1-100000-120-this is a good one eh? (added 110641 records so far)
create-tests ran register-test 144000 times in 41.0 seconds
After using prepare:
matt@xena:/tmp/megatest/dbwars$ csc sqlite3-test.scm && ./sqlite3-test insert
Adding 1082 test4 item/74 host1-0.3-100000-120-this is a good one eh? (added 61281 records so far)
Adding 1138 test7 item/43 host2-0.3-200000-120-this is a good one eh? (added 109001 records so far)
Adding 1023 test9 item/00 host0-0.2-100000-240-this one sucks eh? (added 143878 records so far)
create-tests ran register-test 144000 times in 38.0 seconds
After moving the prepare outside the call (so it isn't done each time):
matt@xena:/tmp/megatest/dbwars$ ./sqlite3-test insert
Adding 1042 test4 item/59 host0-0.3-200000-120-this is a good one eh? (added 63401 records so far)
Adding 1011 test6 item/40 host0-0.1-200000-120-this one sucks eh? (added 94906 records so far)
Adding 1076 test9 item/34 host1-0.2-200000-120-just eh, eh? (added 139035 records so far)
create-tests ran register-test 144000 times in 33.0 seconds
Using sql-de-lite with very similar code:
matt@xena:/tmp/megatest/dbwars$ ./sql-de-lite-test insert
Adding 1029 test4 item/53 host0-0.2-200000-240- (added 64252 records so far)
Adding 1134 test7 item/64 host2-0.3-100000-240-this is a good one eh? (added 105973 records so far)
create-tests ran register-test 144000 times in 31.0 seconds
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added dbwars/sql-de-lite-test.scm version [004f7cb8d7].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(use sql-de-lite)
(include "test-common.scm")
(define db (open-database "test.db"))
(exec (sql db test-table-defn))
(exec (sql db syncsetup))
(define (register-test stmth run-id testname host cpuload diskfree uname rundir shortdir item-path state status final-logf run-duration comment event-time)
(exec
stmth ;; (sql db test-insert)
run-id
testname host cpuload diskfree uname rundir shortdir item-path state status final-logf run-duration comment event-time))
(let ((stmth (sql db test-insert)))
(create-tests stmth))
(close-database db)
|
| | | | | | | | | | | | | | | | | |
Added dbwars/sqlite3-test.scm version [338a298923].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(use sqlite3)
(include "test-common.scm")
(define db (open-database "test.db"))
(execute db test-table-defn)
(execute db syncsetup)
(define (register-test stmth run-id testname host cpuload diskfree uname rundir shortdir item-path state status final-logf run-duration comment event-time)
(execute stmth
run-id
testname host cpuload diskfree uname rundir shortdir item-path state status final-logf run-duration comment event-time))
(let ((stmth (prepare db test-insert)))
(create-tests stmth)
(finalize! stmth))
(finalize! db)
|
| | | | | | | | | | | | | | | | | | |
Added dbwars/test-common.scm version [02dcd9f2da].