summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roos <throos@amazon.de>2023-05-17 16:36:13 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-29 10:57:27 +0100
commitf82c3bd37d62a3efc49fd33efa38a7f523e6c676 (patch)
treeaf91e742b938e4116a5082bfb9351dba83616cca
parent303421dce02fec67daab0dc86d85e11963d5741f (diff)
downloadpoky-f82c3bd37d62a3efc49fd33efa38a7f523e6c676.tar.gz
testimage/oeqa: Drop testimage_dump_host functionality
The intent behind these functions was to dump the system state when issues occured but it has never really worked as we'd planned. Regular monitoring as the build runs has largely replaced this as that allows a trend to be seen rather than a spot value which was never really useful. The code is bitrotting and not functioning correctly so drop it. [YOCTO #13872] RP: Reword commit message (From OE-Core rev: dea37ba49a236029da73d5cfbfc069bffc38b508) Signed-off-by: Thomas Roos <throos@amazon.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/testexport.bbclass6
-rw-r--r--meta/classes-recipe/testimage.bbclass20
-rw-r--r--meta/lib/oeqa/core/target/qemu.py5
-rw-r--r--meta/lib/oeqa/runtime/context.py11
-rw-r--r--meta/lib/oeqa/targetcontrol.py2
-rw-r--r--meta/lib/oeqa/utils/dump.py20
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py18
7 files changed, 8 insertions, 74 deletions
diff --git a/meta/classes-recipe/testexport.bbclass b/meta/classes-recipe/testexport.bbclass
index 0f0c56107f..572f5d9e76 100644
--- a/meta/classes-recipe/testexport.bbclass
+++ b/meta/classes-recipe/testexport.bbclass
@@ -61,16 +61,12 @@ def testexport_main(d):
61 d.getVar("TEST_TARGET"), None, d.getVar("TEST_TARGET_IP"), 61 d.getVar("TEST_TARGET"), None, d.getVar("TEST_TARGET_IP"),
62 d.getVar("TEST_SERVER_IP")) 62 d.getVar("TEST_SERVER_IP"))
63 63
64 host_dumper = OERuntimeTestContextExecutor.getHostDumper(
65 d.getVar("testimage_dump_host"), d.getVar("TESTIMAGE_DUMP_DIR"))
66
67 image_manifest = "%s.manifest" % image_name 64 image_manifest = "%s.manifest" % image_name
68 image_packages = OERuntimeTestContextExecutor.readPackagesManifest(image_manifest) 65 image_packages = OERuntimeTestContextExecutor.readPackagesManifest(image_manifest)
69 66
70 extract_dir = d.getVar("TEST_EXTRACTED_DIR") 67 extract_dir = d.getVar("TEST_EXTRACTED_DIR")
71 68
72 tc = OERuntimeTestContext(td, logger, target, host_dumper, 69 tc = OERuntimeTestContext(td, logger, target, image_packages, extract_dir)
73 image_packages, extract_dir)
74 70
75 copy_needed_files(d, tc) 71 copy_needed_files(d, tc)
76 72
diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass
index 0f02eadf57..e3068348ff 100644
--- a/meta/classes-recipe/testimage.bbclass
+++ b/meta/classes-recipe/testimage.bbclass
@@ -124,18 +124,6 @@ testimage_dump_target () {
124 find /var/log/ -type f 2>/dev/null -exec echo "====================" \; -exec echo {} \; -exec echo "====================" \; -exec cat {} \; -exec echo "" \; 124 find /var/log/ -type f 2>/dev/null -exec echo "====================" \; -exec echo {} \; -exec echo "====================" \; -exec cat {} \; -exec echo "" \;
125} 125}
126 126
127testimage_dump_host () {
128 top -bn1
129 iostat -x -z -N -d -p ALL 20 2
130 ps -ef
131 free
132 df
133 memstat
134 dmesg
135 ip -s link
136 netstat -an
137}
138
139testimage_dump_monitor () { 127testimage_dump_monitor () {
140 query-status 128 query-status
141 query-block 129 query-block
@@ -381,19 +369,13 @@ def testimage_main(d):
381 # runtime use network for download projects for build 369 # runtime use network for download projects for build
382 export_proxies(d) 370 export_proxies(d)
383 371
384 # we need the host dumper in test context
385 host_dumper = OERuntimeTestContextExecutor.getHostDumper(
386 d.getVar("testimage_dump_host"),
387 d.getVar("TESTIMAGE_DUMP_DIR"))
388
389 # the robot dance 372 # the robot dance
390 target = OERuntimeTestContextExecutor.getTarget( 373 target = OERuntimeTestContextExecutor.getTarget(
391 d.getVar("TEST_TARGET"), logger, d.getVar("TEST_TARGET_IP"), 374 d.getVar("TEST_TARGET"), logger, d.getVar("TEST_TARGET_IP"),
392 d.getVar("TEST_SERVER_IP"), **target_kwargs) 375 d.getVar("TEST_SERVER_IP"), **target_kwargs)
393 376
394 # test context 377 # test context
395 tc = OERuntimeTestContext(td, logger, target, host_dumper, 378 tc = OERuntimeTestContext(td, logger, target, image_packages, extract_dir)
396 image_packages, extract_dir)
397 379
398 # Load tests before starting the target 380 # Load tests before starting the target
399 test_paths = get_runtime_paths(d) 381 test_paths = get_runtime_paths(d)
diff --git a/meta/lib/oeqa/core/target/qemu.py b/meta/lib/oeqa/core/target/qemu.py
index 79fd724f7d..6893d10226 100644
--- a/meta/lib/oeqa/core/target/qemu.py
+++ b/meta/lib/oeqa/core/target/qemu.py
@@ -22,7 +22,7 @@ supported_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
22class OEQemuTarget(OESSHTarget): 22class OEQemuTarget(OESSHTarget):
23 def __init__(self, logger, server_ip, timeout=300, user='root', 23 def __init__(self, logger, server_ip, timeout=300, user='root',
24 port=None, machine='', rootfs='', kernel='', kvm=False, slirp=False, 24 port=None, machine='', rootfs='', kernel='', kvm=False, slirp=False,
25 dump_dir='', dump_host_cmds='', display='', bootlog='', 25 dump_dir='', display='', bootlog='',
26 tmpdir='', dir_image='', boottime=60, serial_ports=2, 26 tmpdir='', dir_image='', boottime=60, serial_ports=2,
27 boot_patterns = defaultdict(str), ovmf=False, tmpfsdir=None, **kwargs): 27 boot_patterns = defaultdict(str), ovmf=False, tmpfsdir=None, **kwargs):
28 28
@@ -44,8 +44,7 @@ class OEQemuTarget(OESSHTarget):
44 self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir, 44 self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir,
45 deploy_dir_image=dir_image, display=display, 45 deploy_dir_image=dir_image, display=display,
46 logfile=bootlog, boottime=boottime, 46 logfile=bootlog, boottime=boottime,
47 use_kvm=kvm, use_slirp=slirp, dump_dir=dump_dir, 47 use_kvm=kvm, use_slirp=slirp, dump_dir=dump_dir, logger=logger,
48 dump_host_cmds=dump_host_cmds, logger=logger,
49 serial_ports=serial_ports, boot_patterns = boot_patterns, 48 serial_ports=serial_ports, boot_patterns = boot_patterns,
50 use_ovmf=ovmf, tmpfsdir=tmpfsdir) 49 use_ovmf=ovmf, tmpfsdir=tmpfsdir)
51 dump_monitor_cmds = kwargs.get("testimage_dump_monitor") 50 dump_monitor_cmds = kwargs.get("testimage_dump_monitor")
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 0c5d1869ab..cb7227a8df 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -10,7 +10,6 @@ import sys
10from oeqa.core.context import OETestContext, OETestContextExecutor 10from oeqa.core.context import OETestContext, OETestContextExecutor
11from oeqa.core.target.ssh import OESSHTarget 11from oeqa.core.target.ssh import OESSHTarget
12from oeqa.core.target.qemu import OEQemuTarget 12from oeqa.core.target.qemu import OEQemuTarget
13from oeqa.utils.dump import HostDumper
14 13
15from oeqa.runtime.loader import OERuntimeTestLoader 14from oeqa.runtime.loader import OERuntimeTestLoader
16 15
@@ -20,12 +19,11 @@ class OERuntimeTestContext(OETestContext):
20 os.path.dirname(os.path.abspath(__file__)), "files") 19 os.path.dirname(os.path.abspath(__file__)), "files")
21 20
22 def __init__(self, td, logger, target, 21 def __init__(self, td, logger, target,
23 host_dumper, image_packages, extract_dir): 22 image_packages, extract_dir):
24 super(OERuntimeTestContext, self).__init__(td, logger) 23 super(OERuntimeTestContext, self).__init__(td, logger)
25 24
26 self.target = target 25 self.target = target
27 self.image_packages = image_packages 26 self.image_packages = image_packages
28 self.host_dumper = host_dumper
29 self.extract_dir = extract_dir 27 self.extract_dir = extract_dir
30 self._set_target_cmds() 28 self._set_target_cmds()
31 29
@@ -199,10 +197,6 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
199 197
200 return image_packages 198 return image_packages
201 199
202 @staticmethod
203 def getHostDumper(cmds, directory):
204 return HostDumper(cmds, directory)
205
206 def _process_args(self, logger, args): 200 def _process_args(self, logger, args):
207 if not args.packages_manifest: 201 if not args.packages_manifest:
208 raise TypeError('Manifest file not provided') 202 raise TypeError('Manifest file not provided')
@@ -215,9 +209,6 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
215 self.tc_kwargs['init']['target'] = \ 209 self.tc_kwargs['init']['target'] = \
216 OERuntimeTestContextExecutor.getTarget(args.target_type, 210 OERuntimeTestContextExecutor.getTarget(args.target_type,
217 None, args.target_ip, args.server_ip, **target_kwargs) 211 None, args.target_ip, args.server_ip, **target_kwargs)
218 self.tc_kwargs['init']['host_dumper'] = \
219 OERuntimeTestContextExecutor.getHostDumper(None,
220 args.host_dumper_dir)
221 self.tc_kwargs['init']['image_packages'] = \ 212 self.tc_kwargs['init']['image_packages'] = \
222 OERuntimeTestContextExecutor.readPackagesManifest( 213 OERuntimeTestContextExecutor.readPackagesManifest(
223 args.packages_manifest) 214 args.packages_manifest)
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index d686fe07ec..e21655c979 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -104,7 +104,6 @@ class QemuTarget(BaseTarget):
104 self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin') 104 self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin')
105 self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) 105 self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime)
106 dump_target_cmds = d.getVar("testimage_dump_target") 106 dump_target_cmds = d.getVar("testimage_dump_target")
107 dump_host_cmds = d.getVar("testimage_dump_host")
108 dump_monitor_cmds = d.getVar("testimage_dump_monitor") 107 dump_monitor_cmds = d.getVar("testimage_dump_monitor")
109 dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") 108 dump_dir = d.getVar("TESTIMAGE_DUMP_DIR")
110 if not dump_dir: 109 if not dump_dir:
@@ -141,7 +140,6 @@ class QemuTarget(BaseTarget):
141 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")), 140 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")),
142 use_kvm = use_kvm, 141 use_kvm = use_kvm,
143 dump_dir = dump_dir, 142 dump_dir = dump_dir,
144 dump_host_cmds = dump_host_cmds,
145 logger = logger, 143 logger = logger,
146 tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"), 144 tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"),
147 serial_ports = len(d.getVar("SERIAL_CONSOLES").split())) 145 serial_ports = len(d.getVar("SERIAL_CONSOLES").split()))
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py
index d420b497f9..d4d271369f 100644
--- a/meta/lib/oeqa/utils/dump.py
+++ b/meta/lib/oeqa/utils/dump.py
@@ -51,9 +51,7 @@ class BaseDumper(object):
51 self.dump_dir = dump_dir 51 self.dump_dir = dump_dir
52 52
53 def _construct_filename(self, command): 53 def _construct_filename(self, command):
54 if isinstance(self, HostDumper): 54 if isinstance(self, TargetDumper):
55 prefix = "host"
56 elif isinstance(self, TargetDumper):
57 prefix = "target" 55 prefix = "target"
58 elif isinstance(self, MonitorDumper): 56 elif isinstance(self, MonitorDumper):
59 prefix = "qmp" 57 prefix = "qmp"
@@ -76,22 +74,6 @@ class BaseDumper(object):
76 with open(fullname, 'w') as dump_file: 74 with open(fullname, 'w') as dump_file:
77 dump_file.write(output) 75 dump_file.write(output)
78 76
79class HostDumper(BaseDumper):
80 """ Class to get dumps from the host running the tests """
81
82 def __init__(self, cmds, parent_dir):
83 super(HostDumper, self).__init__(cmds, parent_dir)
84
85 def dump_host(self, dump_dir=""):
86 if dump_dir:
87 self.dump_dir = dump_dir
88 env = os.environ.copy()
89 env['PATH'] = '/usr/sbin:/sbin:/usr/bin:/bin'
90 env['COLUMNS'] = '9999'
91 for cmd in self.cmds:
92 result = runCmd(cmd, ignore_status=True, env=env)
93 self._write_dump(cmd.split()[0], result.output)
94
95class TargetDumper(BaseDumper): 77class TargetDumper(BaseDumper):
96 """ Class to get dumps from target, it only works with QemuRunner. 78 """ Class to get dumps from target, it only works with QemuRunner.
97 Will give up permanently after 5 errors from running commands over 79 Will give up permanently after 5 errors from running commands over
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 0ef8cf0a79..22cf258ddd 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -21,7 +21,6 @@ import threading
21import codecs 21import codecs
22import logging 22import logging
23import tempfile 23import tempfile
24from oeqa.utils.dump import HostDumper
25from collections import defaultdict 24from collections import defaultdict
26import importlib 25import importlib
27 26
@@ -33,8 +32,8 @@ re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
33 32
34class QemuRunner: 33class QemuRunner:
35 34
36 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds, 35 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, use_kvm, logger, use_slirp=False,
37 use_kvm, logger, use_slirp=False, serial_ports=2, boot_patterns = defaultdict(str), use_ovmf=False, workdir=None, tmpfsdir=None): 36 serial_ports=2, boot_patterns = defaultdict(str), use_ovmf=False, workdir=None, tmpfsdir=None):
38 37
39 # Popen object for runqemu 38 # Popen object for runqemu
40 self.runqemu = None 39 self.runqemu = None
@@ -69,7 +68,6 @@ class QemuRunner:
69 if not workdir: 68 if not workdir:
70 workdir = os.getcwd() 69 workdir = os.getcwd()
71 self.qemu_pidfile = workdir + '/pidfile_' + str(os.getpid()) 70 self.qemu_pidfile = workdir + '/pidfile_' + str(os.getpid())
72 self.host_dumper = HostDumper(dump_host_cmds, dump_dir)
73 self.monitorpipe = None 71 self.monitorpipe = None
74 72
75 self.logger = logger 73 self.logger = logger
@@ -138,7 +136,6 @@ class QemuRunner:
138 self.logger.error('runqemu exited with code %d' % self.runqemu.returncode) 136 self.logger.error('runqemu exited with code %d' % self.runqemu.returncode)
139 self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout)) 137 self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout))
140 self.stop() 138 self.stop()
141 self._dump_host()
142 139
143 def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): 140 def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True):
144 env = os.environ.copy() 141 env = os.environ.copy()
@@ -286,7 +283,6 @@ class QemuRunner:
286 if self.runqemu.returncode: 283 if self.runqemu.returncode:
287 # No point waiting any longer 284 # No point waiting any longer
288 self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) 285 self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode)
289 self._dump_host()
290 self.logger.warning("Output from runqemu:\n%s" % self.getOutput(output)) 286 self.logger.warning("Output from runqemu:\n%s" % self.getOutput(output))
291 self.stop() 287 self.stop()
292 return False 288 return False
@@ -314,7 +310,6 @@ class QemuRunner:
314 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command '], stdout=subprocess.PIPE).communicate()[0] 310 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command '], stdout=subprocess.PIPE).communicate()[0]
315 processes = ps.decode("utf-8") 311 processes = ps.decode("utf-8")
316 self.logger.debug("Running processes:\n%s" % processes) 312 self.logger.debug("Running processes:\n%s" % processes)
317 self._dump_host()
318 op = self.getOutput(output) 313 op = self.getOutput(output)
319 self.stop() 314 self.stop()
320 if op: 315 if op:
@@ -430,7 +425,6 @@ class QemuRunner:
430 self.logger.error("Couldn't get ip from qemu command line and runqemu output! " 425 self.logger.error("Couldn't get ip from qemu command line and runqemu output! "
431 "Here is the qemu command line used:\n%s\n" 426 "Here is the qemu command line used:\n%s\n"
432 "and output from runqemu:\n%s" % (cmdline, out)) 427 "and output from runqemu:\n%s" % (cmdline, out))
433 self._dump_host()
434 self.stop() 428 self.stop()
435 return False 429 return False
436 430
@@ -517,7 +511,6 @@ class QemuRunner:
517 lines = tail(bootlog if bootlog else self.msg) 511 lines = tail(bootlog if bootlog else self.msg)
518 self.logger.warning("Last 25 lines of text (%d):\n%s" % (len(bootlog), lines)) 512 self.logger.warning("Last 25 lines of text (%d):\n%s" % (len(bootlog), lines))
519 self.logger.warning("Check full boot log: %s" % self.logfile) 513 self.logger.warning("Check full boot log: %s" % self.logfile)
520 self._dump_host()
521 self.stop() 514 self.stop()
522 return False 515 return False
523 516
@@ -698,13 +691,6 @@ class QemuRunner:
698 status = 1 691 status = 1
699 return (status, str(data)) 692 return (status, str(data))
700 693
701
702 def _dump_host(self):
703 self.host_dumper.create_dir("qemu")
704 self.logger.warning("Qemu ended unexpectedly, dump data from host"
705 " is in %s" % self.host_dumper.dump_dir)
706 self.host_dumper.dump_host()
707
708# This class is for reading data from a socket and passing it to logfunc 694# This class is for reading data from a socket and passing it to logfunc
709# to be processed. It's completely event driven and has a straightforward 695# to be processed. It's completely event driven and has a straightforward
710# event loop. The mechanism for stopping the thread is a simple pipe which 696# event loop. The mechanism for stopping the thread is a simple pipe which