add get_compare_result and get_error_messages inassist-result,
use them in delimiter utils.
Signed-off-by: Cao Xueliang <caoxl78320(a)163.com>
---
container/assist-result/routes.rb | 23 +++++++++++++++++++
.../assist-result/views/get_compare_result.rb | 10 ++++++++
.../assist-result/views/get_error_messages.rb | 9 ++++++++
lib/assist_result_client.rb | 20 ++++++++++++++++
src/delimiter/utils.rb | 15 ++++++++----
5 files changed, 72 insertions(+), 5 deletions(-)
create mode 100644 container/assist-result/views/get_compare_result.rb
create mode 100644 container/assist-result/views/get_error_messages.rb
diff --git a/container/assist-result/routes.rb b/container/assist-result/routes.rb
index 287db25..c0712a9 100755
--- a/container/assist-result/routes.rb
+++ b/container/assist-result/routes.rb
@@ -9,6 +9,8 @@ require 'sinatra'
require_relative './views/get_job_yaml'
require_relative './views/get_job_content'
require_relative './views/check_job_credible'
+require_relative './views/get_compare_result'
+require_relative './views/get_error_messages'
configure do
set :bind, '0.0.0.0'
@@ -45,3 +47,24 @@ get '/get_job_content/:job_id' do
return [200, result.to_json]
end
+
+get '/get_compare_errors/*,*' do |pre_id, cur_id|
+ begin
+ result = get_compare_errors(pre_id, cur_id)
+ rescue StandardError => e
+ return [400, e.backtrace.inspect]
+ end
+
+ return [200, result.to_json]
+end
+
+post '/get_error_messages' do
+ begin
+ data = JSON.parse(Base64.decode64(request.body.read))
+ result = get_error_messages(data['job_id'], data['error_id'])
+ rescue StandardError => e
+ return [400, e.backtrace.inspect]
+ end
+
+ return [200, result.to_json]
+end
diff --git a/container/assist-result/views/get_compare_result.rb b/container/assist-result/views/get_compare_result.rb
new file mode 100644
index 0000000..cf9e1de
--- /dev/null
+++ b/container/assist-result/views/get_compare_result.rb
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: MulanPSL-2.0+
+# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# frozen_string_literal: true
+
+require_relative "#{ENV['CCI_SRC']}/lib/compare_error_messages"
+
+def get_compare_errors(pre_id, cur_id)
+ _, errors = CEM.get_compare_result(pre_id, cur_id)
+ return errors
+end
diff --git a/container/assist-result/views/get_error_messages.rb b/container/assist-result/views/get_error_messages.rb
new file mode 100644
index 0000000..e429dfe
--- /dev/null
+++ b/container/assist-result/views/get_error_messages.rb
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: MulanPSL-2.0+
+# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# frozen_string_literal: true
+
+require_relative "#{ENV['CCI_SRC']}/lib/compare_error_messages"
+
+def get_error_messages(job_id, error_id)
+ return CEM.get_error_messages(job_id, error_id)
+end
diff --git a/lib/assist_result_client.rb b/lib/assist_result_client.rb
index 9c42b97..592c841 100644
--- a/lib/assist_result_client.rb
+++ b/lib/assist_result_client.rb
@@ -42,4 +42,24 @@ class AssistResult
return response.body
end
+
+ def get_compare_errors(pre_id, cur_id)
+ resource = RestClient::Resource.new("http://#{@host}:#{@port}/get_compare_errors/#{pre_id},#{cur_id}")
+ response = resource.get()
+ return nil unless response.code == 200
+
+ return response.body
+ end
+
+ def get_error_messages(job_id, error_id)
+ data = {
+ 'job_id' => job_id,
+ 'error_id' => error_id
+ }
+ resource = RestClient::Resource.new("http://#{@host}:#{@port}/get_error_messages")
+ response = resource.post(Base64.encode64(data.to_json))
+ return nil unless response.code == 200
+
+ return response.body
+ end
end
diff --git a/src/delimiter/utils.rb b/src/delimiter/utils.rb
index f960c7e..c782ea2 100644
--- a/src/delimiter/utils.rb
+++ b/src/delimiter/utils.rb
@@ -67,7 +67,7 @@ module Utils
def submit_job(job)
save_job_to_yaml(job, PROCESS_JOB_YAML)
- response = %x(#{LKP_SRC}/sbin/submit #{PROCESS_JOB_YAML})
+ response = %x(#{ENV['LKP_SRC']}/sbin/submit #{PROCESS_JOB_YAML})
puts "submit job response: #{response}"
return nil if response =~ /job id=0/
return $1 if response =~ /job id=(.*)/
@@ -87,6 +87,7 @@ module Utils
query = { 'job_id': new_job_id, 'job_state': 'extract_finished' }
extract_finished = monitor_run_stop(query)
return nil unless extract_finished.zero?
+ puts "#{bad_job_id}, #{new_job_id}, #{error_id}"
check_result = AssistResult.new.check_job_credible(bad_job_id, new_job_id, error_id)
raise "check job credible failed: #{bad_job_id}, #{new_job_id}, #{error_id}" if check_result == nil
@@ -185,13 +186,17 @@ module Utils
def obt_errors_by_commits(cur_commit, pre_commit)
cur_id = obt_id_by_commit(cur_commit)
pre_id = obt_id_by_commit(pre_commit)
- _, errors = get_compare_result(pre_id, cur_id)
- return errors
+ return AssistResult.new.get_compare_errors(pre_id, cur_id)
end
def obt_result_root_by_commit(commit)
- id = obt_id_by_commit(commit)
- ESQuery.new.query_by_id(id)['result_root']
+ job_id = obt_id_by_commit(commit)
+ job_content = AssistResult.new.get_job_content(job_id)
+ return JSON.parse(job_content)['result_root']
+ end
+
+ def get_bisect_error(job_id, error_id)
+ return AssistResult.new.get_error_messages(job_id, error_id)
end
end
end
--
2.23.0