On Fri, Nov 27, 2020 at 02:39:50PM +0800, Liu Yinsi wrote:
1.monitor job, start time => job_state is 'boot', end time => job_state is 'extract_finished'; 2.query es by field 'job_state' and 'result_root'.
Signed-off-by: Liu Yinsi liuyinsi@163.com
.../maintain/walk-os-test/walk-os-iperf-test | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+)
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 536dc9f..d9d6bd6 100755 --- a/user-client/maintain/walk-os-test/walk-os-iperf-test +++ b/user-client/maintain/walk-os-test/walk-os-iperf-test @@ -34,6 +34,44 @@ OS_MOUNT = %w[cifs initramfs].freeze
EMAIL_ADDRESS = (ENV['USER']).to_s.freeze
+def monitor(query, actions, timeout)
- monitor = Monitor.new
- monitor.overrides = query
- monitor.action = actions
- monitor.run(timeout)
- monitor
+end
+def monitor_state(job_id)
- time_list = []
- job_states = %w[boot extract_finished]
- job_states.each do |state|
- result_dict = monitor({ 'job_id' => job_id, 'job_state' => state }, { 'stop' => true }, '1800').result
- time_list.push(Time.parse(result_dict[0]['time'])) unless result_dict.nil?
- end
- return time_list
"return time_list" => "time_list" the function monitor() return "monitor" without "return" so we'd better keep the same style
+end
+def es_search(job_id)
- es_list = []
- query_field = %w[job_state result_root]
- query_field.each do |field|
- es = ESQuery.new
- result_dict = es.query_by_id(job_id)
- es_list.push(result_dict[field]) unless result_dict.nil?
- end
- return es_list
ditto
Thanks, Weitao
+end
+def find_by_id(job_id)
- start_time, end_time = monitor_state(job_id)
- cost_time = end_time - start_time unless end_time.nil?
- job_state, result_root = es_search(job_id)
- return start_time, end_time, cost_time.to_i.floor, job_state, result_root
+end
def run_qemu Process.fork do %x(#{ENV['CCI_SRC']}/providers/my-qemu.sh >/dev/null 2>&1) -- 2.23.0