Megatest

Diff
Login

Differences From Artifact [879c965cf5]:

To Artifact [f4290acd99]:


4059
4060
4061
4062
4063
4064
4065


4066
4067


4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156


















4157

4158
4159
4160
4161
4162
4163
4164
4165
;;
;; Note: mode 'normal means that tests must be COMPLETED and ok (i.e. PASS, WARN, CHECK, SKIP or WAIVED)
;;       mode 'toplevel means that tests must be COMPLETED only
;;       mode 'itemmatch or 'itemwait means that tests items must be COMPLETED and (PASS|WARN|WAIVED|CHECK) [[ NB// NOT IMPLEMENTED YET ]]
;;       mode 'exclusive means this test/item cannot run if the same test/item is LAUNCHED,REMOTEHOSTSTART or RUNNING
;; 
;; (define (db:get-prereqs-not-met dbstruct run-id waitons ref-item-path mode)


(define (db:get-prereqs-not-met dbstruct run-id waitons ref-test-name ref-item-path mode itemmaps) ;; #!key (mode '(normal))(itemmap #f))
  ;; BBnote - rollup of an itemized test's overall state/status done in db:set-state-status-and-roll-up-items


  (append
   (if (member 'exclusive mode)
       (let ((running-tests (db:get-tests-for-run dbstruct
						  #f  ;; run-id of #f means for all runs. 
						  (if (string=? ref-item-path "")   ;; testpatt
						      ref-test-name
						      (conc ref-test-name "/" ref-item-path))
						  '("LAUNCHED" "REMOTEHOSTSTART" "RUNNING") ;; states
						  '()          ;; statuses
						  #f           ;; offset
						  #f           ;; limit
						  #f           ;; not-in
						  #f           ;; sort by
						  #f           ;; sort order
						  'shortlist   ;; query type
						  0            ;; last update, beginning of time ....
						  #f           ;; mode
						  )))
	;;(map (lambda (testdat)
	;;	(if (equal? (db:test-get-item-path testdat) "")
	;;	    (db:test-get-testname testdat)
	;;	    (conc (db:test-get-testname testdat)
	;;		  "/"
	;;		  (db:test-get-item-path testdat))))
	 running-tests) ;; calling functions want the entire data
       '())
   (if (or (not waitons)
	   (null? waitons))
       '()
       (let* ((unmet-pre-reqs '())
	      (result         '()))
	 (for-each 
	  (lambda (waitontest-name)
	    ;; by getting the tests with matching name we are looking only at the matching test 
	    ;; and related sub items
	    ;; next should be using mt:get-tests-for-run?
	    (let ((tests             (db:get-tests-for-run-state-status dbstruct run-id waitontest-name))
		  (ever-seen         #f)
		  (parent-waiton-met #f)
		  (item-waiton-met   #f))
	      (for-each 
	       (lambda (test) ;; BB- this is the upstream test
		 ;; (if (equal? waitontest-name (db:test-get-testname test)) ;; by defintion this had better be true ...
		 (let* ((state             (db:test-get-state test))
			(status            (db:test-get-status test))
			(item-path         (db:test-get-item-path test)) ;; BB- this is the upstream itempath
			(is-completed      (equal? state "COMPLETED"))
			(is-running        (equal? state "RUNNING"))
			(is-killed         (equal? state "KILLED"))
			(is-ok             (member status '("PASS" "WARN" "CHECK" "WAIVED" "SKIP")))
			;;                                       testname-b    path-a    path-b
			(same-itempath     (db:compare-itempaths ref-test-name item-path ref-item-path itemmaps))) ;; (equal? ref-item-path item-path)))
		   (set! ever-seen #t)
		   (cond
		    ;; case 1, non-item (parent test) is 
		    ((and (equal? item-path "") ;; this is the parent test of the waiton being examined
			  is-completed
			  (or is-ok (not (null? (lset-intersection eq? mode '(toplevel)))))) ;;  itemmatch itemwait))))))
		     (set! parent-waiton-met #t))
		    ;; Special case for toplevel and KILLED
		    ((and (equal? item-path "") ;; this is the parent test
			  is-killed
			  (member 'toplevel mode))
		     (set! parent-waiton-met #t))
		    ;; For itemwait mode IFF the previous matching item is good the set parent-waiton-met
		    ((and (not (null? (lset-intersection eq? mode '(itemmatch itemwait)))) ;; how is that different from (member mode '(itemmatch itemwait)) ?????
			  ;; (not (equal? item-path "")) ;; this applies to both top level (to allow launching of next batch) and items
			  same-itempath)
		     (if (and is-completed is-ok)
			 (set! item-waiton-met #t))
		     (if (and (equal? item-path "") ;; if upstream rollup test is completed, parent-waiton-met is set
			      (or is-completed is-running));; this is the parent, set it to run if completed or running ;; BB1
			 (set! parent-waiton-met #t)))
		    ;; normal checking of parent items, any parent or parent item not ok blocks running
		    ((and is-completed
			  (or is-ok 
			      (member 'toplevel mode))              ;; toplevel does not block on FAIL
			  (and is-ok (member 'itemmatch mode))) ;; itemmatch blocks on not ok
		     (set! item-waiton-met #t)))))
	       tests)
	      ;; both requirements, parent and item-waiton must be met to NOT add item to
	      ;; prereq's not met list
	      (if (not (or parent-waiton-met item-waiton-met))
		  (set! result (append (if (null? tests) (list waitontest-name) tests) result))) ;; appends the string if the full record is not available
	      ;; if the test is not found then clearly the waiton is not met...
	      ;; (if (not ever-seen)(set! result (cons waitontest-name result)))))
	      (if (not ever-seen)
		  (set! result (append (if (null? tests)(list waitontest-name) tests) result)))))
	  waitons)


















	 (delete-duplicates result)))))


;;======================================================================
;; Just for sync, procedures to make sync easy
;;======================================================================

;; get an alist of record ids changed since time since-time
;;   '((runs . (1 2 3 ...))(steps . (5 6 7 ...) ...))
;;







>
>


>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|







4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
;;
;; Note: mode 'normal means that tests must be COMPLETED and ok (i.e. PASS, WARN, CHECK, SKIP or WAIVED)
;;       mode 'toplevel means that tests must be COMPLETED only
;;       mode 'itemmatch or 'itemwait means that tests items must be COMPLETED and (PASS|WARN|WAIVED|CHECK) [[ NB// NOT IMPLEMENTED YET ]]
;;       mode 'exclusive means this test/item cannot run if the same test/item is LAUNCHED,REMOTEHOSTSTART or RUNNING
;; 
;; (define (db:get-prereqs-not-met dbstruct run-id waitons ref-item-path mode)


(define (db:get-prereqs-not-met dbstruct run-id waitons ref-test-name ref-item-path mode itemmaps) ;; #!key (mode '(normal))(itemmap #f))
  ;; BBnote - rollup of an itemized test's overall state/status done in db:set-state-status-and-roll-up-items
  (let* ((ok-statuses '("PASS" "WARN" "CHECK" "WAIVED" "SKIP"))
         (have-itemized (not (null? (lset-intersection eq? mode '(itemmatch itemwait))))))
    (append
     (if (member 'exclusive mode)
         (let ((running-tests (db:get-tests-for-run dbstruct
                                                    #f  ;; run-id of #f means for all runs. 
                                                    (if (string=? ref-item-path "")   ;; testpatt
                                                        ref-test-name
                                                        (conc ref-test-name "/" ref-item-path))
                                                    '("LAUNCHED" "REMOTEHOSTSTART" "RUNNING") ;; states
                                                    '()          ;; statuses
                                                    #f           ;; offset
                                                    #f           ;; limit
                                                    #f           ;; not-in
                                                    #f           ;; sort by
                                                    #f           ;; sort order
                                                    'shortlist   ;; query type
                                                    0            ;; last update, beginning of time ....
                                                    #f           ;; mode
                                                    )))
           ;;(map (lambda (testdat)
           ;;	(if (equal? (db:test-get-item-path testdat) "")
           ;;	    (db:test-get-testname testdat)
           ;;	    (conc (db:test-get-testname testdat)
           ;;		  "/"
           ;;		  (db:test-get-item-path testdat))))
           running-tests) ;; calling functions want the entire data
         '())
     (if (or (not waitons)
             (null? waitons))
         '()
         (let* ((unmet-pre-reqs '())
                (result         '()))
           (for-each 
            (lambda (waitontest-name)
              ;; by getting the tests with matching name we are looking only at the matching test 
              ;; and related sub items
              ;; next should be using mt:get-tests-for-run?
              (let ((tests             (db:get-tests-for-run-state-status dbstruct run-id waitontest-name))
                    (ever-seen         #f)
                    (parent-waiton-met #f)
                    (item-waiton-met   #f))
                (for-each 
                 (lambda (test) ;; BB- this is the upstream test
                   ;; (if (equal? waitontest-name (db:test-get-testname test)) ;; by defintion this had better be true ...
                   (let* ((state             (db:test-get-state test))
                          (status            (db:test-get-status test))
                          (item-path         (db:test-get-item-path test)) ;; BB- this is the upstream itempath
                          (is-completed      (equal? state "COMPLETED"))
                          (is-running        (equal? state "RUNNING"))
                          (is-killed         (equal? state "KILLED"))
                          (is-ok             (member status ok-statuses))
                          ;;                                       testname-b    path-a    path-b
                          (same-itempath     (db:compare-itempaths ref-test-name item-path ref-item-path itemmaps))) ;; (equal? ref-item-path item-path)))
                     (set! ever-seen #t)
                     (cond
                      ;; case 1, non-item (parent test) is 
                      ((and (equal? item-path "") ;; this is the parent test of the waiton being examined
                            is-completed
                            (or is-ok (not (null? (lset-intersection eq? mode '(toplevel)))))) ;;  itemmatch itemwait))))))
                       (set! parent-waiton-met #t))
                      ;; Special case for toplevel and KILLED
                      ((and (equal? item-path "") ;; this is the parent test
                            is-killed
                            (member 'toplevel mode))
                       (set! parent-waiton-met #t))
                      ;; For itemwait mode IFF the previous matching item is good the set parent-waiton-met
                      ((and have-itemized ;; how is that different from (member mode '(itemmatch itemwait)) ?????
                            ;; (not (equal? item-path "")) ;; this applies to both top level (to allow launching of next batch) and items
                            same-itempath)
                       (if (and is-completed is-ok)
                           (set! item-waiton-met #t))
                       (if (and (equal? item-path "") ;; if upstream rollup test is completed, parent-waiton-met is set
                                (or is-completed is-running));; this is the parent, set it to run if completed or running ;; BB1
                           (set! parent-waiton-met #t)))
                      ;; normal checking of parent items, any parent or parent item not ok blocks running
                      ((and is-completed
                            (or is-ok 
                                (member 'toplevel mode))              ;; toplevel does not block on FAIL
                            (and is-ok (member 'itemmatch mode))) ;; itemmatch blocks on not ok
                       (set! item-waiton-met #t)))))
                 tests)
                ;; both requirements, parent and item-waiton must be met to NOT add item to
                ;; prereq's not met list
                (if (not (or parent-waiton-met item-waiton-met))
                    (set! result (append (if (null? tests) (list waitontest-name) tests) result))) ;; appends the string if the full record is not available
                ;; if the test is not found then clearly the waiton is not met...
                ;; (if (not ever-seen)(set! result (cons waitontest-name result)))))
                (if (not ever-seen)
                    (set! result (append (if (null? tests)(list waitontest-name) tests) result)))))
            waitons)

           ;; TODO: for itemwait and itemmatch mode, filter out failed toplevel prereq test if any items passed.
           
           ;; a rewrite might help understanding, but quick fix is just remove tests from result which are completed/pass. -BB
           ;;(pp result)
           ;; (let ((prereq-tests-some-items-passed-list '(ref-test-name))) ;; seed with ref-test-name; do not wait on self.

           ;;   (for-each (lambda (test)
           ;;               (if (vector? test)
           ;;                   (if (and
           ;;                        (equal? (db:test-get-state test) "COMPLETED")
           ;;                        (member (db:test-get-status test) ok-statuses)
           ;;                        (not (equal? (db:test-get-item-path test) "")))
           ;;                       (set! prereq-tests-some-items-passed-list (cons (db:test-get-testname test) prereq-tests-some-items-passed-list)))))
           ;;             result)
           ;;   (set! prereq-tests-some-items-passed-list (delete-duplicates prereq-tests-some-items-passed-list))
                                               

           (delete-duplicates result)
           )))))
  
;;======================================================================
;; Just for sync, procedures to make sync easy
;;======================================================================

;; get an alist of record ids changed since time since-time
;;   '((runs . (1 2 3 ...))(steps . (5 6 7 ...) ...))
;;