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
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
|
(test "setup for run" #t (begin (launch:setup-for-run)
(string? (getenv "MT_RUN_AREA_HOME"))))
;; NON Server tests go here
(test #f #f (db:dbdat-get-path *db*))
(test #f #f (db:get-run-name-from-id *db* run-id))
(test #f '("SYSTEM" "RELEASE") (rmt:get-keys))
;; (exit)
;; Server tests go here
(test #f #f (tasks:server-running-or-starting? (db:delay-if-busy (tasks:open-db)) run-id))
(server:kind-run run-id)
(test "did server start within 20 seconds?"
#t
(let loop ((remtries 20)
(running (tasks:server-running-or-starting? (db:delay-if-busy
(tasks:open-db))
run-id)))
(if running
(> running 0)
(if (> remtries 0)
(begin
(thread-sleep! 1.1)
(loop (- remtries 1)
(tasks:server-running-or-starting? (db:delay-if-busy
(tasks:open-db))
run-id)))))))
(test "did server become available" #t
(let loop ((remtries 10)
(res (tasks:get-server (db:delay-if-busy (tasks:open-db)) run-id)))
(if res
(vector? res)
(begin
(if (> remtries 0)
(begin
(thread-sleep! 1.1)
(loop (- remtries 1)(tasks:get-server (db:delay-if-busy (tasks:open-db)) run-id)))
res)))))
(define user (current-user-name))
(define runname "mytestrun")
(define keys (rmt:get-keys))
(define runinfo #f)
(define keyvals '(("SYSTEM" "abc")("RELEASE" "def")))
(define header (vector "SYSTEM" "RELEASE" "id" "runname" "state" "status" "owner" "event_time"))
;; Setup
;;
(test #f #f (not (client:setup run-id)))
(test #f #f (not (hash-table-ref/default *runremote* run-id #f)))
;; Login
;;
(test #f '(#t "successful login") (rmt:login-no-auto-client-setup (hash-table-ref/default *runremote* run-id #f) run-id))
(test #f '(#t "successful login") (rmt:login run-id))
;; Keys
;;
(test #f '("SYSTEM" "RELEASE") (rmt:get-keys))
;; No data in db
;;
(test #f '() (rmt:get-all-run-ids))
(test #f #f (rmt:get-run-name-from-id run-id))
(test #f
(let ((runrec (vector #f #f)))
(vector-set! runrec header 0)
(vector-set! runrec (vector #f #f #f #f) 1)
runrec)
(rmt:get-run-info run-id))
;; Insert data into db
;;
(test #f 1 (rmt:register-run keyvals runname "new" "n/a" user))
;; (test #f #f (rmt:get-runs-by-patt keys runname))
(test #f #t (rmt:general-call 'register-test run-id run-id "test-one" ""))
;; With data in db
;;
(test #f '(1) (rmt:get-all-run-ids))
(test #f runname (rmt:get-run-name-from-id run-id))
(test #f
runname
(let ((run-info (rmt:get-run-info run-id)))
(db:get-value-by-header (db:get-rows run-info)
(db:get-header run-info)
"runname")))
;; (vector header (vector "abc" "def" 1 "mytestrun" "new" "n/a" "matt" 1416280640.0))
;; test killing server
;;
(tasks:kill-server-run-id run-id)
(test #f #f (tasks:server-running-or-starting? (db:delay-if-busy (tasks:open-db)) run-id))
;; (test #f #f (client:setup run-id))
;; (set! *transport-type* 'http)
;;
;; (test "setup for run" #t (begin (launch:setup-for-run)
;; (string? (getenv "MT_RUN_AREA_HOME"))))
|
|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
|
>
|
|
>
|
|
|
<
>
>
>
>
>
>
>
>
>
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
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
|
(test "setup for run" #t (begin (launch:setup-for-run)
(string? (getenv "MT_RUN_AREA_HOME"))))
;; NON Server tests go here
(test #f #f (db:dbdat-get-path *db*))
(test #f #f (db:get-run-name-from-id *db* run-id))
;; (test #f '("SYSTEM" "RELEASE") (rmt:get-keys))
;; (exit)
;; Server tests go here
(for-each
(lambda (run-id)
(test #f #f (tasks:server-running-or-starting? (db:delay-if-busy (tasks:open-db)) run-id))
(server:kind-run run-id)
(test "did server start within 20 seconds?"
#t
(let loop ((remtries 20)
(running (tasks:server-running-or-starting? (db:delay-if-busy
(tasks:open-db))
run-id)))
(if running
(> running 0)
(if (> remtries 0)
(begin
(thread-sleep! 1)
(loop (- remtries 1)
(tasks:server-running-or-starting? (db:delay-if-busy
(tasks:open-db))
run-id)))))))
(test "did server become available" #t
(let loop ((remtries 10)
(res (tasks:get-server (db:delay-if-busy (tasks:open-db)) run-id)))
(if res
(vector? res)
(begin
(if (> remtries 0)
(begin
(thread-sleep! 1.1)
(loop (- remtries 1)(tasks:get-server (db:delay-if-busy (tasks:open-db)) run-id)))
res)))))
)
(list 0 1))
(define user (current-user-name))
(define runname "mytestrun")
(define keys (rmt:get-keys))
(define runinfo #f)
(define keyvals '(("SYSTEM" "abc")("RELEASE" "def")))
(define header (list "SYSTEM" "RELEASE" "id" "runname" "state" "status" "owner" "event_time"))
;; Setup
;;
(test #f #f (not (client:setup run-id)))
(test #f #f (not (hash-table-ref/default *runremote* run-id #f)))
;; Login
;;
(test #f'(#t "successful login")
(rmt:login-no-auto-client-setup (hash-table-ref/default *runremote* run-id #f) run-id))
(test #f '(#t "successful login")
(rmt:login run-id))
;; Keys
;;
(test #f '("SYSTEM" "RELEASE") (rmt:get-keys))
;; No data in db
;;
(test #f '() (rmt:get-all-run-ids))
(test #f #f (rmt:get-run-name-from-id run-id))
(test #f
(vector
header
(vector #f #f #f #f))
(rmt:get-run-info run-id))
;; Insert data into db
;;
(test #f 1 (rmt:register-run keyvals runname "new" "n/a" user))
;; (test #f #f (rmt:get-runs-by-patt keys runname))
(test #f #t (rmt:general-call 'register-test run-id run-id "test-one" ""))
(define test-one-id #f)
(test #f 1 (let ((test-id (rmt:get-test-id run-id "test-one" "")))
(set! test-one-id test-id)
test-id))
(define test-one-rec #f)
(test #f "test-one" (let ((test-rec (rmt:get-test-info-by-id run-id test-one-id)))
(set! test-one-rec test-rec)
(vector-ref test-rec 2)))
;; With data in db
;;
(print "Using runame=" runname)
(test #f '(1) (rmt:get-all-run-ids))
(test #f runname (rmt:get-run-name-from-id run-id))
(test #f
runname
(let ((run-info (rmt:get-run-info run-id)))
(db:get-value-by-header (db:get-rows run-info)
(db:get-header run-info)
"runname")))
(for-each (lambda (run-id)
;; test killing server
;;
(tasks:kill-server-run-id run-id)
(test #f #f (tasks:server-running-or-starting? (db:delay-if-busy (tasks:open-db)) run-id))
)
(list 0 1))
;; Tests to assess reading/writing while servers are starting/stopping
(define start-time (current-seconds))
(let loop ((test-state 'start))
(let* ((server-dats (tasks:get-server-records (db:delay-if-busy (tasks:open-db)) run-id))
(first-dat (if (not (null? server-dats))
(car server-dats)
#f)))
(map (lambda (dat)
(apply print (intersperse (vector->list dat) ", ")))
server-dats)
(test #f test-one-rec (rmt:get-test-info-by-id run-id test-one-id))
(thread-sleep! 1)
(case test-state
((start)
(print "Trying to start server")
(server:kind-run run-id)
(loop 'server-started))
((server-started)
(case (vector-ref first-dat)
((running)
(print "Server appears to be running. Now ask it to shutdown")
(rmt:kill-server run-id)
(loop 'server-shutdown))
((shutting-down)
(loop test-state))
(else (print "Don't know what to do if get here"))))
((server-shutdown)
(loop test-state)))))
;;======================================================================
;; END OF TESTS
;;======================================================================
;; (test #f #f (client:setup run-id))
;; (set! *transport-type* 'http)
;;
;; (test "setup for run" #t (begin (launch:setup-for-run)
;; (string? (getenv "MT_RUN_AREA_HOME"))))
|