[Fuego] [PATCH v3] batch: add test case for batch.

Zheng Ruoqin zhengrq.fnst at cn.fujitsu.com
Fri Nov 16 16:33:38 UTC 2018


batch command is used to queue, examine or delete jobs for later
execution

Signed-off-by: Zheng Ruoqin <zhengrq.fnst at cn.fujitsu.com>
---
 engine/tests/Functional.batch/batch.sh       |  4 ++++
 engine/tests/Functional.batch/fuego_test.sh  | 19 +++++++++++++++
 engine/tests/Functional.batch/parser.py      | 22 +++++++++++++++++
 engine/tests/Functional.batch/spec.json      |  6 +++++
 engine/tests/Functional.batch/tests/batch.sh | 35 ++++++++++++++++++++++++++++
 5 files changed, 86 insertions(+)
 create mode 100644 engine/tests/Functional.batch/batch.sh
 create mode 100644 engine/tests/Functional.batch/fuego_test.sh
 create mode 100644 engine/tests/Functional.batch/parser.py
 create mode 100644 engine/tests/Functional.batch/spec.json
 create mode 100644 engine/tests/Functional.batch/tests/batch.sh

diff --git a/engine/tests/Functional.batch/batch.sh b/engine/tests/Functional.batch/batch.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.batch/batch.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.batch/fuego_test.sh b/engine/tests/Functional.batch/fuego_test.sh
new file mode 100644
index 0000000..7a5f1d1
--- /dev/null
+++ b/engine/tests/Functional.batch/fuego_test.sh
@@ -0,0 +1,19 @@
+NEED_ROOT=1
+
+function test_pre_check {
+    assert_has_program batch expect
+}
+
+function test_deploy {
+    put $TEST_HOME/batch.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh -v batch.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "1" "TEST-PASS" "p"
+}
diff --git a/engine/tests/Functional.batch/parser.py b/engine/tests/Functional.batch/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.batch/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/engine/tests/Functional.batch/spec.json b/engine/tests/Functional.batch/spec.json
new file mode 100644
index 0000000..7c3e1f5
--- /dev/null
+++ b/engine/tests/Functional.batch/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.batch",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/engine/tests/Functional.batch/tests/batch.sh b/engine/tests/Functional.batch/tests/batch.sh
new file mode 100644
index 0000000..7addb0d
--- /dev/null
+++ b/engine/tests/Functional.batch/tests/batch.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# In target, run comannd batch and execute "echo" in batch
+# Ensure that batch can work well.
+
+test="batch"
+
+if /tmp/batch_result
+then
+    rm /tmp/batch_result
+fi
+
+expect <<-EOF
+spawn batch
+expect {                
+ -re ".*at.*" { 
+           send_user " -> $test: batch executed.\n" 
+           send "echo batch test done > /tmp/batch_result\n"
+          }
+ default { send_user " -> $test: TEST-FAIL\n" }
+ }  
+send "\004\r"
+send_user " -> $test: batch executed succeeded.\n"
+expect eof
+EOF
+
+sleep 5 
+
+if cat /tmp/batch_result | grep "batch test done"
+then
+    echo ' -> $test: TEST-PASS'
+else
+    echo ' -> $test: TEST-FAIL'
+fi
+
-- 
1.8.3.1





More information about the Fuego mailing list