mailweb.openeuler.org
Manage this list

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Compass-ci

Threads by month
  • ----- 2025 -----
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
compass-ci@openeuler.org

  • 2 participants
  • 5237 discussions
[PATCH v1 compass-ci 2/4] providers/libvirt: customizing logger format
by Xiao Shenwei 21 Jan '21

21 Jan '21
format: datetime-severity: message such as: 2021-01-20 16:04:03 +0800-INFO: xxxxxx Signed-off-by: Xiao Shenwei <xiaoshenwei96(a)163.com> --- providers/libvirt/lib/mylog.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 providers/libvirt/lib/mylog.rb diff --git a/providers/libvirt/lib/mylog.rb b/providers/libvirt/lib/mylog.rb new file mode 100644 index 0000000..69061ca --- /dev/null +++ b/providers/libvirt/lib/mylog.rb @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'logger' + +# define a logger format +class Mylog < Logger + def initialize(filename) + @name = filename + if FileTest.exist?(filename) + File.delete(filename) + end + super(filename) + self.datetime_format = '%Y-%m-%d %H:%M:%s' + self.formatter = proc do |severity, datetime, _, msg| + "#{datetime}-#{severity}: #{msg}\n" + end + end +end -- 2.23.0
3 7
0 0
[PATCH compass-ci] lib/job.cr: use an independent interface for submit
by Wu Zhende 21 Jan '21

21 Jan '21
When we use Job.new, we need to do some extra processing only when we submit the job. Use interface "initialized?" to determine whether to submit a job. However, there is a vulnerability. If a job with all fields initialized is submitted, the job can be successfully submitted without checking the account. Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/lib/job.cr | 29 ++++++++++------------------- src/scheduler/submit_job.cr | 1 + 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/lib/job.cr b/src/lib/job.cr index 9b52d88..964c520 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -55,25 +55,6 @@ class Job @es = Elasticsearch::Client.new @account_info = Hash(String, JSON::Any).new @log = JSONLogger.new - - # init job with "-1", or use the original job_content["id"] - id = "-1" if "#{id}" == "" - - if initialized? - if @hash["id"] == "#{id}" - return unless @hash.has_key?("my_uuid") || @hash.has_key?("my_token") - - check_account_info() - set_sshr_info() - return - end - end - - @hash["id"] = JSON::Any.new("#{id}") - - check_required_keys() - check_account_info() - set_defaults() end METHOD_KEYS = %w( @@ -155,6 +136,16 @@ class Job end end + def submit(id = nil) + # init job with "-1", or use the original job_content["id"] + id = "-1" if "#{id}" == "" + @hash["id"] = JSON::Any.new("#{id}") + + check_required_keys() + check_account_info() + set_defaults() + end + private def set_defaults append_init_field() set_docker_os() diff --git a/src/scheduler/submit_job.cr b/src/scheduler/submit_job.cr index bcb265f..1837cb1 100644 --- a/src/scheduler/submit_job.cr +++ b/src/scheduler/submit_job.cr @@ -7,6 +7,7 @@ class Sched job_content = JSON.parse(body) job = Job.new(job_content, job_content["id"]?) + job.submit(job_content["id"]?) job["commit_date"] = get_commit_date(job) cluster_file = job["cluster"] -- 2.23.0
2 1
0 0
[PATCH v3 lkp-tests] sbin/submit: add -f option for uploading libvirt config
by Ren Wen 21 Jan '21

21 Jan '21
An option for 'submit': -f, --upload-file FILE upload an XML template of libvirt FILE's extension should be '.xml'. Example: case1: submit -f existent_file.xml => existent_file/<md5sum>.xml case2: submit -f nonexistent_file.xml => Find no file: nonexistent_file.xml Signed-off-by: Ren Wen <15991987063(a)163.com> --- lib/job.rb | 11 +++++++++++ sbin/submit | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/lib/job.rb b/lib/job.rb index 631ebfc98..812f8c299 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -16,6 +16,17 @@ require 'set' require 'pp' require 'English' +# copied from compass-ci/container/defconfig.rb +def cci_defaults + hash = {} + Dir.glob(['/etc/compass-ci/defaults/*.yaml', + '/etc/compass-ci/accounts/*.yaml', + "#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file| + hash.update YAML.load_file(file) || {} + end + hash +end + def restore(ah, copy) if ah.class == Hash ah.clear.merge!(copy) diff --git a/sbin/submit b/sbin/submit index 39cdcf576..1d56369ad 100755 --- a/sbin/submit +++ b/sbin/submit @@ -17,6 +17,7 @@ opt_auto_define_files = false opt_monitor = false opt_monitor_query = {} opt_my_queue = false +opt_upload_files = [] actions = ['output', 'stop'] options = OptionParser.new do |opts| @@ -64,10 +65,40 @@ options = OptionParser.new do |opts| opt_my_queue = true end + opts.on('-f FILE', '--upload-file FILE', "upload an XML template of libvirt. File: *.xml") do |file| + unless File.exist? file + puts "Find no file: #{file}" + exit 1 + end + + opt_upload_files << file + end + end options.parse!(ARGV) +def upload_configs(files) + defaults = cci_defaults() + upload_host = defaults['LKP_SERVER'] + upload_port = defaults['UPLOAD_LIBVIRT_PORT'] || 3081 + + files.each do |file| + response = `curl -sSf -T #{file} http://#{upload_host}:#{upload_port}/` + if $? == 0 + puts response + else + # TODO: how to deal with uploaded file when one failing + puts response + exit 1 + end + end + + exit 0 +end + +upload_configs(opt_upload_files) unless opt_upload_files.empty? + seen_job_yaml = false ARGV.delete_if do |arg| if arg.index '=' -- 2.23.0
3 4
0 0
[PATCH v4 lkp-tests] sbin/submit: add option -i for submit
by Wei Jihui 21 Jan '21

21 Jan '21
submit -i is for add other yamls content to job.yaml [usage] case 1: submit -i 1.yaml -i 2.yaml job.yaml var priority: 1.yaml < 2.yaml < job.yaml case 2: submit -i 1.yaml job.yaml -i 2.yaml var priority: 1.yaml < job.yaml < 2.yaml case 3: submit -i 1.yaml job1.yaml -i 2.yaml job2.yaml -i 3.yaml var priority: 1.yaml < job1.yaml < 2.yaml < 3.yaml var priority: 1.yaml < 2.yaml < job2.yaml < 3.yaml Signed-off-by: Wei Jihui <weijihuiall(a)163.com> --- lib/job.rb | 17 +++++++++++++---- sbin/submit | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/lib/job.rb b/lib/job.rb index 631ebfc9..640b25a5 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -215,6 +215,8 @@ class Job attr_accessor :overrides attr_accessor :defaults attr_accessor :cmdline_defaults + attr_accessor :default_yamls + attr_accessor :override_yamls def initialize(job = {}, defaults = {}, overrides = {}, cmdline_defaults={}) @job = job @@ -222,6 +224,8 @@ class Job @overrides = overrides # from command line @cmdline_defaults = cmdline_defaults # from command line @available_programs = {} + @default_yamls = [] + @override_yamls = [] end def source_file_symkey(file) @@ -254,8 +258,11 @@ class Job @overrides.merge!(hash['override']){ |_key, a, _b| a} hash.delete('override') end - hash.merge!(@overrides) - hash.merge!(fault_reproduction) if hash.has_key?("id") + + revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? + revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty? + revise_hash(hash, @overrides, true) unless @overrides.empty? + @jobs.concat(multi_args(hash)) # return [hash] or [h1,h2] end rescue StandardError => e @@ -286,8 +293,10 @@ class Job @jobfile = jobfile end - def fault_reproduction - wait = load_yaml("#{lkp_src}/jobs/fault_reproduction.yaml", {}) + def load_include_yamls(include_yamls) + include_hash = {} + include_hash[comment_to_symbol("#{include_yamls.join(' ')}")] = nil + include_hash.merge!(load_yaml_merge(include_yamls, {})) end def multi_args(hash) diff --git a/sbin/submit b/sbin/submit index 39cdcf57..e8b17648 100755 --- a/sbin/submit +++ b/sbin/submit @@ -14,6 +14,7 @@ opt_set_key_value = {} opt_cmdline_defaults = {} opt_output_dir = nil opt_auto_define_files = false +opt_include_yamls = [] opt_monitor = false opt_monitor_query = {} opt_my_queue = false @@ -43,6 +44,10 @@ options = OptionParser.new do |opts| opt_auto_define_files = true end + opts.on('-i include.yaml', '--include include.yaml', 'include other job yamls') do |yaml| + opt_include_yamls << yaml + end + opts.on('-c', '--connect', 'auto connect to the host') do actions << 'connect' end @@ -66,6 +71,7 @@ options = OptionParser.new do |opts| end +ARGV_CLONE = ARGV.clone options.parse!(ARGV) seen_job_yaml = false @@ -91,6 +97,19 @@ end job_ids = [] job_hash_list = [] +def prioritize_include_yaml(include_yamls, jobfile) + default_yamls, override_yamls = [], [] + jobfile_index = ARGV_CLONE.index(jobfile) + include_yamls.each do |yaml| + if ARGV_CLONE.index(yaml) < jobfile_index + default_yamls << yaml + else + override_yamls << yaml + end + end + return default_yamls, override_yamls +end + def find_jobfile(jobfile) return jobfile if File.exist?(jobfile) @@ -103,14 +122,25 @@ def find_jobfile(jobfile) exit 1 end +def find_jobfiles(jobfile_list) + search_jobfile_list = [] + jobfile_list.each do |jobfile| + search_jobfile_list << find_jobfile(jobfile) + end + return search_jobfile_list +end + submit_id = %x(uuidgen).chomp puts "submit_id=#{submit_id}" ARGV.each do |jobfile| + default_yamls, override_yamls = prioritize_include_yaml(opt_include_yamls, jobfile) jobfile = find_jobfile(jobfile) jobs = Job2sh.new jobs.cmdline_defaults = opt_cmdline_defaults jobs.overrides = opt_set_key_value + jobs.default_yamls = find_jobfiles(default_yamls) + jobs.override_yamls = find_jobfiles(override_yamls) jobs.load(jobfile, true) || next jobs[:expand_params] = true jobs['testbox'] = opt_set_key_value['testbox'] if opt_set_key_value['testbox'] -- 2.23.0
1 0
0 0
[PATCH compass-ci] container/add-software: if cd failed, don't go on exec rm cmd
by Xu Xijian 21 Jan '21

21 Jan '21
Signed-off-by: Xu Xijian <hdxuxijian(a)163.com> --- container/add-software/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/add-software/run b/container/add-software/run index aab659b..8a1d9ea 100755 --- a/container/add-software/run +++ b/container/add-software/run @@ -42,7 +42,7 @@ install_cmds=( addsoftware:auto bash -c " yum install -y --skip-broken --installroot=/mnt/root $packages - cd /mnt/root + cd /mnt/root && rm -rf srv/{*,.*} opt/{*,.*} mnt/{*,.*} media/{*,.*} home/{*,.*} lost+found/{*,.*} dev/{*,.*} proc/{*,.*} run/{*,.*} sys/{*,.*} > /dev/null 2>&1 " ) -- 2.23.0
2 2
0 0
[PATCH compass-ci] delimiter: use check_job_credible API to replace credible? function
by Cao Xueliang 21 Jan '21

21 Jan '21
Signed-off-by: Cao Xueliang <caoxl78320(a)163.com> --- src/delimiter/utils.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/delimiter/utils.rb b/src/delimiter/utils.rb index 2c6549c..41b65de 100644 --- a/src/delimiter/utils.rb +++ b/src/delimiter/utils.rb @@ -78,6 +78,7 @@ module Utils # monitor the job id and job state query job stats when job state is extract_finished # according to the job stats return good/bad/nil def get_job_status(job, error_id) + bad_job_id = job['bad_job_id'] new_job_id = submit_job(job) puts "new job id: #{new_job_id}" return nil unless new_job_id @@ -86,7 +87,9 @@ module Utils extract_finished = monitor_run_stop(query) return nil unless extract_finished.zero? - raise "the job is incredible for bisect: #{new_job_id}" unless credible?(job['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 + raise "the job is incredible for bisect: #{new_job_id}" unless check_result['credible'] stats = query_stats(new_job_id, 10) raise "es cant query #{new_job_id} stats field!" unless stats -- 2.23.0
1 0
0 0
[PATCH v4 lkp-tests 4/5] new reset-tbox job yaml and script
by Zhang Dewan 21 Jan '21

21 Jan '21
Signed-off-by: Zhang Dewan <513619464(a)qq.com> --- jobs/reset-tbox.yaml | 2 +- tests/reset-tbox | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/reset-tbox.yaml b/jobs/reset-tbox.yaml index 216a3852..52ea76b7 100644 --- a/jobs/reset-tbox.yaml +++ b/jobs/reset-tbox.yaml @@ -7,4 +7,4 @@ docker_image: reset-tbox:latest queue: reset-tbox reset-tbox: - host_name: +host_name: diff --git a/tests/reset-tbox b/tests/reset-tbox index 36aa37d5..4d2c191e 100755 --- a/tests/reset-tbox +++ b/tests/reset-tbox @@ -1,5 +1,5 @@ #!/bin/bash -# - host_nameset +# host_name account_file=/etc/lab/.account.info hosts_file=/etc/lab/hosts_file -- 2.23.0
2 2
0 0
[PATCH lkp-tests] lkp-bootstrap.service: fix killmode error
by Wang Chenglong 21 Jan '21

21 Jan '21
[Error] Welcome to openEuler 20.09! /usr/lib/systemd/system/lkp-bootstrap.service:11: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's process lifecycle management for the ser vice. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'. Support for KillMode=none is deprecated and will eventually be removed. [How] config the lkp-bootstrap.service: KillMode=control-group Signed-off-by: Wang Chenglong <18509160991(a)163.com> --- rootfs/addon/usr/lib/systemd/system/lkp-bootstrap.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/addon/usr/lib/systemd/system/lkp-bootstrap.service b/rootfs/addon/usr/lib/systemd/system/lkp-bootstrap.service index 842c4aef8..a9eb5152a 100644 --- a/rootfs/addon/usr/lib/systemd/system/lkp-bootstrap.service +++ b/rootfs/addon/usr/lib/systemd/system/lkp-bootstrap.service @@ -8,7 +8,7 @@ Type=forking Environment=HOME=/root ExecStart=/etc/init.d/lkp-bootstrap IgnoreSIGPIPE=no -KillMode=none +KillMode=control-group TasksMax=infinity [Install] -- 2.23.0
1 0
0 0
[PATCH v2 compass-ci] doc/manual: optimize borrow-machine.zh.md
by Luan Shengde 21 Jan '21

21 Jan '21
Signed-off-by: Luan Shengde <shdluan(a)163.com> --- doc/manual/borrow-machine.zh.md | 304 ++++++++------------------------ 1 file changed, 75 insertions(+), 229 deletions(-) diff --git a/doc/manual/borrow-machine.zh.md b/doc/manual/borrow-machine.zh.md index 916aea7..bf85f97 100644 --- a/doc/manual/borrow-machine.zh.md +++ b/doc/manual/borrow-machine.zh.md @@ -1,243 +1,89 @@ -# 前提条件 - -请确认您已按照 [apply-account.md](https://gitee.com/wu_fengguang/compass-ci/blob/master/doc… -- send apply account email. -- receive email from compass-ci-robot(a)qq.com. -- local environment configuration. - - -# 申请测试机(虚拟机) - -1. 生成本地RSA公私钥对 - - ```shell - hi684@account-vm ~% ssh-keygen -t rsa - Generating public/private rsa key pair. - Enter file in which to save the key (/home/hi684/.ssh/id_rsa): - Created directory '/home/hi684/.ssh'. - Enter passphrase (empty for no passphrase): - Enter same passphrase again: - Your identification has been saved in /home/hi684/.ssh/id_rsa. - Your public key has been saved in /home/hi684/.ssh/id_rsa.pub. - The key fingerprint is: - SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hi684@account-vm - The key's randomart image is: - +---[RSA 2048]----+ - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - +----[SHA256]-----+ - hi684@account-vm ~% ls -hla .ssh - total 16K - drwx------. 2 hi684 hi684 4.0K Nov 26 16:37 . - drwx------. 7 hi684 hi684 4.0K Nov 26 16:37 .. - -rw-------. 1 hi684 hi684 1.8K Nov 26 16:37 id_rsa - -rw-r--r--. 1 hi684 hi684 398 Nov 26 16:37 id_rsa.pub - ``` - -2. 根据需求选择yaml - - 每位用户`/home/${USER}`目录下面都存放了一个 lkp-tests 的文件夹。 - - ```shell - hi684@account-vm ~% cd lkp-tests/jobs - hi684@account-vm ~/lkp-tests/jobs% ls -hl borrow-* - -rw-r--r--. 1 root root 53 Nov 2 14:54 borrow-10d.yaml - -rw-r--r--. 1 root root 64 Nov 2 14:54 borrow-1d.yaml - -rw-r--r--. 1 root root 235 Nov 19 15:27 borrow-1h.yaml - ``` - -3. 提交yaml并连接测试机(虚拟机) - - ```shell - hi684@account-vm ~/lkp-tests/jobs% submit -c -m testbox=vm-2p8g borrow-1h.yaml - submit borrow-1h.yaml, got job_id=z9.170593 - query=>{"job_id":["z9.170593"]} - connect to ws://172.168.131.2:11310/filter - {"job_id":"z9.170593","message":"","job_state":"submit","result_root":"/srv/result/borrow/2020-11-26/vm-2p8g/openeuler-20.03-aarch64/3600/z9.170593"} - {"job_id": "z9.170593", "result_root": "/srv/result/borrow/2020-11-26/vm-2p8g/openeuler-20.03-aarch64/3600/z9.170593", "job_state": "set result root"} - {"job_id": "z9.170593", "job_state": "boot"} - {"job_id": "z9.170593", "job_state": "download"} - {"time":"2020-11-26 14:45:06","mac":"0a-1f-0d-3c-91-5c","ip":"172.18.156.13","job_id":"z9.170593","state":"running","testbox":"vm-2p8g.taishan200-2280-2s64p-256g--a38-12"} - {"job_state":"running","job_id":"z9.170593"} - {"job_id": "z9.170593", "state": "set ssh port", "ssh_port": "51840", "tbox_name": "vm-2p8g.taishan200-2280-2s64p-256g--a38-12"} - Host 172.168.131.2 not found in /home/hi684/.ssh/known_hosts - Warning: Permanently added '[172.168.131.2]:51840' (ECDSA) to the list of known hosts. - Last login: Wed Sep 23 11:10:58 2020 - - - Welcome to 4.19.90-2003.4.0.0036.oe1.aarch64 - - System information as of time: Thu Nov 26 06:44:18 CST 2020 - - System load: 0.83 - Processes: 107 - Memory used: 6.1% - Swap used: 0.0% - Usage On: 89% - IP address: 172.18.156.13 - Users online: 1 - - - - root@vm-2p8g ~# - ``` - - 更多关于`submit命令如何使用`、`testbox都有什么可选项`、`如何borrow指定的操作系统`,请参见文章末尾FAQ。 - -4. 使用完毕退还测试机(虚拟机) - - ```shell - root@vm-2p8g ~# reboot - Connection to 172.168.131.2 closed by remote host. - Connection to 172.168.131.2 closed. - hi684@account-vm ~/lkp-tests/jobs% - ``` - - -# 申请测试机(物理机) - - -1. 生成本地RSA公私钥对 - - ```shell - hi684@account-vm ~% ssh-keygen -t rsa - Generating public/private rsa key pair. - Enter file in which to save the key (/home/hi684/.ssh/id_rsa): - Created directory '/home/hi684/.ssh'. - Enter passphrase (empty for no passphrase): - Enter same passphrase again: - Your identification has been saved in /home/hi684/.ssh/id_rsa. - Your public key has been saved in /home/hi684/.ssh/id_rsa.pub. - The key fingerprint is: - SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hi684@account-vm - The key's randomart image is: - +---[RSA 2048]----+ - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - |xxxxxxxxxxxxxxxxx| - +----[SHA256]-----+ - hi684@account-vm ~% ls -hla .ssh - total 16K - drwx------. 2 hi684 hi684 4.0K Nov 26 16:37 . - drwx------. 7 hi684 hi684 4.0K Nov 26 16:37 .. - -rw-------. 1 hi684 hi684 1.8K Nov 26 16:37 id_rsa - -rw-r--r--. 1 hi684 hi684 398 Nov 26 16:37 id_rsa.pub - ``` - -2. 根据需求选择yaml - - 每位用户`/home/${USER}`目录下面都存放了一个 lkp-tests 的文件夹。 - - ```shell - hi684@account-vm ~% cd lkp-tests/jobs - hi684@account-vm ~/lkp-tests/jobs% ls -hl borrow-* - -rw-r--r--. 1 root root 53 Nov 2 14:54 borrow-10d.yaml - -rw-r--r--. 1 root root 64 Nov 2 14:54 borrow-1d.yaml - -rw-r--r--. 1 root root 235 Nov 19 15:27 borrow-1h.yaml - ``` - -3. 提交yaml并连接测试机(物理机) - - ```shell - hi684@account-vm ~/lkp-tests/jobs% submit -c -m testbox=taishan200-2280-2s64p-256g borrow-1h.yaml - submit borrow-1h.yaml, got job_id=z9.170594 - query=>{"job_id":["z9.170594"]} - connect to ws://172.168.131.2:11310/filter - {"job_id":"z9.170594","message":"","job_state":"submit","result_root":"/srv/result/borrow/2020-11-26/taishan200-2280-2s64p-256g/openeuler-20.03-aarch64/3600/z9.170594"} - {"job_id": "z9.170594", "result_root": "/srv/result/borrow/2020-11-26/taishan200-2280-2s64p-256g/openeuler-20.03-aarch64/3600/z9.170594", "job_state": "set result root"} - {"job_id": "z9.170594", "job_state": "boot"} - {"job_id": "z9.170594", "job_state": "download"} - {"time":"2020-11-26 14:51:56","mac":"84-46-fe-26-d3-47","ip":"172.168.178.48","job_id":"z9.170594","state":"running","testbox":"taishan200-2280-2s64p-256g--a5"} - {"job_state":"running","job_id":"z9.170594"} - {"job_id": "z9.170594", "state": "set ssh port", "ssh_port": "50420", "tbox_name": "taishan200-2280-2s64p-256g--a5"} - Host 172.168.131.2 not found in /home/hi684/.ssh/known_hosts - Warning: Permanently added '[172.168.131.2]:50420' (ECDSA) to the list of known hosts. - Last login: Wed Sep 23 11:10:58 2020 +# 前置准备 +- 申请account +- 配置默认yaml文件 - Welcome to 4.19.90-2003.4.0.0036.oe1.aarch64 +如果未完成以上步骤,请参考[apply-account.md](https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/manual/apply-account.md)完成操作。 - System information as of time: Thu Nov 26 14:51:59 CST 2020 +# 申请测试机 - System load: 1.31 - Processes: 1020 - Memory used: 5.1% - Swap used: 0.0% - Usage On: 3% - IP address: 172.168.178.48 - Users online: 1 - - - - root@taishan200-2280-2s64p-256g--a5 ~# - ``` - - 更多关于`submit命令如何使用`、`testbox都有什么可选项`、`如何borrow指定的操作系统`,请参见文章末尾FAQ。 - -4. 使用完毕退还测试机(物理机) - - ```shell - root@taishan200-2280-2s64p-256g--a5 ~# reboot - Connection to 172.168.131.2 closed by remote host. - Connection to 172.168.131.2 closed. - hi684@account-vm ~/lkp-tests/jobs% - ``` +## 1. 生成本地公/私钥对 + 使用下面命令查看是否已存在公/私钥: + + ''' + ls -a ~/.ssh + ''' + + 如果当前没有现成的公/私钥对,请使用下面命令进行生成: + + ''' + ssh-keygen -r rsa + ''' + +## 2. 选择job yaml + + 在 ~/lkp-tests/jobs 目录下未您提供了众多job yaml模板。 + + 使用以下命令可筛选出借用机器的模板: + + ''' + cd ~/lkp-tests/jobs + ls -a borrow* + ''' + + - 检查并确保您选择的模板中引用的公钥地址和文件名和你本地的公钥一致。 + +## 3. 提交job + + 使用以下命令提交job: + + ''' + submit -c -m testbox=vm-2p8g borrow-1h.yaml + ''' + + - 使用该命令,您可以实时查看job状态,测试机正常运行后将直接登入。 + +## 4. 退还测试机 + + 到期自动归还: + + 借用期限到达后,测试接将自动重启归还。 + + 手动归还: + + 执行‘reboot’命令重启测试机,测试机将立即归还。 + + - 所有测试机在执行‘reboot’命令后都会被归还,归还后不可再次登录使用。 + - 机器归还后,如果您还需要继续使用测试机,请重新提交job申请新的测试机。 # FAQ +## 自定义借用时长 + + 在借用机器的yaml模板中,找到’runtime‘字段,根据需求修改借用时长。 + +## submit命令指导 + + 学习submit命令,您可以使用 以下命令查看submit命令的各项参数及使用方法: + + ''' + submit -h + ''' + + 也可以参考submit命令手册学习submit命令高级用法: + + [submit命令详解](https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/manua… + +## 可选的testbox -* 如何自行修改申请时长 - - ```shell - hi684@account-vm ~/lkp-tests/jobs% cat borrow-1h.yaml - suite: borrow - testcase: borrow - - runtime: 1h - ssh_pub_key: <%= - begin - File.read("#{ENV['HOME']}/.ssh/id_rsa.pub").chomp - rescue - nil - end - %> - sshd: - # sleep at the bottom - sleep: - hi684@account-vm ~/lkp-tests/jobs% grep runtime: borrow-1h.yaml - sleep: 1h - # 使用vim来修改你的runtime字段的值 - hi684@account-vm ~/lkp-tests/jobs% vim borrow-1h.yaml - # 修改完毕后重新submit即可 - hi684@account-vm ~/lkp-tests/jobs% submit -c -m testbox=vm-2p8g borrow-1h.yaml - ``` - -* Submit命令指导 - - 参考文档:[submit命令详解](https://gitee.com/wu_fengguang/compass-ci/blob/master/doc… - -* testbox有什么可选项 - - testbox可选项请参考:https://gitee.com/wu_fengguang/lab-z9/tree/master/hosts + 可选的testbox模板,请参考:https://gitee.com/wu_fengguang/lab-z9/tree/master/hosts >![](./../public_sys-resources/icon-note.gif) **说明:** > - > 虚拟机的testbox : vm-xxx - > 物理机的testbox : taishan200-2280-xxx + > - 容 器: dc-xxx + > - 虚拟机: vm-xxx + > - 物理机: taishan200-2280-xxx @@ -245,6 +91,6 @@ > - 物理机的testbox若选择以`--axx`结尾的,则表示指定到了具体的某一个物理机。若此物理机任务队列中已经有任务在排队,则需要等待队列中前面的任务执行完毕后,才会轮到你提交的borrow任务。 > - 物理机的testbox若不选择以`-axx`结尾的,表示不指定具体的某一个物理机。则此时集群中的空闲物理机会即时被分配执行你的borrow任务。 -* 如何 borrow 指定的操作系统 +## 如何 borrow 指定的操作系统 关于支持的`os`, `os_arch`, `os_version`,参见:[os-os_verison-os_arch.md](https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/job/os-os_verison-os_arch.md) -- 2.23.0
2 2
0 0
[PATCH lkp-tests] iso2rootfs: add step: archive checksum file to every rootfs if needed
by Yu Chuan 21 Jan '21

21 Jan '21
[Why] dailybuild have many version, we only store the checksum file of latest version, it's not enough, and it's not easy to identify every version. [How] So after the rootfs is generated, copy the checksum file corresponding to each rootfs to rootfs:/. Signed-off-by: Yu Chuan <13186087857(a)163.com> --- tests/iso2rootfs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/iso2rootfs b/tests/iso2rootfs index af164bd43077..cb077fa28b0f 100755 --- a/tests/iso2rootfs +++ b/tests/iso2rootfs @@ -576,6 +576,7 @@ update_dailybuild_soft_link() [ -n "${dailybuild_iso_url_file}" ] || return 0 mv "${CHECKSUM_FILE_CACHE}.tmp" "${CHECKSUM_FILE_CACHE}" + cp "${CHECKSUM_FILE_CACHE}" "${ROOTFS_DES_DIR}" local soft_link="${iso_version}-dailybuild" cd "${ROOTFS_LOCAL_PATH}" && -- 2.23.0
1 0
0 0
[PATCH v2 lkp-tests] tests/build-pkg: fix to download *.tar packages failure
by Liu Shaofei 21 Jan '21

21 Jan '21
[why] The server does not support HTTP protocol address download, only use the original HTTPS protocol address download. curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 ==> ERROR: Failure while downloading buddy-2.4.tar.gz Aborting... Signed-off-by: Liu Shaofei <370072077(a)qq.com> --- tests/build-pkg | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/build-pkg b/tests/build-pkg index 31762384d..7c65f26bc 100755 --- a/tests/build-pkg +++ b/tests/build-pkg @@ -127,7 +127,6 @@ replace_source() } } } - url=$(echo "$url" | sed 's|https://|http://|g') echo \'$url\' >> $1 done -- 2.23.0
2 2
0 0
[PATCH v3 lkp-tests] sbin/submit: add parameter option -i for submit
by Wei Jihui 21 Jan '21

21 Jan '21
submit -i is for add other yamls content to job.yaml [usage] case 1: submit -i 1.yaml -i 2.yaml job.yaml var priority: job.yaml > 2.yaml > 1.yaml case 2: submit -i 1.yaml job.yaml -i 2.yaml var priority: 2.yaml > job.yaml > 1.yaml case 3: submit -i 1.yaml job1.yaml -i 2.yaml job2.yaml -i 3.yaml var priority: 3.yaml > job2.yaml > 2.yaml > 1.yaml var priority: 3.yaml > 2.yaml > job1.yaml > 1.yaml Signed-off-by: Wei Jihui <weijihuiall(a)163.com> --- lib/job.rb | 17 +++++++++++++---- sbin/submit | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/lib/job.rb b/lib/job.rb index 631ebfc9..640b25a5 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -215,6 +215,8 @@ class Job attr_accessor :overrides attr_accessor :defaults attr_accessor :cmdline_defaults + attr_accessor :default_yamls + attr_accessor :override_yamls def initialize(job = {}, defaults = {}, overrides = {}, cmdline_defaults={}) @job = job @@ -222,6 +224,8 @@ class Job @overrides = overrides # from command line @cmdline_defaults = cmdline_defaults # from command line @available_programs = {} + @default_yamls = [] + @override_yamls = [] end def source_file_symkey(file) @@ -254,8 +258,11 @@ class Job @overrides.merge!(hash['override']){ |_key, a, _b| a} hash.delete('override') end - hash.merge!(@overrides) - hash.merge!(fault_reproduction) if hash.has_key?("id") + + revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? + revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty? + revise_hash(hash, @overrides, true) unless @overrides.empty? + @jobs.concat(multi_args(hash)) # return [hash] or [h1,h2] end rescue StandardError => e @@ -286,8 +293,10 @@ class Job @jobfile = jobfile end - def fault_reproduction - wait = load_yaml("#{lkp_src}/jobs/fault_reproduction.yaml", {}) + def load_include_yamls(include_yamls) + include_hash = {} + include_hash[comment_to_symbol("#{include_yamls.join(' ')}")] = nil + include_hash.merge!(load_yaml_merge(include_yamls, {})) end def multi_args(hash) diff --git a/sbin/submit b/sbin/submit index 39cdcf57..e8b17648 100755 --- a/sbin/submit +++ b/sbin/submit @@ -14,6 +14,7 @@ opt_set_key_value = {} opt_cmdline_defaults = {} opt_output_dir = nil opt_auto_define_files = false +opt_include_yamls = [] opt_monitor = false opt_monitor_query = {} opt_my_queue = false @@ -43,6 +44,10 @@ options = OptionParser.new do |opts| opt_auto_define_files = true end + opts.on('-i include.yaml', '--include include.yaml', 'include other job yamls') do |yaml| + opt_include_yamls << yaml + end + opts.on('-c', '--connect', 'auto connect to the host') do actions << 'connect' end @@ -66,6 +71,7 @@ options = OptionParser.new do |opts| end +ARGV_CLONE = ARGV.clone options.parse!(ARGV) seen_job_yaml = false @@ -91,6 +97,19 @@ end job_ids = [] job_hash_list = [] +def prioritize_include_yaml(include_yamls, jobfile) + default_yamls, override_yamls = [], [] + jobfile_index = ARGV_CLONE.index(jobfile) + include_yamls.each do |yaml| + if ARGV_CLONE.index(yaml) < jobfile_index + default_yamls << yaml + else + override_yamls << yaml + end + end + return default_yamls, override_yamls +end + def find_jobfile(jobfile) return jobfile if File.exist?(jobfile) @@ -103,14 +122,25 @@ def find_jobfile(jobfile) exit 1 end +def find_jobfiles(jobfile_list) + search_jobfile_list = [] + jobfile_list.each do |jobfile| + search_jobfile_list << find_jobfile(jobfile) + end + return search_jobfile_list +end + submit_id = %x(uuidgen).chomp puts "submit_id=#{submit_id}" ARGV.each do |jobfile| + default_yamls, override_yamls = prioritize_include_yaml(opt_include_yamls, jobfile) jobfile = find_jobfile(jobfile) jobs = Job2sh.new jobs.cmdline_defaults = opt_cmdline_defaults jobs.overrides = opt_set_key_value + jobs.default_yamls = find_jobfiles(default_yamls) + jobs.override_yamls = find_jobfiles(override_yamls) jobs.load(jobfile, true) || next jobs[:expand_params] = true jobs['testbox'] = opt_set_key_value['testbox'] if opt_set_key_value['testbox'] -- 2.23.0
3 2
0 0
[PATCH v12 compass-ci] lib/es_jobs.rb: optimize es-jobs output
by Lu Kaiyi 21 Jan '21

21 Jan '21
[why] Reduce the nesting of results and output yaml [example] es-jobs os=archlinux [output] kvcount.arch=aarch64: 43 kvcount.arch=x86_64: 2 kvcount.category=benchmark: 12 kvcount.category=functional: 33 kvcount.job_state=failed: 20 kvcount.job_state=finished: 25 kvcount.os=archlinux: 45 kvcount.suite=cci-depends: 28 kvcount.suite=cci-makepkg: 5 kvcount.suite=iperf: 3 kvcount.suite=iperf-walk-os-test: 9 kvcount.summary.any_error=1: 24 kvcount.summary.any_stderr=1: 44 kvcount.summary.any_warning=1: 23 kvcount.summary.success=1: 1 kvcount.tbox_group=vm-2p16g--wangyong: 1 kvcount.tbox_group=vm-2p16g--wcl: 1 kvcount.tbox_group=vm-2p16g.wangyong: 34 kvcount.tbox_group=vm-2p8g: 9 ... raw.id.[job_state=failed]: ["crystal.122405","crystal.122406","crystal.122331","crystal.122365","crystal.122404","crystal.122438","crystal.122607","crystal.122370","crystal.122375","crystal.122410","crystal.122900","crystal.122906","crystal.122271","crystal.122451","crystal.122835","crystal.122834","crystal.122232","crystal.122403","crystal.122453","crystal.122886"] ... raw.id.[summary.any_error=1]: ["crystal.122436","crystal.122476","crystal.122803","crystal.122883","crystal.122910","crystal.122438","crystal.122452","crystal.122895","crystal.122446","crystal.122685","crystal.122687","crystal.122833","crystal.122451","crystal.122690","crystal.122719","crystal.122882","crystal.122890","crystal.122453","crystal.122443","crystal.122435","crystal.122432","crystal.122688","crystal.122689","crystal.122886"] ... sum.stats.last_state.test.iperf.exit_code.127: 12 sum.stats.stderr./lkp/lkp/src/lib/env.sh:#:set_perf_path: 12 sum.stats.last_state.is_incomplete_run: 12 sum.stats.kmsg.timestamp:last: 45 sum.stats.last_state.exit_fail: 20 sum.stats.stderr.has_stderr: 44 ... raw.stats.sched_debug.cfs_rq:/.load.stddev: [524288.0,null,null,null,null,null,null,null,null,524288.0,524288.0,null,null,null,null,null,516608.0,null,1048576.0,null,null,null,null,null,null,null,524288.0,null,null,null,null,2104832.0,1572864.0,null,null,2097152.0,null,null,null,null,null,null,null,null,null] ... avg.stats.sched_debug.cfs_rq:/.load.stddev: 1048576.0 avg.stats.softirqs.CPU1.NET_RX: 2.5833333333333335 avg.stats.slabinfo.kmalloc-512.active_objs: 1372.75 ... max.stats.sched_debug.cfs_rq:/.load.stddev: 2104832.0 max.stats.softirqs.CPU1.NET_RX: 6 max.stats.slabinfo.kmalloc-512.active_objs: 1616 ... Signed-off-by: Lu Kaiyi <2392863668(a)qq.com> --- lib/es_jobs.rb | 202 +++++++++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 90 deletions(-) diff --git a/lib/es_jobs.rb b/lib/es_jobs.rb index a90b1ba..6051e22 100644 --- a/lib/es_jobs.rb +++ b/lib/es_jobs.rb @@ -3,137 +3,159 @@ LKP_SRC = ENV['LKP_SRC'] || '/c/lkp-tests' +KEYWORD = %w[suite os arch category job_state tbox_group upstream_repo summary.success + summary.any_fail summary.any_error summary.any_stderr summary.any_warning].freeze + +require 'json' require "#{LKP_SRC}/lib/stats" require_relative './es_query' # deal jobs search from es class ESJobs def initialize(es_query, my_refine = [], fields = [], stats_filter = []) - @es_query = es_query - @es = ESQuery.new(ES_HOST, ES_PORT) + @jobs = query_jobs_from_es(es_query) @refine = my_refine @fields = fields @stats_filter = stats_filter - @stats_filter_result = {} @refine_jobs = [] - @jobs = {} - @stats_level = { - 0 => 'stats.success', - 1 => 'stats.unknown', - 2 => 'stats.warning', - 3 => 'stats.has_error' - } - set_defaults - deal_jobs + set_jobs_summary end - def set_defaults - query_result = @es.multi_field_query(@es_query) - query_result['hits']['hits'].each do |job| - @jobs[job['_id']] = job['_source'] - end - - @stats = { - 'stats.count' => Hash.new(0), - 'stats.sum' => Hash.new(0), - 'stats.avg' => Hash.new(0) - } - @result = {} - @fields.each do |field| - @result[field] = [] - end + def query_jobs_from_es(items) + es = ESQuery.new(ES_HOST, ES_PORT) + result = es.multi_field_query items + jobs = result['hits']['hits'] + jobs.map! { |job| job['_source'] } + return jobs end - def add_result_fields(job, level) - return unless @refine.include?(level) || @refine.include?(-1) - - @refine_jobs << job['id'] - @fields.each do |field| - value = job[field] - if value - value = job['id'] + '.' + value if field == 'job_state' - @result[field] << value + def set_job_summary(stats, job) + summary_result = '' + stats.keys.each do |stat| + if stat.match(/\.warning/i) + job['summary.any_warning'] = 1 + summary_result = 'warning' + end + if stat.match(/stderr\./i) + job['summary.any_stderr'] = 1 + summary_result = 'stderr' + end + if stat.match(/error|\.exit_code/i) + job['summary.any_error'] = 1 + summary_result = 'error' + end + if stat.match(/\.fail$/i) + job['summary.any_fail'] = 1 + summary_result = 'fail' end - - next unless job['stats'] - - @result[field] << job['stats'][field] if job['stats'][field] end - end - - def deal_jobs - stats_count = Hash.new(0) - stats_jobs = {} + return unless summary_result.empty? - @jobs.each do |job_id, job| - level = deal_stats(job) - add_result_fields(job, level) + job['summary.success'] = 1 + end - stat_key = @stats_level[level] - stat_jobs_key = stat_key + '_jobs' + # set jobs summary fields information in place + def set_jobs_summary + @jobs.each do |job| + stats = job['stats'] + next unless stats - stats_count[stat_key] += 1 - stats_jobs[stat_jobs_key] ||= [] - stats_jobs[stat_jobs_key] << job_id + set_job_summary(stats, job) end - - @stats['stats.count'].merge!(stats_count) - @stats['stats.count'].merge!(stats_jobs) end - def deal_stats(job, level = 0) - return 1 unless job['stats'] + def get_all_metrics(jobs) + metrics = [] + jobs.each do |job| + stats = job['stats'] + next unless stats - job['stats'].each do |key, value| - match_stats_filter(key, value, job['id']) - calculate_stat(key, value) - level = get_stat_level(key, level) + metrics.concat(stats.keys) end - return level + metrics.uniq! end - def match_stats_filter(key, value, job_id) - @stats_filter.each do |filter| - next unless key.include?(filter) + def initialize_result_hash(metrics) + result = { + 'kvcount' => {}, + 'raw.id' => {}, + 'sum.stats' => {}, + 'raw.stats' => {}, + 'avg.stats' => {}, + 'max.stats' => {}, + 'min.stats' => {} + } + metrics.each { |metric| result['raw.stats'][metric] = [] } + result + end - key = job_id + '.' + key - @stats_filter_result[key] = value + def set_default_value(result, stats, metrics) + left_metrics = metrics - stats.keys + left_metrics.each { |metric| result['raw.stats'][metric] << nil } - break + stats.each do |key, value| + result['raw.stats'][key] << value end end - def calculate_stat(key, value) - if function_stat?(key) - return unless @fields.include?('stats.sum') + def kvcount(result, job) + KEYWORD.each do |keyword| + next unless job[keyword] - @stats['stats.sum'][key] += value - else - return unless @fields.include?('stats.avg') + result['kvcount']["#{keyword}=#{job[keyword]}"] ||= 0 + result['kvcount']["#{keyword}=#{job[keyword]}"] += 1 + result['raw.id']["[#{keyword}=#{job[keyword]}]"] ||= [] + result['raw.id']["[#{keyword}=#{job[keyword]}]"] << job['id'] + end + end - @stats['stats.avg'][key] = (@stats['stats.avg'][key] + value) / 2 + def stats_count(result) + result['raw.stats'].each do |key, value| + if function_stat?(key) + result['sum.stats'][key] = value.compact.size + else + result['avg.stats'][key] = value.compact.sum / value.compact.size.to_f + result['max.stats'][key] = value.compact.max + result['min.stats'][key] = value.compact.min + end end end - def get_stat_level(stat, level) - return level if level >= 3 - return 3 if stat.match(/error|fail/i) - return 2 if stat.match(/warn/i) + def query_jobs_state(jobs) + metrics = get_all_metrics(jobs) + result = initialize_result_hash(metrics) + jobs.each do |job| + stats = job['stats'] + next unless stats + + set_default_value(result, stats, metrics) + kvcount(result, job) + end - return 0 + stats_count(result) + result end - def output - result = { - 'stats.count' => @stats['stats.count'] - } + def output_yaml(prefix, result) + result.each do |key, value| + if prefix.empty? + prefix_key = "#{key}" + else + prefix_key = "#{prefix}.#{key}" + end - @stats.each do |key, value| - result[key] = value if @fields.include?(key) + if value.is_a? Hash + output_yaml(prefix_key, value) + else + puts "#{prefix_key}: #{value.to_json}" + end end + end - @result['stats_filter_result'] = @stats_filter_result unless @stats_filter.empty? - @result.merge!(result) - puts JSON.pretty_generate(@result) + def output + @result = query_jobs_state(@jobs) + @result['kvcount'] = @result['kvcount'].sort.to_h + @result['raw.id'] = @result['raw.id'].sort.to_h + output_yaml('', @result) end end -- 2.23.0
2 1
0 0
[PATCH v2 compass-ci 1/5] upload-libvirt-xml/build: add upload-libvirt-xml docker image
by cuiyili 21 Jan '21

21 Jan '21
Add upload-libvirt-xml docker image in order to upload libvirt xml file. Signed-off-by: cuiyili <2268260388(a)qq.com> --- container/upload-libvirt-xml/build | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 container/upload-libvirt-xml/build diff --git a/container/upload-libvirt-xml/build b/container/upload-libvirt-xml/build new file mode 100755 index 0000000..0490e15 --- /dev/null +++ b/container/upload-libvirt-xml/build @@ -0,0 +1,7 @@ +#!/bin/bash +# Origin: https://hub.docker.com/r/openresty/openresty +# Copyright (C) 2016-2020 Eric D. Evan Wies +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +docker build -t upload-libvirt-xml . -- 2.23.0
2 2
0 0
[PATCH v1 compass-ci 3/4] providers/libvirt: request scheduler to consume job
by Xiao Shenwei 21 Jan '21

21 Jan '21
provider a public methods: request_job it will register hostname mac queues and request http://#{@sched_host}:#{@sched_port}/boot.libvirt/mac/#{@info['mac']} Signed-off-by: Xiao Shenwei <xiaoshenwei96(a)163.com> --- providers/libvirt/lib/consumer.rb | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 providers/libvirt/lib/consumer.rb diff --git a/providers/libvirt/lib/consumer.rb b/providers/libvirt/lib/consumer.rb new file mode 100644 index 0000000..6cfa448 --- /dev/null +++ b/providers/libvirt/lib/consumer.rb @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'set' +require 'yaml' +require 'json' +require_relative 'base' +require_relative "#{ENV['CCI_SRC']}/container/defconfig" + +# register hostname mac queues +# request scheduler +class Consumer < Base + attr_reader :info + + def initialize(hostname, queues) + @info = {} + @info['hostname'] = hostname + @info['queues'] = queues + end + + def close + del_host_info + end + + def request_job + get_mac_from_hostname(@info['hostname']) + config_scheduler + set_host_info + host_exists + url = "http://#{@sched_host}:#{@sched_port}/boot.libvirt/mac/#{@info['mac']}" + @logger.info("Request URL: #{url}") + res = %x(curl #{url}) + if res.empty? + @logger.error('Can not connect scheduler') + raise 'Can not connect scheduler' + end + JSON.parse(res) + end + + private + + def config_scheduler + names = Set.new %w[ + SCHED_HOST + SCHED_PORT + ] + defaults = relevant_defaults(names) + @sched_host = defaults['SCHED_HOST'] || '172.17.0.1' + @sched_port = defaults['SCHED_PORT'] || 3000 + @logger.info("SCHED_HOST: #{@sched_host}") + @logger.info("SCHED_PORT: #{@sched_port}") + end + + def get_mac_from_hostname(hostname) + cmd = %(echo #{hostname} | md5sum | sed "s/^\\(..\\)\\(..\\)\\(..\\)\\(..\\)\\(..\\).*$/0a-\\1-\\2-\\3-\\4-\\5/") + @info['mac'] = %x(#{cmd}).chomp + @logger.info("Mac address: #{@info['mac']}") + end + + def set_host_info + system "curl -X PUT \ + 'http://#{@sched_host}:#{@sched_port}/set_host_mac?hostname=#{@info['hostname']}&mac=#{@info['mac']}'" + system "curl -X PUT \ + 'http://#{@sched_host}:#{@sched_port}/set_host2queues?host=#{@info['hostname']}&queues=#{@info['queues']}'" + end + + def del_host_info + system "curl -X PUT 'http://#{@sched_host}:#{@sched_port}/del_host_mac?mac=#{@info['mac']}'" + system "curl -X PUT 'http://#{@sched_host}:#{@sched_port}/del_host2queues?host=#{@info['hostname']}'" + end + + def host_exists + @info['host'] = @info['hostname'].split('.')[0] + host_file = "#{ENV['LKP_SRC']}/hosts/#{@info['host']}" + return if FileTest.exists?(host_file) + + @logger.error("The file does't exist: #{host_file}") + raise "The file does't exist: #{host_file}" + end +end -- 2.23.0
2 2
0 0
[PATCH v2 compass-ci 5/5] upload-libvirt-xml/nginx.conf: nginx.conf in upload-libvirt-xml container
by cuiyili 21 Jan '21

21 Jan '21
Signed-off-by: cuiyili <2268260388(a)qq.com> --- container/upload-libvirt-xml/nginx.conf | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 container/upload-libvirt-xml/nginx.conf diff --git a/container/upload-libvirt-xml/nginx.conf b/container/upload-libvirt-xml/nginx.conf new file mode 100644 index 0000000..aef8fb8 --- /dev/null +++ b/container/upload-libvirt-xml/nginx.conf @@ -0,0 +1,43 @@ +# For more information on configuration, see: +# * Official English Documentation: http://nginx.org/en/docs/ + +user lkp; +worker_processes auto; +pid /run/nginx.pid; + +events {} + +http { + server { + listen 3081; + server_name "upload-libvirt-xml"; + server_tokens off; + client_max_body_size 50m; + access_log /tmp/access.log; + error_log /tmp/error.log; + + location / { + allow all; + root /srv/cci/libvirt-xml/; + + autoindex on; + create_full_put_path on; + dav_methods PUT MKCOL; + dav_access user:rw group:rw all:rw; + content_by_lua_block { + ngx.req.read_body() + local filename = string.gsub(ngx.var.request_uri, "/", "") + if string.match(filename, "([^/]+).xml$") then + add_path = string.match(filename, "([^/]+).xml$") + local data = ngx.req.get_body_data() + local file = io.open("/srv/cci/libvirt-xml/"..filename, "w") + file:write(data) + file:close() + file_md5 = io.popen("cd /srv/cci/libvirt-xml/ && file_md5=$(md5sum "..filename.." | awk '{print $1}') && mkdir -p "..add_path.." && mv "..filename.." "..add_path.."/${file_md5}.xml && echo ${file_md5}"):read() + ngx.say(add_path.."/"..tostring(file_md5)..".xml") + end + } + } + + } +} -- 2.23.0
1 0
0 0
[PATCH v2 compass-ci 4/5] upload-libvirt-xml/openresty.sh: start openresty in upload-libvirt-xml docker image
by cuiyili 21 Jan '21

21 Jan '21
Signed-off-by: cuiyili <2268260388(a)qq.com> --- container/upload-libvirt-xml/openresty.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 container/upload-libvirt-xml/openresty.sh diff --git a/container/upload-libvirt-xml/openresty.sh b/container/upload-libvirt-xml/openresty.sh new file mode 100755 index 0000000..6215d91 --- /dev/null +++ b/container/upload-libvirt-xml/openresty.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +umask 002 +/usr/local/openresty/bin/openresty -g 'daemon off;' -- 2.23.0
1 0
0 0
[PATCH v2 compass-ci 3/5] upload-libvirt-xml/start: start upload-libvirt-xml docker container
by cuiyili 21 Jan '21

21 Jan '21
Signed-off-by: cuiyili <2268260388(a)qq.com> --- container/upload-libvirt-xml/start | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 container/upload-libvirt-xml/start diff --git a/container/upload-libvirt-xml/start b/container/upload-libvirt-xml/start new file mode 100755 index 0000000..ddb04e7 --- /dev/null +++ b/container/upload-libvirt-xml/start @@ -0,0 +1,23 @@ +#!/bin/bash +# Refer to: https://hub.docker.com/r/openresty/openresty +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# SPDX-License-Identifier: MulanPSL-2.0+ + +. $CCI_SRC/container/defconfig.sh + +: ${UPLOAD_LIBVIRT_PORT:=3081} + +docker_rm upload-libvirt-xml + +cmd=( + docker run -d + --name upload-libvirt-xml + --restart=always + -p ${UPLOAD_LIBVIRT_PORT}:3081 + -v $PWD/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf + -v /etc/localtime:/etc/localtime:ro + -v /srv/cci/libvirt-xml:/srv/cci/libvirt-xml + upload-libvirt-xml +) + +"${cmd[@]}" -- 2.23.0
1 0
0 0
[PATCH v2 compass-ci 2/5] upload-libvirt-xml/Dockerfile: add upload-libvirt-xml docker image
by cuiyili 21 Jan '21

21 Jan '21
Add upload-libvirt-xml docker image in order to upload libvirt xml file. Signed-off-by: cuiyili <2268260388(a)qq.com> --- container/upload-libvirt-xml/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 container/upload-libvirt-xml/Dockerfile diff --git a/container/upload-libvirt-xml/Dockerfile b/container/upload-libvirt-xml/Dockerfile new file mode 100644 index 0000000..db48bcb --- /dev/null +++ b/container/upload-libvirt-xml/Dockerfile @@ -0,0 +1,14 @@ +# Origin: https://hub.docker.com/r/openresty/openresty +# Copyright (C) 2016-2020 Eric D. Evan Wies +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +FROM openresty/openresty:alpine + +RUN apk add bash +RUN mkdir -p /var/log/nginx/ +RUN adduser lkp -u 1090 -g 1090 -D + +COPY ./openresty.sh /usr/local/bin/ + +CMD ["/usr/local/bin/openresty.sh"] -- 2.23.0
1 0
0 0
[PATCH lkp-tests] submit: upload libvirt config files
by Ren Wen 21 Jan '21

21 Jan '21
An option for 'submit': -f, --upload-file FILE upload an XML template of libvirt File's extension should be '.xml'. Example: case1: submit -f existent_file.xml => existent_file/<md5sum>.xml case2: submit -f nonexistent_file.xml => Find no file: nonexistent_file.xml Signed-off-by: Ren Wen <15991987063(a)163.com> --- lib/job2sh.rb | 10 ++++++++++ sbin/submit | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lib/job2sh.rb b/lib/job2sh.rb index 7f9cf562f..14c4e3f4b 100755 --- a/lib/job2sh.rb +++ b/lib/job2sh.rb @@ -15,6 +15,16 @@ SHELL_BLOCK_KEYWORDS = { 'function' => ['{', '}'] }.freeze +def cci_defaults + hash = {} + Dir.glob(['/etc/compass-ci/defaults/*.yaml', + '/etc/compass-ci/accounts/*.yaml', + "#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file| + hash.update YAML.load_file(file) || {} + end + hash +end + def valid_shell_variable?(key) key =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/ end diff --git a/sbin/submit b/sbin/submit index 39cdcf576..e9e10d903 100755 --- a/sbin/submit +++ b/sbin/submit @@ -17,6 +17,7 @@ opt_auto_define_files = false opt_monitor = false opt_monitor_query = {} opt_my_queue = false +opt_upload_files = [] actions = ['output', 'stop'] options = OptionParser.new do |opts| @@ -64,10 +65,40 @@ options = OptionParser.new do |opts| opt_my_queue = true end + opts.on('-f FILE', '--upload-file FILE', "upload an XML template of libvirt. File: *.xml") do |file| + unless File.exist? file + puts "Find no file: #{file}" + exit 1 + end + + opt_upload_files << file + end + end options.parse!(ARGV) +def upload_configs(files) + defaults = cci_defaults() + upload_host = defaults['LKP_SERVER'] + upload_port = defaults['UPLOAD_LIBVIRT_PORT'] || 3081 + + files.each do |file| + response = `curl -sSf -T #{file} http://#{upload_host}:#{upload_port}/` + if $? == 0 + puts response + else + # TODO: how to deal with uploaded file when one failing + puts response + exit 1 + end + end + + exit 0 +end + +upload_configs(opt_upload_files) + seen_job_yaml = false ARGV.delete_if do |arg| if arg.index '=' -- 2.23.0
2 3
0 0
[PATCH v2 compass-ci] lib/job.cr: add log when check account failed
by Wu Zhende 21 Jan '21

21 Jan '21
[Why] The information about the job that fails the account verification can be traced on kibana. [Log] {"level_num":2,"level":"WARN","time":"2021-01-21T11:28:25.476+0800", "msg":"Invalid account","my_email":"wuzhende666(a)163.com","my_name":"wuzhende","suite":"iperf","testbox":vm-2p8g"} Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/lib/job.cr | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/lib/job.cr b/src/lib/job.cr index 17a0f1b..9b52d88 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -10,6 +10,7 @@ require "scheduler/jobfile_operate.cr" require "scheduler/kernel_params.cr" require "scheduler/pp_params.cr" require "../scheduler/elasticsearch_client" +require "./json_logger" struct JSON::Any def []=(key : String, value : String) @@ -53,6 +54,7 @@ class Job @hash = job_content.as_h @es = Elasticsearch::Client.new @account_info = Hash(String, JSON::Any).new + @log = JSONLogger.new # init job with "-1", or use the original job_content["id"] id = "-1" if "#{id}" == "" @@ -394,17 +396,30 @@ class Job error_msg += "Please refer to https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/manual/apply-acco…" account_info = @es.get_account(self["my_email"]) - raise error_msg unless account_info.is_a?(JSON::Any) + + flag = is_valid_account?(account_info) + @log.warn({"msg" => "Invalid account", + "my_email" => self["my_email"], + "my_name" => self["my_name"], + "suite" => self["suite"], + "testbox" => self["testbox"] + }.to_json) unless flag + raise error_msg unless flag + + @hash.delete("my_uuid") + @hash.delete("my_token") + end + + private def is_valid_account?(account_info) + return false unless account_info.is_a?(JSON::Any) @account_info = account_info.as_h # my_name can be nil in es # my_token can't be nil in es - raise error_msg unless self["my_name"] == @account_info["my_name"]?.to_s - raise error_msg unless self["my_token"] == @account_info["my_token"]? - - @hash.delete("my_uuid") - @hash.delete("my_token") + return false unless self["my_name"] == @account_info["my_name"]?.to_s + return false unless self["my_token"] == @account_info["my_token"]? + return true end private def get_initialized_keys -- 2.23.0
1 0
0 0
[PATCH v2 lkp-tests] sbin/submit: add -f option for uploading libvirt config
by Ren Wen 21 Jan '21

21 Jan '21
An option for 'submit': -f, --upload-file FILE upload an XML template of libvirt FILE's extension should be '.xml'. Example: case1: submit -f existent_file.xml => existent_file/<md5sum>.xml case2: submit -f nonexistent_file.xml => Find no file: nonexistent_file.xml Signed-off-by: Ren Wen <15991987063(a)163.com> --- lib/job.rb | 11 +++++++++++ sbin/submit | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/lib/job.rb b/lib/job.rb index 631ebfc98..812f8c299 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -16,6 +16,17 @@ require 'set' require 'pp' require 'English' +# copied from compass-ci/container/defconfig.rb +def cci_defaults + hash = {} + Dir.glob(['/etc/compass-ci/defaults/*.yaml', + '/etc/compass-ci/accounts/*.yaml', + "#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file| + hash.update YAML.load_file(file) || {} + end + hash +end + def restore(ah, copy) if ah.class == Hash ah.clear.merge!(copy) diff --git a/sbin/submit b/sbin/submit index 39cdcf576..e9e10d903 100755 --- a/sbin/submit +++ b/sbin/submit @@ -17,6 +17,7 @@ opt_auto_define_files = false opt_monitor = false opt_monitor_query = {} opt_my_queue = false +opt_upload_files = [] actions = ['output', 'stop'] options = OptionParser.new do |opts| @@ -64,10 +65,40 @@ options = OptionParser.new do |opts| opt_my_queue = true end + opts.on('-f FILE', '--upload-file FILE', "upload an XML template of libvirt. File: *.xml") do |file| + unless File.exist? file + puts "Find no file: #{file}" + exit 1 + end + + opt_upload_files << file + end + end options.parse!(ARGV) +def upload_configs(files) + defaults = cci_defaults() + upload_host = defaults['LKP_SERVER'] + upload_port = defaults['UPLOAD_LIBVIRT_PORT'] || 3081 + + files.each do |file| + response = `curl -sSf -T #{file} http://#{upload_host}:#{upload_port}/` + if $? == 0 + puts response + else + # TODO: how to deal with uploaded file when one failing + puts response + exit 1 + end + end + + exit 0 +end + +upload_configs(opt_upload_files) + seen_job_yaml = false ARGV.delete_if do |arg| if arg.index '=' -- 2.23.0
1 1
0 0
[PATCH compass-ci] lib/job.cr: add log when check account failed
by Wu Zhende 21 Jan '21

21 Jan '21
[Why] The information about the job that fails the account verification can be traced on kibana. [Log] {"level_num":2,"level":"WARN","time":"2021-01-21T11:08:19.647+0800","msg":"Invalid account","my_email":"wuzhende666(a)163.com","suite":"iperf","testcase":"iperf"} Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/lib/job.cr | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lib/job.cr b/src/lib/job.cr index 17a0f1b..2971a77 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -10,6 +10,7 @@ require "scheduler/jobfile_operate.cr" require "scheduler/kernel_params.cr" require "scheduler/pp_params.cr" require "../scheduler/elasticsearch_client" +require "./json_logger" struct JSON::Any def []=(key : String, value : String) @@ -53,6 +54,7 @@ class Job @hash = job_content.as_h @es = Elasticsearch::Client.new @account_info = Hash(String, JSON::Any).new + @log = JSONLogger.new # init job with "-1", or use the original job_content["id"] id = "-1" if "#{id}" == "" @@ -394,17 +396,29 @@ class Job error_msg += "Please refer to https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/manual/apply-acco…" account_info = @es.get_account(self["my_email"]) - raise error_msg unless account_info.is_a?(JSON::Any) + + flag = is_valid_account?(account_info) + @log.warn({"msg" => "Invalid account", + "my_email" => self["my_email"], + "suite" => self["suite"], + "testcase" => self["testcase"] + }.to_json) unless flag + raise error_msg unless flag + + @hash.delete("my_uuid") + @hash.delete("my_token") + end + + private def is_valid_account?(account_info) + return false unless account_info.is_a?(JSON::Any) @account_info = account_info.as_h # my_name can be nil in es # my_token can't be nil in es - raise error_msg unless self["my_name"] == @account_info["my_name"]?.to_s - raise error_msg unless self["my_token"] == @account_info["my_token"]? - - @hash.delete("my_uuid") - @hash.delete("my_token") + return false unless self["my_name"] == @account_info["my_name"]?.to_s + return false unless self["my_token"] == @account_info["my_token"]? + return true end private def get_initialized_keys -- 2.23.0
1 0
0 0
[PATCH compass-ci] git_mirror.rb: add new_refs_count by year/month/day
by Li Yuanchao 21 Jan '21

21 Jan '21
Add a hash table new_refs_count in fork_stat for every repo, which will record new refs times of this repo by year/month/day. Signed-off-by: Li Yuanchao <lyc163mail(a)163.com> --- lib/git_mirror.rb | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index 4f74751..6d1624f 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -298,6 +298,7 @@ class MirrorMain offset_new_refs = 0 if offset_new_refs >= 10 @fork_stat[git_repo][:new_refs_time][offset_new_refs] = Time.now.to_s @fork_stat[git_repo][:offset_new_refs] = offset_new_refs + 1 + @fork_stat[git_repo][:new_refs_count] = update_new_refs_count(@fork_stat[git_repo][:new_refs_count]) end def update_fork_stat(git_repo, possible_new_refs) @@ -373,15 +374,53 @@ class MirrorMain fetch_time: [], offset_fetch: 0, new_refs_time: [], - offset_new_refs: 0 + offset_new_refs: 0, + new_refs_count: {} } query = { query: { match: { git_repo: git_repo } } } result = @es_client.search(index: 'repo', body: query)['hits'] return fork_stat unless result['total'].positive? fork_stat.each_key do |key| - fork_stat[key] = result['hits'][0]['_source'][key.to_s] + fork_stat[key] = result['hits'][0]['_source'][key.to_s] || fork_stat[key] end return fork_stat end + + def create_year_hash(new_refs_count, year, month, day) + new_refs_count[year] = { 'year_count' => 1, month => { 'month_count' => 1, day => 1 } } + return new_refs_count + end + + def update_year_hash(new_refs_count, year, month, day) + new_refs_count[year]['year_count'] += 1 + return create_month_hash(new_refs_count, year, month, day) if new_refs_count[year][month].nil? + + return update_month_hash(new_refs_count, year, month, day) + end + + def create_month_hash(new_refs_count, year, month, day) + new_refs_count[year][month] = { 'month_count' => 1, day => 1 } + return new_refs_count + end + + def update_month_hash(new_refs_count, year, month, day) + new_refs_count[year][month]['month_count'] += 1 + if new_refs_count[year][month][day].nil? + new_refs_count[year][month][day] = 1 + else + new_refs_count[year][month][day] += 1 + end + return new_refs_count + end + + def update_new_refs_count(new_refs_count) + t = Time.now + year = t.year.to_s + month = t.month.to_s + day = t.day.to_s + return create_year_hash(new_refs_count, year, month, day) if new_refs_count[year].nil? + + return update_year_hash(new_refs_count, year, month, day) + end end -- 2.23.0
1 0
0 0
[PATCH compass-ci] container/assist-result: add check_job_credible function
by Cao Xueliang 21 Jan '21

21 Jan '21
The container assist-result mount "/srv/result" dir, the function credible? need "/srv/result" dir, so it can be implemented in the container. Signed-off-by: Cao Xueliang <caoxl78320(a)163.com> --- container/assist-result/Dockerfile | 2 +- container/assist-result/routes.rb | 12 ++++++++++++ .../assist-result/views/check_job_credible.rb | 9 +++++++++ lib/assist_result_client.rb | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 container/assist-result/views/check_job_credible.rb diff --git a/container/assist-result/Dockerfile b/container/assist-result/Dockerfile index 47ef92f..60a2fbf 100644 --- a/container/assist-result/Dockerfile +++ b/container/assist-result/Dockerfile @@ -12,4 +12,4 @@ RUN sed -ri.origin 's|^https?://dl-cdn.alpinelinux.org|http://mirrors.huaweiclou RUN umask 002 && \ echo ':sources: ["http://rubygems.org"]' >> ~/.gemrc && \ - gem install rest-client activesupport json yaml elasticsearch sinatra puma + gem install rest-client activesupport json yaml elasticsearch sinatra puma terminal-table diff --git a/container/assist-result/routes.rb b/container/assist-result/routes.rb index 1013643..077a427 100755 --- a/container/assist-result/routes.rb +++ b/container/assist-result/routes.rb @@ -7,6 +7,7 @@ require 'json' require 'sinatra' require_relative './views/get_job_yaml' +require_relative './views/check_job_credible' configure do set :bind, '0.0.0.0' @@ -22,3 +23,14 @@ get '/get_job_yaml/:job_id' do return [200, result.to_json] end + +post '/check_job_credible' do + begin + data = JSON.parse(Base64.decode64(request.body.read)) + result = check_job_credible(data['pre_job_id'], data['cur_job_id'], data['error_id']) + rescue StandardError => e + return [400, e.backtrace.inspect] + end + + return [200, {'credible' => result}.to_json] +end diff --git a/container/assist-result/views/check_job_credible.rb b/container/assist-result/views/check_job_credible.rb new file mode 100644 index 0000000..a8d387f --- /dev/null +++ b/container/assist-result/views/check_job_credible.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 check_job_credible(pre_job_id, cur_job_id, error_id) + return credible?(pre_job_id, cur_job_id, error_id) +end diff --git a/lib/assist_result_client.rb b/lib/assist_result_client.rb index 042b189..fcf5d9d 100644 --- a/lib/assist_result_client.rb +++ b/lib/assist_result_client.rb @@ -3,6 +3,8 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. # frozen_string_literal: true +require 'json' +require 'base64' require 'rest-client' require_relative 'constants' @@ -19,4 +21,17 @@ class AssistResult return response.body end + + def check_job_credible(pre_job_id, cur_job_id, error_id) + data = { + 'pre_job_id' => pre_job_id, + 'cur_job_id' => cur_job_id, + 'error_id' => error_id + } + resource = RestClient::Resource.new("http://#{@host}:#{@port}/check_job_credible") + response = resource.post(Base64.encode64(data.to_json)) + return nil unless response.code == 200 + + return JSON.parse(response.body) + end end -- 2.23.0
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • ...
  • 210
  • Older →

HyperKitty Powered by HyperKitty