1. no needed my-qemu.sh after submit job in z9 tbox, remove.
2. monitor job_state boot/extract_finished to get job runtime.
Signed-off-by: Liu Yinsi <liuyinsi(a)163.com>
---
.../maintain/walk-os-test/walk-os-iperf-test | 124 +++++++++---------
1 file changed, 65 insertions(+), 59 deletions(-)
diff --git a/user-client/maintain/walk-os-test/walk-os-iperf-test b/user-client/maintain/walk-os-test/walk-os-iperf-test
index 21e1428..2c3fc9f 100755
--- a/user-client/maintain/walk-os-test/walk-os-iperf-test
+++ b/user-client/maintain/walk-os-test/walk-os-iperf-test
@@ -1,62 +1,68 @@
-#!/bin/bash -e
+#!/usr/bin/env ruby
# SPDX-License-Identifier: MulanPSL-2.0+
+# # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# frozen_string_literal: true
-# os test rounds
-test_times=1
-
-test_logs=walk-test.report
-test_yaml=iperf-walk-os.yaml
-test_os=(
- 'openeuler aarch64 20'
- 'openeuler aarch64 20.03'
- 'centos aarch64 7.6'
- 'centos aarch64 7.8'
- 'centos aarch64 8.1.1911'
+require "#{ENV['LKP_SRC']}/lib/monitor"
+
+TEST_OS = [
+ 'openeuler aarch64 20.03',
+ 'centos aarch64 7.6.1810',
+ 'centos aarch64 7.8.2003',
+ 'centos aarch64 8.1.1911',
'debian aarch64 sid'
-)
-
-trap 'echo User Cancelled! && exit' SIGINT
-
-sec2date() {
- date -d@$1 +"%Y%m%d_%H:%M:%S"
-}
-
-logging() {
- if [ 'new' == "$1" ] ; then
- printf "%-5s %-8s %-25s %-20s %-20s %-8s %-10s\n" ${@:2} > $test_logs
- else
- printf "%-5s %-8s %-25s %-20s %-20s %-8s %-10s\n" $@ >> $test_logs
- fi
-}
-
-create_test_yaml() {
- local hwarch os os_arch os_ver cur_os
- hwarch=$(arch)
- cur_os="$@"
- os=$(echo $cur_os |cut -d' ' -f1)
- os_arch=$(echo $cur_os |cut -d' ' -f2)
- os_ver=$(echo $cur_os |cut -d' ' -f3)
- sed "s/USER/$USER/" $test_yaml > test.yaml
- sed -i "s/OS_ARCH/$os_arch/" test.yaml
- sed -i "s/OS_VER/$os_ver/" test.yaml
- sed -i "s/OS/$os/" test.yaml
- echo "$hwarch $os/$os_arch/$os_ver"
-}
-
-job_test() {
- local job_id bef aft
- job_id=$(submit test.yaml |awk '{print $NF}')
- bef=$(date +%s)
- ./my-qemu.sh
- aft=$(date +%s)
- logging "$1" "$2" "$3" "$(sec2date $bef)" "$(sec2date $aft)" "$((aft - bef))" "$job_id"
-}
-
-logging new "Index" "hwArch" "OS" "Begin" "End" "Cost/sec" "Job_ID"
-for round in $(seq $test_times)
-do
- for idx in "${!test_os[@]}"
- do
- job_test $round $(create_test_yaml "${test_os[$idx]}")
- done
-done
+]
+
+MOUNT_TYPE = ['cifs', 'initramfs']
+
+def logging(job_id, os_params, start_time, end_time, cost_time)
+ line = format("%-12s %-36s %-28s %-28s %-8s\n", job_id, os_params, start_time, end_time, cost_time)
+ f = File.new('walk-test.report', 'a')
+ f.write(line)
+ f.close
+end
+
+def monitor_job(job_id, job_state)
+ res = monitor({'job_id' => job_id, 'job_state' => job_state}, {'stop' => true}, '600s')
+ if res == 0
+ Time.now
+ end
+end
+
+def monitor(query, actions, timeout)
+ monitor = Monitor.new
+ monitor.overrides = query
+ monitor.action = actions
+ monitor.run(timeout)
+end
+
+def submit_job(os_array)
+ os = os_array[0]
+ os_arch = os_array[1]
+ os_version = os_array[2]
+ os_mount = os_array[3]
+ message = %x(submit -s 'os: #{os}' -s 'os_arch: #{os_arch}' -s 'os_version: #{os_version}' -s 'os_mount: #{os_mount}' iperf-walk-os.yaml)
+ puts message
+
+ job_id = message.split('=')[1].chomp
+ os_params = os_array.join('/')
+ start_time = monitor_job(job_id, 'boot')
+ end_time = monitor_job(job_id, 'extract_finished')
+ cost_time = (end_time - start_time).floor
+
+ logging(job_id, os_params, start_time, end_time, cost_time)
+end
+
+def get_os_array(os_mount)
+ TEST_OS.each do | item |
+ os_array = item.split.push(os_mount)
+
+ submit_job(os_array)
+ end
+end
+
+system "walk-test.report"
+
+logging("Job_ID", "OS", "Begin", "End", "Cost/sec")
+
+MOUNT_TYPE.each {| os_mount | get_os_array(os_mount)}
--
2.23.0