2 # Copyright (C) 2019 - Jonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 from jinja2
import Environment
, FileSystemLoader
25 USERNAME
= "lava-jenkins"
26 HOSTNAME
= "lava-master-02.internal.efficios.com"
27 DEFAULT_KERNEL_COMMIT
= "1a1a512b983108015ced1e7a7c7775cfeec42d8c"
30 def wait_on(server
, jobid
):
32 Wait for the completion of the job.
33 Do not care for result. This is mostly to prevent flooding of lava with
34 multiple jobs for the same commit hash. Jenkins is responsible for
35 running only one job for job submissions.
37 # Check the status of the job every 30 seconds
38 jobstatus
= server
.scheduler
.job_state(jobid
)["job_state"]
40 while jobstatus
in ["Submitted", "Scheduling", "Scheduled", "Running"]:
41 if not running
and jobstatus
== "Running":
42 print("Job started running", flush
=True)
46 jobstatus
= server
.scheduler
.job_state(jobid
)["job_state"]
47 except xmlrpc
.client
.ProtocolError
:
48 print("Protocol error, retrying", flush
=True)
50 print("Job ended with {} status.".format(jobstatus
), flush
=True)
54 commit
, debug
=False, kernel_commit
=DEFAULT_KERNEL_COMMIT
, wait_for_completion
=True
56 nfsrootfs
= "https://obj.internal.efficios.com/lava/rootfs/rootfs_amd64_xenial_2018-12-05.tar.gz"
57 nfsrootfs_sha256
= "0df15933ed18eb73ed5f0e7b1eca8d032ee88d92e5dbfc0f56dcc68c821048a8"
58 kernel_url
= "https://obj.internal.efficios.com/lava/kernel/{}.baremetal.bzImage".format(
61 kernel_sha256
= "0da55bad8c780a889ae71e7aa0f4788bc671c598c21369ad4211555088e3d889"
62 modules_url
= "https://obj.internal.efficios.com/lava/modules/linux/{}.baremetal.linux.modules.tar.gz".format(
69 lava_api_key
= os
.environ
["LAVA2_JENKINS_TOKEN"]
70 except Exception as error
:
72 "LAVA2_JENKINS_TOKEN not found in the environment variable. Exiting...",
77 jinja_loader
= FileSystemLoader(os
.path
.dirname(os
.path
.realpath(__file__
)))
78 jinja_env
= Environment(loader
=jinja_loader
, trim_blocks
=True, lstrip_blocks
=True)
79 jinja_template
= jinja_env
.get_template("template_lava_job_bt_benchmark.jinja2")
82 context
["kernel_url"] = kernel_url
83 context
["kernel_sha256"] = kernel_sha256
84 context
["nfsrootfs_url"] = nfsrootfs
85 context
["nfsrootfs_sha256"] = nfsrootfs_sha256
86 context
["commit_hash"] = commit
88 render
= jinja_template
.render(context
)
90 print("Job to be submitted:", flush
=True)
92 print(render
, flush
=True)
97 server
= xmlrpc
.client
.ServerProxy(
98 "http://%s:%s@%s/RPC2" % (USERNAME
, lava_api_key
, HOSTNAME
)
101 for attempt
in range(10):
103 jobid
= server
.scheduler
.submit_job(render
)
104 except xmlrpc
.client
.ProtocolError
as error
:
106 "Protocol error on submit, sleeping and retrying. Attempt #{}".format(
116 print("Lava jobid:{}".format(jobid
), flush
=True)
118 "Lava job URL: http://lava-master-02.internal.efficios.com/scheduler/job/{}".format(
124 if not wait_for_completion
:
127 wait_on(server
, jobid
)
130 if __name__
== "__main__":
131 parser
= argparse
.ArgumentParser(
132 description
="Launch baremetal babeltrace test using Lava"
134 parser
.add_argument("-c", "--commit", required
=True)
136 "-k", "--kernel-commit", required
=False, default
=DEFAULT_KERNEL_COMMIT
138 parser
.add_argument("-d", "--debug", required
=False, action
="store_true")
139 args
= parser
.parse_args()
140 sys
.exit(submit(args
.kernel_commit
, args
.commit
, args
.debug
))
This page took 0.034209 seconds and 5 git commands to generate.