Index: archive.scm
==================================================================
--- archive.scm
+++ archive.scm
@@ -386,6 +386,83 @@
(run-n-wait bup-exe params: bup-restore-params print-cmd: #f)
;; (mutex-unlock! bup-mutex)
(mt:test-set-state-status-by-id run-id test-id "COMPLETED" #f #f)))
(debug:print-error 0 *default-log-port* "No archive path in the record for run-id=" run-id " test-id=" test-id))))
(filter vector? tests))))
-
+
+(define (common:get-youngest-test tests)
+ (if (null? tests)
+ #f
+ (let ((res #f))
+ (for-each
+ (lambda (test-dat)
+ (let ((event-time (db:test-get-event_time test-dat)))
+ (if (or (not res)
+ (> event-time (db:test-get-event_time res)))
+ (set! res test-dat))))
+ tests)
+ res)))
+
+;; from an archive get a specific path - works ONLY with bup for now
+;;
+(define (archive:bup-get-data archive-command run-id-in run-name-in tests rp-mutex bup-mutex)
+ (if (null? tests)
+ (debug:print-info 0 *default-log-port* "get-data called with no matching tests to operate on.")
+
+ (let* ((bup-exe (or (configf:lookup *configdat* "archive" "bup") "bup"))
+ (linktree (common:get-linktree)) ;; (configf:lookup *configdat* "setup" "linktree")))
+ ;; (test-dat (common:get-youngest-test tests))
+ (destpath (args:get-arg "-dest")))
+ (cond
+ ((null? tests)
+ (debug:print-error 0 *default-log-port*
+ "No test matching provided target, runname pattern and test pattern found."))
+ ((file-exists? destpath)
+ (debug:print-error 0 *default-log-port*
+ "Destination path alread exists! Please remove it before running get."))
+ (else
+ (let loop ((rem-tests tests))
+ (let* ((test-dat (common:get-youngest-test rem-tests))
+ (item-path (db:test-get-item-path test-dat))
+ (test-name (db:test-get-testname test-dat))
+ (test-id (db:test-get-id test-dat))
+ (run-id (db:test-get-run_id test-dat))
+ (run-name (rmt:get-run-name-from-id run-id))
+ (keyvals (rmt:get-key-val-pairs run-id))
+ (target (string-intersperse (map cadr keyvals) "/"))
+
+ (toplevel/children (and (db:test-get-is-toplevel test-dat)
+ (> (rmt:test-toplevel-num-items run-id test-name) 0)))
+ (test-partial-path (conc target "/" run-name "/"
+ (db:test-make-full-name test-name item-path)))
+ ;; note the trailing slash to get the dir inspite of it being a link
+ (test-path (conc linktree "/" test-partial-path))
+ (archive-block-id (db:test-get-archived test-dat))
+ (archive-block-info (rmt:test-get-archive-block-info archive-block-id))
+ (archive-path (if (vector? archive-block-info)
+ (vector-ref archive-block-info 2)
+ #f))
+ (archive-internal-path (conc (common:get-testsuite-name) "-" run-id
+ "/latest/" test-partial-path)))
+
+ (if (and archive-path ;; no point in proceeding if there is no actual archive
+ (not toplevel/children))
+ (begin
+ (let* ((bup-restore-params (list "-d" archive-path "restore" "-C" (or destpath "data")
+ ;; " " ;; What is the empty string for?
+ archive-internal-path)))
+ (debug:print-info 0 *default-log-port* "Restoring archived data to " (or destpath "data")
+ " from archive in " archive-path " ... " archive-internal-path)
+ (run-n-wait bup-exe params: bup-restore-params print-cmd: #t)))
+ (let ((new-rem-tests (filter (lambda (tdat)
+ (or (not (eq? (db:test-get-id tdat) test-id))
+ (not (eq? (db:test-get-run_id tdat) run-id))))
+ rem-tests) ))
+ (debug:print-info 0 *default-log-port*
+ "No archive path in the record for run-id=" run-id
+ " test-id=" test-id ", skipping.")
+ (if (null? new-rem-tests)
+ (begin
+ (debug:print-info 0 *default-log-port* "No archives found for " target "/" run-name "...")
+ #f)
+ (loop new-rem-tests)))))))))))
+
Index: common.scm
==================================================================
--- common.scm
+++ common.scm
@@ -1197,11 +1197,23 @@
;;
(define (common:bash-glob instr)
(string-split
(with-input-from-pipe
(conc "/bin/bash -c \"echo " instr "\"")
- read-line)))
+ read-line)))
+
+;;======================================================================
+;; Some safety net stuff
+;;======================================================================
+
+;; return input if it is a list or return null
+(define (common:list-or-null inlst #!key (ovrd #f)(message #f))
+ (if (list? inlst)
+ inlst
+ (begin
+ (if message (debug:print-error 0 *default-log-port* message))
+ (or ovrd '()))))
;;======================================================================
;; T A R G E T S , S T A T E , S T A T U S ,
;; R U N N A M E A N D T E S T P A T T
;;======================================================================
Index: docs/manual/howto.txt
==================================================================
--- docs/manual/howto.txt
+++ docs/manual/howto.txt
@@ -13,196 +13,213 @@
// You should have received a copy of the GNU General Public License
// along with Megatest. If not, see .
//
// Copyright 2006-2012, Matthew Welland.
-How To Do Things
-----------------
-
-Process Runs
-~~~~~~~~~~~~
-
-Remove Runs
-^^^^^^^^^^^
-
-From the dashboard click on the button (PASS/FAIL...) for one of the tests. From the test control panel that
-comes up push the clean test button. The command field will be prefilled with a template command for removing
-that test. You can edit the command, for example change the argument to -testpatt to "%" to remove all tests.
-
-.Remove the test diskperf and all it's items
-----------------
-megatest -remove-runs -target ubuntu/nfs/none -runname ww28.1a -testpatt diskperf/% -v
-----------------
-
-.Remove all tests for all runs and all targets
-----------------
-megatest -remove-runs -target %/%/% -runname % -testpatt % -v
-----------------
-
-Archive Runs
-^^^^^^^^^^^^
-
-Megatest supports using the bup backup tool (https://bup.github.io/) to archive your tests for efficient storage
-and retrieval. Archived data can be rapidly retrieved if needed. The metadata for the run (PASS/FAIL status, run
-durations, time stamps etc.) are all preserved in the megatest database.
-
-For setup information see the Archiving topic in the reference section of this manual.
-
-To Archive
-++++++++++
-
-Hint: use the test control panel to create a template command by pushing the "Archive Tests" button.
-
-.Archive a full run
-----------------
-megatest -target ubuntu/nfs/none -runname ww28.1a -archive save-remove -testpatt %
-----------------
-
-To Restore
-++++++++++
-
-.Retrieve a single test
-----------------
-megatest -target ubuntu/nfs/none -runname ww28.1a -archive restore -testpatt diskperf/%
-----------------
-
-Hint: You can browse the archive using bup commands directly.
-
-----------------
-bup -d /path/to/bup/archive ftp
-----------------
-
-Submit jobs to Host Types based on Test Name
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.In megatest.config
-------------------------
-[host-types]
-general ssh #{getbgesthost general}
-nbgeneral nbjob run JOBCOMMAND -log $MT_LINKTREE/$MT_TARGET/$MT_RUNNAME.$MT_TESTNAME-$MT_ITEM_PATH.lgo
-
-[hosts]
-general cubian xena
-
-[launchers]
-envsetup general
-xor/%/n 4C16G
-% nbgeneral
-
-[jobtools]
-launcher bsub
-# if defined and not "no" flexi-launcher will bypass launcher unless there is no
-# match.
-flexi-launcher yes
-------------------------
-
-Tricks
-------
-
-This section is a compendium of a various useful tricks for debugging,
-configuring and generally getting the most out of Megatest.
-
-Limiting your running jobs
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The following example will limit a test in the jobgroup "group1" to no more than 10 tests simultaneously.
-
-In your testconfig:
-
-----------------
-[test_meta]
-jobgroup group1
-----------------
-
-In your megatest.config:
-
----------------
-[jobgroups]
-group1 10
-custdes 4
----------------
-
-Debugging Tricks
-----------------
-
-Examining The Environment
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Test Control Panel - xterm
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-From the dashboard click on a test PASS/FAIL button. This brings up a test control panel. Aproximately near the center left of the
-window there is a button "Start Xterm". Push this to get an xterm with the full context and environment loaded for that test. You can run
-scripts or ezsteps by copying from the testconfig (hint, load up the testconfig in a separate gvim or emacs window). This is the easiest way
-to debug your tests.
-
-During Config File Processing
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-It is often helpful to know the content of variables in various
-contexts as Megatest does the actions needed to run your tests. A handy technique is to force the startup of an xterm in the context being examined.
-
-For example, if an item list is not being generated as expected you
-can inject the startup of an xterm as if it were an item:
-
-.Original items table
------------------
-[items]
-CELLNAME [system getcellname.sh]
------------------
-
-.Items table modified for debug
------------------
-[items]
-DEBUG [system xterm]
-CELLNAME [system getcellnames.sh]
------------------
-
-When this test is run an xterm will pop up. In that xterm the
-environment is exactly that in which the script "getcellnames.sh"
-would run. You can now debug the script to find out why it isn't
-working as expected.
-
-Organising Your Tests and Tasks
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The default location "tests" for storing tests can be extended by
-adding to your tests-paths section.
-
-----------------------------
-[misc]
-parent #{shell dirname $(readlink -f .)}
-
-[tests-paths]
-1 #{get misc parent}/simplerun/tests
-----------------------------
-
-The above example shows how you can use addition sections in your
-config file to do complex processing. By putting results of relatively
-slow operations into variables the processing of your configs can be
-kept fast.
-
-Alternative Method for Running your Job Script
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.Directly running job in testconfig
--------------------
-[setup]
-runscript main.csh
--------------------
-
-The runscript method is essentially a brute force way to run scripts where the
-user is responsible for setting STATE and STATUS and managing the details of running a test.
-
-Debugging Server Problems
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Some handy Unix commands to track down issues with servers not
-communicating with your test manager processes. Please put in tickets
-at https://www.kiatoa.com/fossils/megatest if you have problems with
-servers getting stuck.
-
-----------------
-sudo lsof -i
-sudo netstat -lptu
-sudo netstat -tulpn
+How To Do Things
+----------------
+
+Process Runs
+~~~~~~~~~~~~
+
+Remove Runs
+^^^^^^^^^^^
+
+From the dashboard click on the button (PASS/FAIL...) for one of the tests. From the test control panel that
+comes up push the clean test button. The command field will be prefilled with a template command for removing
+that test. You can edit the command, for example change the argument to -testpatt to "%" to remove all tests.
+
+.Remove the test diskperf and all it's items
+----------------
+megatest -remove-runs -target ubuntu/nfs/none -runname ww28.1a -testpatt diskperf/% -v
+----------------
+
+.Remove all tests for all runs and all targets
+----------------
+megatest -remove-runs -target %/%/% -runname % -testpatt % -v
+----------------
+
+Archive Runs
+^^^^^^^^^^^^
+
+Megatest supports using the bup backup tool (https://bup.github.io/) to archive your tests for efficient storage
+and retrieval. Archived data can be rapidly retrieved if needed. The metadata for the run (PASS/FAIL status, run
+durations, time stamps etc.) are all preserved in the megatest database.
+
+For setup information see the Archiving topic in the reference section of this manual.
+
+To Archive
+++++++++++
+
+Hint: use the test control panel to create a template command by pushing the "Archive Tests" button.
+
+.Archive a full run
+----------------
+megatest -target ubuntu/nfs/none -runname ww28.1a -archive save-remove -testpatt %
+----------------
+
+To Restore
+++++++++++
+
+.Retrieve a single test
+----------------
+megatest -target ubuntu/nfs/none -runname ww28.1a -archive restore -testpatt diskperf/%
+----------------
+
+Hint: You can browse the archive using bup commands directly.
+
+----------------
+bup -d /path/to/bup/archive ftp
+----------------
+
+Pass Data from Test to Test
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.To save the data call archive save within your test:
+----------------
+megatest -archive save
+----------------
+
+.To retrieve the data call archive get using patterns as needed
+----------------
+# Put the retrieved data into /tmp
+DESTPATH=/tmp/$USER/$MT_TARGET/$MT_RUN_NAME/$MT_TESTNAME/$MT_ITEMPATH/my_data
+mkdir -p $DESTPATH
+megatest -archive get -runname % -dest $DESTPATH
+----------------
+
+
+Submit jobs to Host Types based on Test Name
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.In megatest.config
+------------------------
+[host-types]
+general ssh #{getbgesthost general}
+nbgeneral nbjob run JOBCOMMAND -log $MT_LINKTREE/$MT_TARGET/$MT_RUNNAME.$MT_TESTNAME-$MT_ITEM_PATH.lgo
+
+[hosts]
+general cubian xena
+
+[launchers]
+envsetup general
+xor/%/n 4C16G
+% nbgeneral
+
+[jobtools]
+launcher bsub
+# if defined and not "no" flexi-launcher will bypass launcher unless there is no
+# match.
+flexi-launcher yes
+------------------------
+
+Tricks
+------
+
+This section is a compendium of a various useful tricks for debugging,
+configuring and generally getting the most out of Megatest.
+
+Limiting your running jobs
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The following example will limit a test in the jobgroup "group1" to no more than 10 tests simultaneously.
+
+In your testconfig:
+
+----------------
+[test_meta]
+jobgroup group1
+----------------
+
+In your megatest.config:
+
+---------------
+[jobgroups]
+group1 10
+custdes 4
+---------------
+
+Debugging Tricks
+----------------
+
+Examining The Environment
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Test Control Panel - xterm
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+From the dashboard click on a test PASS/FAIL button. This brings up a test control panel. Aproximately near the center left of the
+window there is a button "Start Xterm". Push this to get an xterm with the full context and environment loaded for that test. You can run
+scripts or ezsteps by copying from the testconfig (hint, load up the testconfig in a separate gvim or emacs window). This is the easiest way
+to debug your tests.
+
+During Config File Processing
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+It is often helpful to know the content of variables in various
+contexts as Megatest does the actions needed to run your tests. A handy technique is to force the startup of an xterm in the context being examined.
+
+For example, if an item list is not being generated as expected you
+can inject the startup of an xterm as if it were an item:
+
+.Original items table
+-----------------
+[items]
+CELLNAME [system getcellname.sh]
+-----------------
+
+.Items table modified for debug
+-----------------
+[items]
+DEBUG [system xterm]
+CELLNAME [system getcellnames.sh]
+-----------------
+
+When this test is run an xterm will pop up. In that xterm the
+environment is exactly that in which the script "getcellnames.sh"
+would run. You can now debug the script to find out why it isn't
+working as expected.
+
+Organising Your Tests and Tasks
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The default location "tests" for storing tests can be extended by
+adding to your tests-paths section.
+
+----------------------------
+[misc]
+parent #{shell dirname $(readlink -f .)}
+
+[tests-paths]
+1 #{get misc parent}/simplerun/tests
+----------------------------
+
+The above example shows how you can use addition sections in your
+config file to do complex processing. By putting results of relatively
+slow operations into variables the processing of your configs can be
+kept fast.
+
+Alternative Method for Running your Job Script
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.Directly running job in testconfig
+-------------------
+[setup]
+runscript main.csh
+-------------------
+
+The runscript method is essentially a brute force way to run scripts where the
+user is responsible for setting STATE and STATUS and managing the details of running a test.
+
+Debugging Server Problems
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some handy Unix commands to track down issues with servers not
+communicating with your test manager processes. Please put in tickets
+at https://www.kiatoa.com/fossils/megatest if you have problems with
+servers getting stuck.
+
+----------------
+sudo lsof -i
+sudo netstat -lptu
+sudo netstat -tulpn
----------------
Index: docs/manual/megatest_manual.html
==================================================================
--- docs/manual/megatest_manual.html
+++ docs/manual/megatest_manual.html
@@ -1452,10 +1452,26 @@
bup -d /path/to/bup/archive ftp
+
+
+
Pass Data from Test to Test
+
+
To save the data call archive save within your test:
+
+
megatest -archive save
+
+
+
To retrieve the data call archive get using patterns as needed
+
+
# Put the retrieved data into /tmp
+DESTPATH=/tmp/$USER/$MT_TARGET/$MT_RUN_NAME/$MT_TESTNAME/$MT_ITEMPATH/my_data
+mkdir -p $DESTPATH
+megatest -archive get -runname % -dest $DESTPATH
+
Submit jobs to Host Types based on Test Name
In megatest.config
@@ -2366,10 +2382,29 @@
Propagate environment to next step
$MT_MEGATEST -env2file .ezsteps/${stepname}
+
+
+
Scripts
+
+
Specifying scripts inline (best used for only simple scripts)
+
+
[scripts]
+loaddb #!/bin/bash
+ sqlite3 $1 <<EOF
+ .mode tabs
+ .import $2 data
+ .q
+ EOF
+
+
The above snippet results in the creation of an executable script
+called "loaddb" in the test directory. NOTE: every line in the script
+must be prefixed with the exact same number of spaces. Lines beginning
+with a # will not work as expected. Currently you cannot indent
+intermediate lines.
Full example with ezsteps, logpro rules, scripts etc.
# You can include a common file
#
@@ -3134,10 +3169,10 @@