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 -----
  • 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

January 2021

  • 24 participants
  • 859 discussions
[PATCH v2 compass-ci] lib/compare_matrixes.rb: fix TypeError
by Lu Weitao 25 Jan '21

25 Jan '21
[Why] When use compare as: sbin/compare id=crystal.120202 id=crystal.122057 met error: /home/lwt/work4/compass-ci/lib/compare_matrixes.rb:182:in `[]': no implicit conversion of String into Integer (TypeError) root cause: we call the function: def compare_matrixes(matrixes_list, suite_list, latest_jobs, matrixes_titles = nil, group_key = nil, options: {}) like: compare_matrixes(matrices_list, suite_list, options: options) the "options" will passed as "latest_jobs" [How] set nil as default value to "latest_jobs" like: def compare_matrixes(matrixes_list, suite_list, latest_jobs = nil, matrixes_titles = nil, group_key = nil, options: {}) Signed-off-by: Lu Weitao <luweitaobe(a)163.com> --- lib/compare_matrixes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index fa578f6..12c1f3e 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -179,6 +179,7 @@ def get_matrixes_values(matrixes_list, latest_jobs, options) end def latest_failure?(field, latest_jobs) + return true unless latest_jobs latest_jobs.any? { |job| job['stats'][field] } end @@ -203,7 +204,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end -def compare_matrixes(matrixes_list, suite_list, latest_jobs, matrixes_titles = nil, group_key = nil, options: {}) +def compare_matrixes(matrixes_list, suite_list, latest_jobs=nil, matrixes_titles = nil, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # @matrixes_list: list consisting of matrix # @matrixes_titles: number or dimension of matrix -- 2.23.0
1 0
0 0
[PATCH v3 compass-ci 1/3] scheduler/elasticsearch_client.cr: add a new function for searching
by Wu Zhende 25 Jan '21

25 Jan '21
Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/scheduler/elasticsearch_client.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scheduler/elasticsearch_client.cr b/src/scheduler/elasticsearch_client.cr index c1663c9..e343809 100644 --- a/src/scheduler/elasticsearch_client.cr +++ b/src/scheduler/elasticsearch_client.cr @@ -78,6 +78,10 @@ class Elasticsearch::Client @client.get_source(query) end + def search(index, query) + @client.search({:index => index, :body => query}) + end + def update_account(account_content : JSON::Any, my_email : String) return @client.update( { -- 2.23.0
1 0
0 0
[PATCH compass-ci] lib/compare_matrixes.rb: fix TypeError
by Lu Weitao 25 Jan '21

25 Jan '21
[Why] When use compare as: sbin/compare id=crystal.120202 id=crystal.122057 met error: /home/lwt/work4/compass-ci/lib/compare_matrixes.rb:182:in `[]': no implicit conversion of String into Integer (TypeError) Signed-off-by: Lu Weitao <luweitaobe(a)163.com> --- lib/compare_matrixes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index fa578f6..12c1f3e 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -179,6 +179,7 @@ def get_matrixes_values(matrixes_list, latest_jobs, options) end def latest_failure?(field, latest_jobs) + return true unless latest_jobs latest_jobs.any? { |job| job['stats'][field] } end @@ -203,7 +204,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end -def compare_matrixes(matrixes_list, suite_list, latest_jobs, matrixes_titles = nil, group_key = nil, options: {}) +def compare_matrixes(matrixes_list, suite_list, latest_jobs=nil, matrixes_titles = nil, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # @matrixes_list: list consisting of matrix # @matrixes_titles: number or dimension of matrix -- 2.23.0
2 2
0 0
[PATCH v2 compass-ci 3/3] container/lifecycle: add a new docker service
by Wu Zhende 25 Jan '21

25 Jan '21
Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- container/lifecycle/Dockerfile | 25 ++++++++++++++++++++++ container/lifecycle/build | 18 ++++++++++++++++ container/lifecycle/build-depends | 1 + container/lifecycle/start | 35 +++++++++++++++++++++++++++++++ container/lifecycle/start-depends | 1 + 5 files changed, 80 insertions(+) create mode 100644 container/lifecycle/Dockerfile create mode 100755 container/lifecycle/build create mode 100755 container/lifecycle/build-depends create mode 100755 container/lifecycle/start create mode 100755 container/lifecycle/start-depends diff --git a/container/lifecycle/Dockerfile b/container/lifecycle/Dockerfile new file mode 100644 index 0000000..d89a181 --- /dev/null +++ b/container/lifecycle/Dockerfile @@ -0,0 +1,25 @@ +FROM alpine:3.11 + +RUN sed -ri.origin 's|^https?://dl-cdn.alpinelinux.org|http://mirrors.huaweicloud.com|g' /etc/apk/repositories + +RUN apk update && \ + apk add --no-cache 'ruby-dev' \ + 'g++' 'gcc' 'pcre' 'libevent' 'make' 'git' 'cpio' 'bash' + +RUN umask 002 && \ + echo ':sources: ["http://rubygems.org"]' >> ~/.gemrc && \ + gem install rest-client && \ + gem install activesupport && \ + gem install git && \ + gem install json && \ + gem install yaml + + +ENV LIFECYCLE_RUNTIME_DIR /c/cci/lifecycle + +RUN mkdir -p $LIFECYCLE_RUNTIME_DIR && \ + chown -R 1090:1090 /c + +WORKDIR $LIFECYCLE_RUNTIME_DIR + +COPY --chown=1090:1090 lifecycle . diff --git a/container/lifecycle/build b/container/lifecycle/build new file mode 100755 index 0000000..8c4acca --- /dev/null +++ b/container/lifecycle/build @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'set' +require_relative '../defconfig.rb' + +names = Set.new ['LIFECYCLE_PORT'] +defaults = relevant_defaults(names) + +LIFECYCLE_PORT = (defaults['LIFECYCLE_PORT'] || '11311') + +CCI_SRC = ENV['CCI_SRC'] +system "bash #{CCI_SRC}/container/compile ." +system "docker build -t lifecycle-#{LIFECYCLE_PORT} ." + +system 'rm lifecycle' diff --git a/container/lifecycle/build-depends b/container/lifecycle/build-depends new file mode 100755 index 0000000..5dd403e --- /dev/null +++ b/container/lifecycle/build-depends @@ -0,0 +1 @@ +scheduler-dev diff --git a/container/lifecycle/start b/container/lifecycle/start new file mode 100755 index 0000000..35d4198 --- /dev/null +++ b/container/lifecycle/start @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'set' +require_relative '../defconfig.rb' + +names = Set.new %w[ + LIFECYCLE_PORT +] + +defaults = relevant_defaults(names) +env = docker_env(defaults) + +#DEFAULT_CCI = '/c/cci' +#DEFAULT_LKP = '/c/lkp-tests' +LIFECYCLE_PORT = defaults['LIFECYCLE_PORT'] || '11311' +docker_rm "lifecycle-#{LIFECYCLE_PORT}" + +cmd = %W[ + docker run + --restart=always + --name lifecycle-#{LIFECYCLE_PORT} + -d + -u 1090:1090 + -p #{LIFECYCLE_PORT}:#{LIFECYCLE_PORT} +] + env + %W[ + -v /etc/localtime:/etc/localtime:ro + lifecycle-#{LIFECYCLE_PORT} +] + +cmd += ['sh', '-c', 'umask 002 && ./lifecycle'] + +system(*cmd) diff --git a/container/lifecycle/start-depends b/container/lifecycle/start-depends new file mode 100755 index 0000000..8357fca --- /dev/null +++ b/container/lifecycle/start-depends @@ -0,0 +1 @@ +es -- 2.23.0
1 0
0 0
[PATCH v2 compass-ci 2/3] service/lifecycle: add a new service
by Wu Zhende 25 Jan '21

25 Jan '21
Managing the life cycles of jobs and testboxs. Includes a series of query interfaces and data maintenance interfaces. Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/lib/lifecycle.cr | 39 ++++++++++++++++++++++++++++++++++++++ src/lib/web_env.cr | 9 +++++++++ src/lifecycle.cr | 16 ++++++++++++++++ src/lifecycle/constants.cr | 4 ++++ src/lifecycle/lifecycle.cr | 32 +++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 src/lib/lifecycle.cr create mode 100644 src/lifecycle.cr create mode 100644 src/lifecycle/constants.cr create mode 100644 src/lifecycle/lifecycle.cr diff --git a/src/lib/lifecycle.cr b/src/lib/lifecycle.cr new file mode 100644 index 0000000..a577b3e --- /dev/null +++ b/src/lib/lifecycle.cr @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +require "kemal" +require "yaml" + +require "./web_env" +require "../scheduler/elasticsearch_client" + +class Lifecycle + property es + + def initialize(env : HTTP::Server::Context) + @es = Elasticsearch::Client.new + @env = env + @log = env.log.as(JSONLogger) + end + + def alive(version) + "LKP Alive! The time is #{Time.local}, version = #{version}" + rescue e + @log.warn(e) + end + + def get_running_testbox + size = @env.params.query["size"]? || 20 + from = @env.params.query["from"]? || 0 + query = { + "size" => size, + "from" => from, + "query" => { + "terms" => { + "state" => ["booting", "running"] + } + } + } + @es.search("testbox", query) + end +end diff --git a/src/lib/web_env.cr b/src/lib/web_env.cr index d33b4c0..b3a90a8 100644 --- a/src/lib/web_env.cr +++ b/src/lib/web_env.cr @@ -2,6 +2,7 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. require "./sched" +require "./lifecycle" require "./json_logger" class HTTP::Server @@ -22,5 +23,13 @@ class HTTP::Server def log @log ||= create_log end + + def lifecycle + @lifecycle ||= create_lifecycle + end + + def create_lifecycle + @lifecycle = Lifecycle.new(self) + end end end diff --git a/src/lifecycle.cr b/src/lifecycle.cr new file mode 100644 index 0000000..a864621 --- /dev/null +++ b/src/lifecycle.cr @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +require "lifecycle/lifecycle" +require "./lifecycle/constants.cr" +require "./lib/json_logger" + +module Cycle + log = JSONLogger.new + + begin + Kemal.run(LIFECYCLE_PORT) + rescue e + log.error(e) + end +end diff --git a/src/lifecycle/constants.cr b/src/lifecycle/constants.cr new file mode 100644 index 0000000..a428251 --- /dev/null +++ b/src/lifecycle/constants.cr @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +LIFECYCLE_PORT = (ENV.has_key?("LIFECYCLE_PORT") ? ENV["LIFECYCLE_PORT"] : 11311).to_i32 diff --git a/src/lifecycle/lifecycle.cr b/src/lifecycle/lifecycle.cr new file mode 100644 index 0000000..4154a27 --- /dev/null +++ b/src/lifecycle/lifecycle.cr @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +require "kemal" + +require "../lib/web_env" +require "../lib/lifecycle" +require "../lib/json_logger" + +module Cycle + VERSION = "0.1.0" + + add_context_storage_type(Time::Span) + + before_all do |env| + env.set "start_time", Time.monotonic + env.response.headers["Connection"] = "close" + env.create_log + env.create_lifecycle + end + + # echo alive + get "/" do |env| + env.lifecycle.alive(VERSION) + end + + # find the testbox that are performing jobs + # curl http://localhost:11311/get_running_testbox?size=10&from=0 + get "/get_running_testbox" do |env| + env.lifecycle.get_running_testbox.to_json + end +end -- 2.23.0
1 0
0 0
[PATCH v2 compass-ci 1/3] scheduler/elasticsearch_client.cr: add a new function for searching
by Wu Zhende 25 Jan '21

25 Jan '21
Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/scheduler/elasticsearch_client.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scheduler/elasticsearch_client.cr b/src/scheduler/elasticsearch_client.cr index c1663c9..e343809 100644 --- a/src/scheduler/elasticsearch_client.cr +++ b/src/scheduler/elasticsearch_client.cr @@ -78,6 +78,10 @@ class Elasticsearch::Client @client.get_source(query) end + def search(index, query) + @client.search({:index => index, :body => query}) + end + def update_account(account_content : JSON::Any, my_email : String) return @client.update( { -- 2.23.0
1 0
0 0
[PATCH compass-ci 3/3] container/lifecycle: add a new docker service
by Wu Zhende 25 Jan '21

25 Jan '21
Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- container/lifecycle/Dockerfile | 26 ++++++++++++++++++++++ container/lifecycle/build | 18 ++++++++++++++++ container/lifecycle/build-depends | 1 + container/lifecycle/start | 36 +++++++++++++++++++++++++++++++ container/lifecycle/start-depends | 1 + 5 files changed, 82 insertions(+) create mode 100644 container/lifecycle/Dockerfile create mode 100755 container/lifecycle/build create mode 100755 container/lifecycle/build-depends create mode 100755 container/lifecycle/start create mode 100755 container/lifecycle/start-depends diff --git a/container/lifecycle/Dockerfile b/container/lifecycle/Dockerfile new file mode 100644 index 0000000..ed5f6ee --- /dev/null +++ b/container/lifecycle/Dockerfile @@ -0,0 +1,26 @@ +FROM alpine:3.11 + +RUN sed -ri.origin 's|^https?://dl-cdn.alpinelinux.org|http://mirrors.huaweicloud.com|g' /etc/apk/repositories + +RUN apk update + +RUN apk add --no-cache 'ruby-dev' \ + 'g++' 'gcc' 'pcre' 'libevent' 'make' 'git' 'cpio' 'bash' + +RUN umask 002 && \ + echo ':sources: ["http://rubygems.org"]' >> ~/.gemrc && \ + gem install rest-client && \ + gem install activesupport && \ + gem install git && \ + gem install json && \ + gem install yaml + + +ENV LIFECYCLE_RUNTIME_DIR /c/cci/lifecycle + +RUN mkdir -p $LIFECYCLE_RUNTIME_DIR && \ + chown -R 1090:1090 /c + +WORKDIR $LIFECYCLE_RUNTIME_DIR + +COPY --chown=1090:1090 lifecycle . diff --git a/container/lifecycle/build b/container/lifecycle/build new file mode 100755 index 0000000..8c4acca --- /dev/null +++ b/container/lifecycle/build @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'set' +require_relative '../defconfig.rb' + +names = Set.new ['LIFECYCLE_PORT'] +defaults = relevant_defaults(names) + +LIFECYCLE_PORT = (defaults['LIFECYCLE_PORT'] || '11311') + +CCI_SRC = ENV['CCI_SRC'] +system "bash #{CCI_SRC}/container/compile ." +system "docker build -t lifecycle-#{LIFECYCLE_PORT} ." + +system 'rm lifecycle' diff --git a/container/lifecycle/build-depends b/container/lifecycle/build-depends new file mode 100755 index 0000000..5dd403e --- /dev/null +++ b/container/lifecycle/build-depends @@ -0,0 +1 @@ +scheduler-dev diff --git a/container/lifecycle/start b/container/lifecycle/start new file mode 100755 index 0000000..5862403 --- /dev/null +++ b/container/lifecycle/start @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'set' +require_relative '../defconfig.rb' + +names = Set.new %w[ + LIFECYCLE_PORT +] + +defaults = relevant_defaults(names) +env = docker_env(defaults) + +DEFAULT_CCI = '/c/cci' +DEFAULT_LKP = '/c/lkp-tests' +LIFECYCLE_PORT = defaults['LIFECYCLE_PORT'] || '11311' +docker_rm "lifecycle-#{LIFECYCLE_PORT}" + +cmd = %W[ + docker run + --restart=always + --name lifecycle-#{LIFECYCLE_PORT} + -d + -u 1090:1090 + -p #{LIFECYCLE_PORT}:#{LIFECYCLE_PORT} +] + env + %W[ + -e CCI_SRC=#{DEFAULT_LKP} + -v /etc/localtime:/etc/localtime:ro + lifecycle-#{LIFECYCLE_PORT} +] + +cmd += ['sh', '-c', 'umask 002 && ./lifecycle'] + +system(*cmd) diff --git a/container/lifecycle/start-depends b/container/lifecycle/start-depends new file mode 100755 index 0000000..8357fca --- /dev/null +++ b/container/lifecycle/start-depends @@ -0,0 +1 @@ +es -- 2.23.0
3 2
0 0
[PATCH v2 lab-z9] add hosts-file of taishan200-2280-2s64p-256g--a5 which include NVMe SSD
by Zhang Dewan 25 Jan '21

25 Jan '21
Signed-off-by: Zhang Dewan <513619464(a)qq.com> --- hosts/taishan200-2280-2s64p-256g--a5 | 25 +++++++++++++++++++++++++ hosts/taishan200-2280-2s64p-256g--a6 | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 hosts/taishan200-2280-2s64p-256g--a5 create mode 100644 hosts/taishan200-2280-2s64p-256g--a6 diff --git a/hosts/taishan200-2280-2s64p-256g--a5 b/hosts/taishan200-2280-2s64p-256g--a5 new file mode 100644 index 0000000..e6c11b3 --- /dev/null +++ b/hosts/taishan200-2280-2s64p-256g--a5 @@ -0,0 +1,25 @@ +memory: 256G +nr_hdd_partitions: 1 +nr_ssd_partitions: 1 +hdd_partitions: + - /dev/disk/by-id/scsi-350000399981306c5 +ssd_partitions: + - /dev/disk/by-id/nvme-HWE36P43012M000N_032BEJ10GC000328 +mac_addr: + - 84:46:fe:26:d3:47 + - 84:46:fe:26:d3:48 + - 84:46:fe:26:d3:49 + - 84:46:fe:26:d3:4a + - ac:b3:b5:1e:b4:ab + - ac:b3:b5:1e:b4:ac + - ac:b3:b5:1e:b4:ad + - ac:b3:b5:1e:b4:ae + - ac:b3:b5:1e:ba:9b + - ac:b3:b5:1e:ba:9c + - ac:b3:b5:1e:ba:9d + - ac:b3:b5:1e:ba:9e +arch: aarch64 +nr_node: 4 +nr_cpu: 128 +model_name: Kunpeng-920 +ipmi_ip: 9.3.1.5 diff --git a/hosts/taishan200-2280-2s64p-256g--a6 b/hosts/taishan200-2280-2s64p-256g--a6 new file mode 100644 index 0000000..0944193 --- /dev/null +++ b/hosts/taishan200-2280-2s64p-256g--a6 @@ -0,0 +1,25 @@ +memory: 256G +nr_hdd_partitions: 1 +nr_ssd_partitions: 1 +hdd_partitions: + - /dev/disk/by-id/scsi-350000399981344d9 +ssd_partitions: + - /dev/disk/by-id/nvme-HWE36P43012M000N_032BEJ10GC000301 +mac_addr: + - 84:46:fe:89:ba:56 + - 84:46:fe:89:ba:57 + - 84:46:fe:89:ba:58 + - 84:46:fe:89:ba:59 + - ac:b3:b5:1e:b5:8b + - ac:b3:b5:1e:b5:8c + - ac:b3:b5:1e:b5:8d + - ac:b3:b5:1e:b5:8e + - ac:b3:b5:1e:b6:eb + - ac:b3:b5:1e:b6:ec + - ac:b3:b5:1e:b6:ed + - ac:b3:b5:1e:b6:ee +arch: aarch64 +nr_node: 4 +nr_cpu: 128 +model_name: Kunpeng-920 +ipmi_ip: 9.3.1.6 -- 2.23.0
1 0
0 0
[PATCH compass-ci 2/3] service/lifecycle: add a new service
by Wu Zhende 25 Jan '21

25 Jan '21
Managing the life cycles of jobs and testboxs. Includes a series of query interfaces and data maintenance interfaces. Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/lib/lifecycle.cr | 39 ++++++++++++++++++++++++++++++++++++++ src/lib/web_env.cr | 9 +++++++++ src/lifecycle.cr | 16 ++++++++++++++++ src/lifecycle/constants.cr | 4 ++++ src/lifecycle/lifecycle.cr | 32 +++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 src/lib/lifecycle.cr create mode 100644 src/lifecycle.cr create mode 100644 src/lifecycle/constants.cr create mode 100644 src/lifecycle/lifecycle.cr diff --git a/src/lib/lifecycle.cr b/src/lib/lifecycle.cr new file mode 100644 index 0000000..d4d6ca1 --- /dev/null +++ b/src/lib/lifecycle.cr @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +require "kemal" +require "yaml" + +require "./web_env" +require "../scheduler/elasticsearch_client" + +class Lifecycle + property es + + def initialize(env : HTTP::Server::Context) + @es = Elasticsearch::Client.new + @env = env + @log = env.log.as(JSONLogger) + end + + def alive(version) + "LKP Alive! The time is #{Time.local}, version = #{version}" + rescue e + @log.warn(e) + end + + def performing_testbox + size = @env.params.query["size"]? || 20 + from = @env.params.query["from"]? || 0 + query = { + "size" => size, + "from" => from, + "query" => { + "terms" => { + "state" => ["booting", "running"] + } + } + } + @es.search("testbox", query) + end +end diff --git a/src/lib/web_env.cr b/src/lib/web_env.cr index d33b4c0..b3a90a8 100644 --- a/src/lib/web_env.cr +++ b/src/lib/web_env.cr @@ -2,6 +2,7 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. require "./sched" +require "./lifecycle" require "./json_logger" class HTTP::Server @@ -22,5 +23,13 @@ class HTTP::Server def log @log ||= create_log end + + def lifecycle + @lifecycle ||= create_lifecycle + end + + def create_lifecycle + @lifecycle = Lifecycle.new(self) + end end end diff --git a/src/lifecycle.cr b/src/lifecycle.cr new file mode 100644 index 0000000..a864621 --- /dev/null +++ b/src/lifecycle.cr @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +require "lifecycle/lifecycle" +require "./lifecycle/constants.cr" +require "./lib/json_logger" + +module Cycle + log = JSONLogger.new + + begin + Kemal.run(LIFECYCLE_PORT) + rescue e + log.error(e) + end +end diff --git a/src/lifecycle/constants.cr b/src/lifecycle/constants.cr new file mode 100644 index 0000000..a428251 --- /dev/null +++ b/src/lifecycle/constants.cr @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +LIFECYCLE_PORT = (ENV.has_key?("LIFECYCLE_PORT") ? ENV["LIFECYCLE_PORT"] : 11311).to_i32 diff --git a/src/lifecycle/lifecycle.cr b/src/lifecycle/lifecycle.cr new file mode 100644 index 0000000..9a191ab --- /dev/null +++ b/src/lifecycle/lifecycle.cr @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +require "kemal" + +require "../lib/web_env" +require "../lib/lifecycle" +require "../lib/json_logger" + +module Cycle + VERSION = "0.1.0" + + add_context_storage_type(Time::Span) + + before_all do |env| + env.set "start_time", Time.monotonic + env.response.headers["Connection"] = "close" + env.create_log + env.create_lifecycle + end + + # echo alive + get "/" do |env| + env.lifecycle.alive(VERSION) + end + + # find testboxs that are perforing tasks + # curl http://localhost:11311/performing_testbox?size=10&from=0 + get "/performing_testbox" do |env| + env.lifecycle.performing_testbox.to_json + end +end -- 2.23.0
2 1
0 0
[PATCH compass-ci 1/3] scheduler/elasticsearch_client.cr: add a new function for searching
by Wu Zhende 25 Jan '21

25 Jan '21
Signed-off-by: Wu Zhende <wuzhende666(a)163.com> --- src/scheduler/elasticsearch_client.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scheduler/elasticsearch_client.cr b/src/scheduler/elasticsearch_client.cr index c1663c9..e343809 100644 --- a/src/scheduler/elasticsearch_client.cr +++ b/src/scheduler/elasticsearch_client.cr @@ -78,6 +78,10 @@ class Elasticsearch::Client @client.get_source(query) end + def search(index, query) + @client.search({:index => index, :body => query}) + end + def update_account(account_content : JSON::Any, my_email : String) return @client.update( { -- 2.23.0
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • ...
  • 86
  • Older →

HyperKitty Powered by HyperKitty