ADDED autostuff/.mtutil.scm
Index: autostuff/.mtutil.scm
==================================================================
--- /dev/null
+++ autostuff/.mtutil.scm
@@ -0,0 +1,88 @@
+;; Copyright 2006-2017, Matthew Welland.
+;;
+;; This file is part of Megatest.
+;;
+;; Megatest is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Megatest is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Megatest. If not, see .
+
+(use json)
+(use ducttape-lib)
+
+(define (get-last-runname area-path target)
+ (let* ((run-data (with-input-from-pipe (conc "megatest -list-runs % -target " target " -fields runs:runname,event_time -dumpmode sexpr -start-dir " area-path)
+ read)))
+ (if (or (not run-data)
+ (null? run-data))
+ #f
+ (let* ((name-time (let ((dat (map cdadr (alist-ref target run-data equal?)))) ;; (("runname" . "2017w07.0-0047") ("event_time" . "1487490424"))
+ ;; (print "dat=" dat)
+ (map (lambda (item)
+ (cons (alist-ref "runname" item equal?)
+ (string->number (alist-ref "event_time" item equal?))))
+ dat)))
+ (sorted (sort name-time (lambda (a b)(> (cdr a)(cdr b)))))
+ (last-name (if (null? sorted)
+ #f
+ (caar sorted))))
+ last-name))))
+
+(define (str-first-char->number str)
+ (char->integer (string-ref str 0)))
+
+;; example of how to set up and write target mappers
+;; NOTE: maps a *list* of targets!
+;;
+;; (? target run-name area area-path reason contour mode-patt)
+;;
+(add-target-mapper 'prefix-contour
+ (lambda (runkey area contour)
+ (print "target: " runkey)
+ (list (conc contour "/" runkey))))
+#;(add-target-mapper 'prefix-area-contour
+ (lambda (target run-name area area-path reason contour mode-patt)
+ (conc area "/" contour "/" target)))
+
+(add-runname-mapper 'corporate-ww
+ (lambda (target run-name area area-path reason contour mode-patt)
+ (print "corporate-ww called with: target=" target " run-name=" run-name " area=" area " area-path=" area-path " reason=" reason " contour=" contour " mode-patt=" mode-patt)
+ (let* ((last-name (get-last-runname area-path target))
+ (last-letter (let* ((ch (if (string? last-name)
+ (let ((len (string-length last-name)))
+ (substring last-name (- len 1) len))
+ "a"))
+ (chnum (str-first-char->number ch))
+ (a (str-first-char->number "a"))
+ (z (str-first-char->number "z")))
+ (if (and (>= chnum a)(<= chnum z))
+ chnum
+ #f)))
+ (next-letter (if last-letter
+ (list->string
+ (list
+ (integer->char
+ (+ last-letter 1)))) ;; surely there is an easier way?
+ "a")))
+ ;; (print "last-name: " last-name " last-letter: " last-letter " next-letter: " next-letter)
+ (conc (seconds->wwdate (current-seconds)) next-letter))))
+
+(add-runname-mapper 'auto
+ (lambda (target run-name area area-path reason contour mode-patt)
+ "auto-eh"))
+
+;; run only areas where first letter of area name is "a"
+;;
+(add-area-checker 'first-letter-a
+ (lambda (area target contour)
+ (string-match "^a.*$" area)))
+
+
ADDED autostuff/megatest.config
Index: autostuff/megatest.config
==================================================================
--- /dev/null
+++ autostuff/megatest.config
@@ -0,0 +1,85 @@
+# Copyright 2006-2017, Matthew Welland.
+#
+# This file is part of Megatest.
+#
+# Megatest is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Megatest is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Megatest. If not, see .
+
+## commented out due to a bug in v1.6501 in mtutil
+[fields]
+a text
+b text
+c text
+
+[default]
+# usercode .mtutil.scm
+# areafilter area-to-run
+# targtrans generic-target-translator
+# runtrans generic-runname-translator
+usercode .mtutil.scm
+# areafilter area-to-run
+targtrans prefix-contour-broken
+# runtrans generic-runname-translator
+
+[setup]
+pktsdirs /mfs/home/matt/orion_automation/pkts
+
+[areas]
+
+# path-to-area map-target-script(future, optional)
+# someqa path=../megatestqa/someqa; targtrans=somefunc; areafilter=area-to-run
+# targtrans is name of scheme proc stored in .mtutil.scm, which lives in PWD where mtutil is run
+# the target translator can return: a/target OR (list/of targets/to apply/run)
+# OR #f i.e. run nothing
+
+# ext-tests path=ext-tests; targtrans=prefix-contour;
+
+
+ext path=/mfs/home/matt/automation_areas/megatest/ext-tests; targtrans=prefix-contour
+
+[contours]
+# selector=tag-expr/mode-patt
+quick areas=ext; selector=/QUICKPATT
+# quick2 areafn=check-area; selector=/QUICKPATT
+full areas=ext
+# quick areas=fullrun,ext-tests; selector=QUICKPATT/quick
+# full areas=fullrun,ext-tests; selector=MAXPATT/
+# short areas=fullrun,ext-tests; selector=MAXPATT/
+# all areas=fullrun,ext-tests
+# snazy selector=QUICKPATT/
+
+[nopurpose]
+
+[access]
+ext matt:admin mattw:owner
+
+[accesstypes]
+admin run rerun resume remove set-ss rerun-clean
+owner run rerun resume remove rerun-all
+badguy set-ss
+
+[setup]
+maxload 1.2
+
+[listeners]
+localhost:12345 contact=matt@kiatoa.com
+localhost:54321 contact=matt@kiatoa.com
+
+[listener]
+script nbfake echo
+
+
+[server]
+timeout 1
+
+[include local.config]
ADDED autostuff/runconfigs.config
Index: autostuff/runconfigs.config
==================================================================
--- /dev/null
+++ autostuff/runconfigs.config
@@ -0,0 +1,112 @@
+# Copyright 2006-2017, Matthew Welland.
+#
+# This file is part of Megatest.
+#
+# Megatest is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Megatest is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Megatest. If not, see .
+
+# To get emacs font highlighing in the various megatest configs do this:
+#
+# Install emacs-goodies-el:
+# sudo apt install emacs-goodies-el
+# Add to your ~/.emacs file:
+# (add-to-list 'auto-mode-alist '("config\\'" . conf-space-mode))
+#
+
+# example of a cron entry to run sync using db spec pgdb, with pgdb setting in file local.config
+#
+[a/b/c]
+# all:scheduled:sync cron= 0/5 * * * *;dbdest=pgdb;appendconf=/nfs/phoebe/disk1/home/mfs/matt/.sysmaint/local.config
+# quick:scheduled:sync cron= 0/5 * * * *;dbdest=pgdb;appendconf=/nfs/phoebe/disk1/home/mfs/matt/.sysmaint/local.config
+# fast:scheduled:sync-prepend cron= 0/1 * * * *;dbdest=pgdb;appendconf=/mfs/matt/.sysmaint/local.config
+
+# [scriptinc ./gentargets.sh #{getenv USER}]
+# [v1.23/45/67]
+
+# tip will be replaced with hashkey?
+
+# [%/%/%] doesn't work
+
+[/.*/]
+
+[v1.65/tip/dev]
+# file: files changes since last run trigger new run
+# script: script is called with unix seconds as last parameter (other parameters are preserved)
+#
+# contour:sensetype:action params data
+# commented out for debug
+
+quick:file:run runtrans=auto; glob=/nfs/orion/disk1/mfs_home/home/matt/automation_areas/megatest/*.scm foo.touchme
+# snazy:file:run runtrans=corporate-ww; glob=/home/matt/data/megatest/*.scm
+# short:file:run runtrans=short; glob=/home/matt/data/megatest/*.scm
+
+# script returns change-time (unix epoch), new-target-name, run-name
+#
+# quick:script:run checkfossil = http://www.kiatoa.com/fossils/megatest v1.63;\
+# checkfossil = http://www.kiatoa.com/fossils/megatest_qa trunk
+
+# # fossil based trigger
+# #
+quick:fossil:run http://www.kiatoa.com/fossils/megatest=v1.65;\
+ http://www.kiatoa.com/fossils/megatest_qa=trunk
+
+# field allowed values
+# ----- --------------
+# minute 0-59
+# hour 0-23
+# day of month 1-31
+# month 1-12 (or names, future development)
+# day of week 0-7 (0 or 7 is Sun, or, future development, use names)
+
+# actions:
+# run - run a testsuite
+# clean - clear out runs
+# archive - archive runs
+
+# quick:scheduled:run cron=47 * * * * ;run-name=auto
+# quick:scheduled:archive cron=15 20 * * * ;run-name=%;target=%/%/%
+
+# [%]
+# # every friday at midnight clean "all" tests over 7d
+# all:scheduled:clean cron= 0 0 0 0 5;run-name=%;age=7d
+
+[v1.65/tip/dev]
+# # file: files changes since last run trigger new run
+# # script: script is called with unix seconds as last parameter (other parameters are preserved)
+# #
+# # contour:sensetype:action params data
+# quick:file:run run-name=auto;glob=*.scm
+# quick:file:clean run-name=auto;
+# quick:script:run run-name=auto;script=checkfossil.sh v1.63
+#
+# # field allowed values
+# # ----- --------------
+# # minute 0-59
+# # hour 0-23
+# # day of month 1-31
+# # month 1-12 (or names, future development)
+# # day of week 0-7 (0 or 7 is Sun, or, future development, use names)
+#
+# # actions:
+# # run - run a testsuite
+# # clean - clear out runs
+# # archive - archive runs
+#
+quick:scheduled:run cron=47 * * * * ;run-name=auto
+# quick:scheduled:archive cron=15 20 * * * ;run-name=% ;
+#
+
+[%/%/%]
+# # every friday at midnight clean "all" tests over 7d
+all:scheduled:clean cron= 0 0 0 0 5;run-name=%;age=7d
+#
ADDED autostuff/setup.sh
Index: autostuff/setup.sh
==================================================================
--- /dev/null
+++ autostuff/setup.sh
@@ -0,0 +1,2 @@
+source /opt/chicken/4.13.0_18.04_WW45/setup-chicken4x.sh
+export PATH=/mfs/home/matt/orion_automation/bin:$PATH