Megatest

Check-in [22975ea8da]
Login
Overview
Comment:updated couple unit tests
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.6569-multi-db-wip
Files: files | file ages | folders
SHA1: 22975ea8dac8c9a881027734f4734c88adcee191
User & Date: matt on 2021-02-13 19:16:35
Other Links: branch diff | manifest | tags
Context
2021-02-13
21:42
code tidy check-in: 318542508d user: matt tags: v1.6569-multi-db-wip (unpublished)
19:16
updated couple unit tests check-in: 22975ea8da user: matt tags: v1.6569-multi-db-wip (unpublished)
2021-02-12
21:46
Remove couple calls to telemetry stuff check-in: 9bb722e1d3 user: matt tags: v1.6569-multi-db-wip (unpublished)
Changes

Modified tests/unittests/all-api.scm from [60bcb491ab] to [6967a9bad5].

50
51
52
53
54
55
56
57

58
59
60
61
62
63
64

;; 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))







|
>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

;; 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?

(import commonmod)
(import dbmod)
(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))
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
(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))







|







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
(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))) 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))

Modified tests/unittests/all-rmt.scm from [3c7b17d5c4] to [1afb8effa6].

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
56
57


58
59
60
61
62
63
64
65
66
67
68
69
;;  ./rununittest.sh all-rmt 1

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





(print "start dir: " (current-directory))
       
(define toppath (current-directory))

(test #f #f (server:check-if-running toppath))           ;; these are used by server:start-and-wait
(test #f #t (list? (server:get-list toppath)))
(test #f '() (server:get-best '()))

(test #f #t (common:simple-file-lock-and-wait "test.lock" expire-time: 15))
(test #f "test.lock" (common:simple-file-release-lock "test.lock"))
(test #f #t (server:get-best-guess-address (get-host-name)))
(test #f #t (string? (common:get-homehost)))

;; clean out any old running servers
;;
(let ((servers (server:get-list toppath)))
  (print "Known servers: "  servers)
  (if (not (null? servers))
      (begin
	(for-each
	 (lambda (server)
	   (let ((pid (list-ref server 4)))
	     (thread-start!
	      (make-thread
	       (lambda ()


		 (print "Attempting to kill server: " server)
		 (print "Attempting to kill pid " pid)
		 (system (conc "kill " pid))
		 (thread-sleep! 2)
		 (system (conc "kill -9 " pid)))
	       (conc pid)))))
	 servers)
	(thread-sleep! 2))))
;; let's start up a server the mechanical way
(system "nbfake megatest -server -")
(thread-sleep! 2)
;; (test #f #t (string? (server:start-and-wait *toppath*)))







>
>
>
>








>


|
|









|



>
>
|
|
|
|
|







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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;;  ./rununittest.sh all-rmt 1

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

(import commonmod)
(import dbmod)
(use matchable)

(print "start dir: " (current-directory))
       
(define toppath (current-directory))

(test #f #f (server:check-if-running toppath))           ;; these are used by server:start-and-wait
(test #f #t (list? (server:get-list toppath)))
(test #f '() (server:get-best '()))
(test #f '() (server:get-rand-best toppath))
(test #f #t (common:simple-file-lock-and-wait "test.lock" expire-time: 15))
(test #f "test.lock" (common:simple-file-release-lock "test.lock"))
(test #f #t (string? (server:get-best-guess-address (get-host-name))))
(test #f #t (string? (car (common:get-homehost))))

;; clean out any old running servers
;;
(let ((servers (server:get-list toppath)))
  (print "Known servers: "  servers)
  (if (not (null? servers))
      (begin
	(for-each
	 (lambda (server)
	   (let ((pid (list-ref server 2)))
	     (thread-start!
	      (make-thread
	       (lambda ()
		 (if (number? pid)
		     (begin
		       (print "Attempting to kill server: " server)
		       (print "Attempting to kill pid " pid)
		       (system (conc "kill " pid))
		       (thread-sleep! 2)
		       (system (conc "kill -9 " pid)))))
	       (conc pid)))))
	 servers)
	(thread-sleep! 2))))
;; let's start up a server the mechanical way
(system "nbfake megatest -server -")
(thread-sleep! 2)
;; (test #f #t (string? (server:start-and-wait *toppath*)))