Megatest

Check-in [eb90f6fe98]
Login
Overview
Comment:updated api unit tests and corrected cleanup
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65
Files: files | file ages | folders
SHA1: eb90f6fe980d47e0aeec5e24b106ff77ee4373bf
User & Date: mmgraham on 2019-08-26 14:37:37
Other Links: branch diff | manifest | tags
Context
2019-08-27
11:18
Fix for mtut not converting config option to a number check-in: ae80d00cc7 user: jmoon18 tags: v1.65
2019-08-26
14:37
updated api unit tests and corrected cleanup check-in: eb90f6fe98 user: mmgraham tags: v1.65
2019-08-25
21:26
added initial version of api unit tests. check-in: 2e84f80306 user: mmgraham tags: v1.65
Changes

Modified tests/rununittest.sh from [2e9330431f] to [1c340ef384].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
export PATH="${mtbindir}:$PATH"

# Clean setup
#
dbdir=$(echo /tmp/$USER/megatest_localdb/simplerun/.[a-zA-Z]*/)
echo "dbdir=$dbdir"
rm -f simplerun/megatest.db simplerun/monitor.db simplerun/db/monitor.db $dbdir
rm -rf simplelinks/ simpleruns/ simplerun/db/ $dbdir
mkdir -p simplelinks simpleruns
(cd simplerun;cp ../../*_records.scm .;perl -pi.bak -e 's/define-inline/define/' *_records.scm)
(cd simplerun;cp ../../altdb.scm .)

# Run the test $1 is the unit test to run
cd simplerun;echo '(load "../tests.scm")' | ../../bin/megatest -repl -debug $2 $1







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
export PATH="${mtbindir}:$PATH"

# Clean setup
#
dbdir=$(echo /tmp/$USER/megatest_localdb/simplerun/.[a-zA-Z]*/)
echo "dbdir=$dbdir"
rm -f simplerun/megatest.db simplerun/monitor.db simplerun/db/monitor.db
rm -rf simplelinks/ simpleruns/ simplerun/db/ $dbdir
mkdir -p simplelinks simpleruns
(cd simplerun;cp ../../*_records.scm .;perl -pi.bak -e 's/define-inline/define/' *_records.scm)
(cd simplerun;cp ../../altdb.scm .)

# Run the test $1 is the unit test to run
cd simplerun;echo '(load "../tests.scm")' | ../../bin/megatest -repl -debug $2 $1

Modified tests/unittests/all-api.scm from [85d5dbfa84] to [67ebf06449].

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
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
;;     You should have received a copy of the GNU General Public License
;;     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.


;; Run like this:
;;
;; Update the following line. make unit from parent directory.
;;  ./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))
       
(set! my-dbstruct (db:setup #t))

(define toppath (current-directory))
(test #f #t (string?(server:start-and-wait *toppath*)))

(test "setup for run" #t (begin (launch:setup)
 				(string? (getenv "MT_RUN_AREA_HOME"))))
(test #f #t (vector? (client:setup toppath)))


;;(test #f #t (vector? (rmt:get-connection-info toppath))) ;; TODO: push areapath down.

(test #f #t (string? (server:check-if-running ".")))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'login (list toppath 1.6531 "Fred"))) 0))
(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-latest-host-load (list "localhost"))) 0))
(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-tests-tags (list ))) 0))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-val-pairs (list 0 ))) 1))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys (list ))) 1))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys-write (list ))) 1))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-vals (list 1 ))) 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 #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-test-info-by-id (list 1 1))) 0))
(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 (list? (rmt:get-tests-for-runs-mindata '(1) "%" '() '() #f)))
;; Gets "message: unbound variable"
;;(test #f #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-tests-for-runs-mindata (list '(1 2) "%" '("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))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "test-toplevel-num-items" (list 1 "foo"))) 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-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))
(define keys (db:get-keys my-dbstruct))
(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 "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))
(define keypatts '(("SYSTEM" "ubuntu")("RELEASE" "v1.234")) )
(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 "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 (1))(api:execute-requests my-dbstruct (vector "get-all-run-ids" '())))







|







<
<
|
<

<
|
<
<
<
>

|

<
|
|















<
<
<
|
<










<












<







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
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
;;     You should have received a copy of the GNU General Public License
;;     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.


;; Run like this:
;;
;; Update the following line. make unit from parent directory.
;;  ./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 "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-tests-tags (list ))) 0))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-val-pairs (list 0 ))) 1))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys (list ))) 1))
(test #f '("SYSTEM" "RELEASE") (vector-ref (api:execute-requests my-dbstruct (vector 'get-keys-write (list ))) 1))
(test #f '() (vector-ref (api:execute-requests my-dbstruct (vector 'get-key-vals (list 1 ))) 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 #t (vector-ref (api:execute-requests my-dbstruct (vector 'get-test-info-by-id (list 1 1))) 0))
(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))

(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))
(test #f 0 (vector-ref (api:execute-requests my-dbstruct (vector "test-toplevel-num-items" (list 1 "foo"))) 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-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 "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 #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 "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 (1))(api:execute-requests my-dbstruct (vector "get-all-run-ids" '())))