Megatest

Check-in [987ac55bdd]
Login
Overview
Comment:Added direct.scm for the direct to db connection test
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.64-minimt
Files: files | file ages | folders
SHA1: 987ac55bdda7ef30982a497b7b74289a9810dedb
User & Date: matt on 2017-06-25 16:20:43
Other Links: branch diff | manifest | tags
Context
2017-06-25
21:56
minor improvements to minimt Closed-Leaf check-in: d806a4bc74 user: matt tags: v1.64-minimt
16:20
Added direct.scm for the direct to db connection test check-in: 987ac55bdd user: matt tags: v1.64-minimt
16:07
Base scenario working. Takes aprox 60-70 seconds to run. check-in: 96bdf8577f user: matt tags: v1.64-minimt
Changes

Modified minimt/Makefile from [01be78487b] to [a3a84a9e52].

1
2
3
4
5
6
minimt : minimt.scm db.scm setup.scm
	csc minimt.scm

clean :
	rm -rf runtest/*

|





1
2
3
4
5
6
minimt : minimt.scm db.scm setup.scm direct.scm
	csc minimt.scm

clean :
	rm -rf runtest/*

Added minimt/direct.scm version [61661674b3].





















>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
;; direct API, call the db calls directly

(define rmt:create-run create-run)
(define rmt:create-step create-step)
(define rmt:create-test create-test)
(define rmt:get-test-id get-test-id)
(define rmt:get-run-id  get-run-id)
(define rmt:open-create-db open-create-db)
(define rmt:step-set-state-status step-set-state-status)
(define rmt:test-set-state-status test-set-state-status)

Modified minimt/minimt.scm from [8f30c5ea44] to [731c706dfc].

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
56
57
(use posix)

(include "db.scm")

;; define following in setup.scm
;;    *remotehost*  => host for "tests"
;;    *homehost*    => host for servers
;;    *homepath*    => directory from which to run
;;    *numtests*    => how many tests to simulate for each run
;;    *numruns*     => how many runs to simulate
;;    
(include "setup.scm")



;; RUN A TEST
(define (run-test dbconn run-id test-name)
  (create-test dbconn run-id test-name)
  (let ((test-id (get-test-id dbconn run-id test-name)))
    (test-set-state-status dbconn test-id "LAUNCHED" "na")
    (thread-sleep! *launchdelay*)
    (test-set-state-status dbconn test-id "RUNNING" "na")
    (for-each
     (lambda (step-name)
       (create-step dbconn test-id step-name)
       (let ((step-id (get-step-id dbconn test-id step-name)))
	 (step-set-state-status dbconn step-id "START" -1)
	 (thread-sleep! *stepdelay*)
	 (step-set-state-status dbconn step-id "END" 0)
	 (print"   STEP: " step-name " done.")))
     '("step1" "step2" "step3" "step4" "step5" "step6" "step7" "step8" "step9"))
    (print "TEST: " test-name " done.")
    test-id))

;; RUN A RUN
(define (run-run dbconn target run-name num-tests)
  (create-run dbconn target run-name)
  (let ((run-id (get-run-id dbconn target run-name)))
    (let loop ((test-num 0))
      (system (conc "NBFAKE_LOG=test-" test-num "-run-id-" run-id ".log NBFAKE_HOST=" *remotehost* " nbfake minimt runtest " run-id " test-" test-num))
      (if (< test-num num-tests)
	  (loop (+ test-num 1))))))

;; Do what is asked
(let ((args (cdr (argv))))
  (if (< (length args) 1)
      (print
       "Usage: minimt [options]" "
  runtest run-id testname
  runrun  target runname")
      (let ((cmd    (car args))
	    (dbconn (open-create-db *homepath* "mt.db" init-db)))
	(change-directory *homepath*)
	(case (string->symbol cmd)
	  ((runtest)
	   (let ((run-id    (string->number (cadr args)))
		 (test-name (caddr args)))
	     (print "Launching test " test-name " for run-id " run-id)
	     (run-test dbconn run-id test-name)))













>
>


|
|
|

|


|

|

|







|
|













|







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
56
57
58
59
(use posix)

(include "db.scm")

;; define following in setup.scm
;;    *remotehost*  => host for "tests"
;;    *homehost*    => host for servers
;;    *homepath*    => directory from which to run
;;    *numtests*    => how many tests to simulate for each run
;;    *numruns*     => how many runs to simulate
;;    
(include "setup.scm")

(include "direct.scm") ;; direct db calls

;; RUN A TEST
(define (run-test dbconn run-id test-name)
  (rmt:create-test dbconn run-id test-name)
  (let ((test-id (rmt:get-test-id dbconn run-id test-name)))
    (rmt:test-set-state-status dbconn test-id "LAUNCHED" "na")
    (thread-sleep! *launchdelay*)
    (rmt:test-set-state-status dbconn test-id "RUNNING" "na")
    (for-each
     (lambda (step-name)
       (rmt:create-step dbconn test-id step-name)
       (let ((step-id (get-step-id dbconn test-id step-name)))
	 (rmt:step-set-state-status dbconn step-id "START" -1)
	 (thread-sleep! *stepdelay*)
	 (rmt:step-set-state-status dbconn step-id "END" 0)
	 (print"   STEP: " step-name " done.")))
     '("step1" "step2" "step3" "step4" "step5" "step6" "step7" "step8" "step9"))
    (print "TEST: " test-name " done.")
    test-id))

;; RUN A RUN
(define (run-run dbconn target run-name num-tests)
  (rmt:create-run dbconn target run-name)
  (let ((run-id (rmt:get-run-id dbconn target run-name)))
    (let loop ((test-num 0))
      (system (conc "NBFAKE_LOG=test-" test-num "-run-id-" run-id ".log NBFAKE_HOST=" *remotehost* " nbfake minimt runtest " run-id " test-" test-num))
      (if (< test-num num-tests)
	  (loop (+ test-num 1))))))

;; Do what is asked
(let ((args (cdr (argv))))
  (if (< (length args) 1)
      (print
       "Usage: minimt [options]" "
  runtest run-id testname
  runrun  target runname")
      (let ((cmd    (car args))
	    (dbconn (rmt:open-create-db *homepath* "mt.db" init-db)))
	(change-directory *homepath*)
	(case (string->symbol cmd)
	  ((runtest)
	   (let ((run-id    (string->number (cadr args)))
		 (test-name (caddr args)))
	     (print "Launching test " test-name " for run-id " run-id)
	     (run-test dbconn run-id test-name)))