summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2017-01-30 20:03:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-14 14:42:17 +0000
commitea4bac7e45188cd35f2c88cd0021fc8cfb8b3642 (patch)
tree93f1a0b32707b98e4bcb12bd69c27d3a2bbb6729 /meta/lib/oeqa
parentdfa298762350289772ef6841d8660912ad00a245 (diff)
downloadpoky-ea4bac7e45188cd35f2c88cd0021fc8cfb8b3642.tar.gz
testimage.bbclass: fix runtime test for rpm, port smart tests to dnf
(From OE-Core rev: 749a496d273f9fd378588e309cf976294584ca5f) Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/oetest.py7
-rw-r--r--meta/lib/oeqa/runtime/cases/dnf.py111
-rw-r--r--meta/lib/oeqa/runtime/cases/parselogs.py1
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py21
-rw-r--r--meta/lib/oeqa/runtime/cases/smart.py196
5 files changed, 123 insertions, 213 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 1dad763ff1..f7171260e7 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -128,13 +128,6 @@ class oeRuntimeTest(oeTest):
128 def tearDownLocal(self): 128 def tearDownLocal(self):
129 pass 129 pass
130 130
131 #TODO: use package_manager.py to install packages on any type of image
132 def install_packages(self, packagelist):
133 for package in packagelist:
134 (status, result) = self.target.run("smart install -y "+package)
135 if status != 0:
136 return status
137
138def getmodule(pos=2): 131def getmodule(pos=2):
139 # stack returns a list of tuples containg frame information 132 # stack returns a list of tuples containg frame information
140 # First element of the list the is current frame, caller is 1 133 # First element of the list the is current frame, caller is 1
diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py
new file mode 100644
index 0000000000..77e7eb9450
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/dnf.py
@@ -0,0 +1,111 @@
1import os
2import re
3import subprocess
4from oeqa.utils.httpserver import HTTPService
5
6from oeqa.runtime.case import OERuntimeTestCase
7from oeqa.core.decorator.depends import OETestDepends
8from oeqa.core.decorator.oeid import OETestID
9from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
10from oeqa.runtime.decorator.package import OEHasPackage
11
12class DnfTest(OERuntimeTestCase):
13
14 def dnf(self, command, expected = 0):
15 command = 'dnf-2 %s' % command
16 status, output = self.target.run(command, 1500)
17 message = os.linesep.join([command, output])
18 self.assertEqual(status, expected, message)
19 return output
20
21class DnfBasicTest(DnfTest):
22
23 @skipIfNotFeature('package-management',
24 'Test requires package-management to be in IMAGE_FEATURES')
25 @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
26 'RPM is not the primary package manager')
27 @OEHasPackage(['dnf'])
28 @OETestDepends(['ssh.SSHTest.test_ssh'])
29 def test_dnf_help(self):
30 self.dnf('--help')
31
32 @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
33 def test_dnf_version(self):
34 self.dnf('--version')
35
36 @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
37 def test_dnf_info(self):
38 self.dnf('info dnf')
39
40 @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
41 def test_dnf_search(self):
42 self.dnf('search dnf')
43
44 @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
45 def test_dnf_history(self):
46 self.dnf('history')
47
48class DnfRepoTest(DnfTest):
49
50 @classmethod
51 def setUpClass(cls):
52 cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-testimage-repo'),
53 cls.tc.target.server_ip)
54 cls.repo_server.start()
55
56 @classmethod
57 def tearDownClass(cls):
58 cls.repo_server.stop()
59
60 def dnf_with_repo(self, command):
61 pkgarchs = os.listdir(os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo'))
62 deploy_url = 'http://%s:%s/' %(self.target.server_ip, self.repo_server.port)
63 cmdlinerepoopts = ["--repofrompath=oe-testimage-repo-%s,%s%s" %(arch, deploy_url, arch) for arch in pkgarchs]
64
65 self.dnf(" ".join(cmdlinerepoopts) + " --nogpgcheck " + command)
66
67 @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
68 def test_dnf_makecache(self):
69 self.dnf_with_repo('makecache')
70
71
72# Does not work when repo is specified on the command line
73# @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
74# def test_dnf_repolist(self):
75# self.dnf_with_repo('repolist')
76
77 @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
78 def test_dnf_repoinfo(self):
79 self.dnf_with_repo('repoinfo')
80
81 @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
82 def test_dnf_install(self):
83 self.dnf_with_repo('install -y run-postinsts-dev')
84
85 @OETestDepends(['dnf.DnfRepoTest.test_dnf_install'])
86 def test_dnf_install_dependency(self):
87 self.dnf_with_repo('remove -y run-postinsts')
88 self.dnf_with_repo('install -y run-postinsts-dev')
89
90 @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_dependency'])
91 def test_dnf_install_from_disk(self):
92 self.dnf_with_repo('remove -y run-postinsts-dev')
93 self.dnf_with_repo('install -y --downloadonly run-postinsts-dev')
94 status, output = self.target.run('find /var/cache/dnf -name run-postinsts-dev*rpm', 1500)
95 self.assertEqual(status, 0, output)
96 self.dnf_with_repo('install -y %s' % output)
97
98 @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_from_disk'])
99 def test_dnf_install_from_http(self):
100 output = subprocess.check_output('%s %s -name run-postinsts-dev*' % (bb.utils.which(os.getenv('PATH'), "find"),
101 self.tc.td['DEPLOY_DIR_RPM']), shell=True).decode("utf-8")
102 rpm_path = output.split("/")[-2] + "/" + output.split("/")[-1]
103 url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, rpm_path)
104 self.dnf_with_repo('remove -y run-postinsts-dev')
105 self.dnf_with_repo('install -y %s' % url)
106
107 @OETestDepends(['dnf.DnfRepoTest.test_dnf_install'])
108 def test_dnf_reinstall(self):
109 self.dnf_with_repo('reinstall -y run-postinsts-dev')
110
111
diff --git a/meta/lib/oeqa/runtime/cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py
index a53a3608bd..6e929469c4 100644
--- a/meta/lib/oeqa/runtime/cases/parselogs.py
+++ b/meta/lib/oeqa/runtime/cases/parselogs.py
@@ -48,6 +48,7 @@ common_errors = [
48 "stmmac_dvr_probe: warning: cannot get CSR clock", 48 "stmmac_dvr_probe: warning: cannot get CSR clock",
49 "error: couldn\'t mount because of unsupported optional features", 49 "error: couldn\'t mount because of unsupported optional features",
50 "GPT: Use GNU Parted to correct GPT errors", 50 "GPT: Use GNU Parted to correct GPT errors",
51 "Cannot set xattr user.Librepo.DownloadInProgress",
51 ] 52 ]
52 53
53video_related = [ 54video_related = [
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
index 532fbf82eb..05b94c7b40 100644
--- a/meta/lib/oeqa/runtime/cases/rpm.py
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -102,14 +102,15 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
102 @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove']) 102 @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove'])
103 def test_check_rpm_install_removal_log_file_size(self): 103 def test_check_rpm_install_removal_log_file_size(self):
104 """ 104 """
105 Summary: Check rpm install/removal log file size 105 Summary: Check that rpm writes into /var/log/messages
106 Expected: There should be some method to keep rpm log in a small size . 106 Expected: There should be some RPM prefixed entries in the above file.
107 Product: BSPs 107 Product: BSPs
108 Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com> 108 Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
109 Author: Alexander Kanavin <alexander.kanavin@intel.com>
109 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> 110 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
110 """ 111 """
111 db_files_cmd = 'ls /var/lib/rpm/__db.*' 112 db_files_cmd = 'ls /var/lib/rpm/__db.*'
112 get_log_size_cmd = "du /var/lib/rpm/log/log.* | awk '{print $1}'" 113 check_log_cmd = "grep RPM /var/log/messages | wc -l"
113 114
114 # Make sure that some database files are under /var/lib/rpm as '__db.xxx' 115 # Make sure that some database files are under /var/lib/rpm as '__db.xxx'
115 status, output = self.target.run(db_files_cmd) 116 status, output = self.target.run(db_files_cmd)
@@ -129,13 +130,13 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
129 msg = 'Failed to remove rpm-doc package. Reason: {}'.format(output) 130 msg = 'Failed to remove rpm-doc package. Reason: {}'.format(output)
130 self.assertEqual(0, status, msg=msg) 131 self.assertEqual(0, status, msg=msg)
131 132
132 # Get the size of log file 133 # if using systemd this should ensure all entries are flushed to /var
133 status, output = self.target.run(get_log_size_cmd) 134 status, output = self.target.run("journalctl --sync")
135 # Get the amount of entries in the log file
136 status, output = self.target.run(check_log_cmd)
134 msg = 'Failed to get the final size of the log file.' 137 msg = 'Failed to get the final size of the log file.'
135 self.assertEqual(0, status, msg=msg) 138 self.assertEqual(0, status, msg=msg)
136 139
137 # Compare each log size 140 # Check that there's enough of them
138 for log_file_size in output: 141 self.assertGreaterEqual(int(output), 80,
139 msg = ('Log file size is greater that expected (~10MB), ' 142 'Cound not find sufficient amount of rpm entries in /var/log/messages, found {} entries'.format(output))
140 'found {} bytes'.format(log_file_size))
141 self.assertLessEqual(int(log_file_size), 11264, msg=msg)
diff --git a/meta/lib/oeqa/runtime/cases/smart.py b/meta/lib/oeqa/runtime/cases/smart.py
deleted file mode 100644
index 79bd9c8af7..0000000000
--- a/meta/lib/oeqa/runtime/cases/smart.py
+++ /dev/null
@@ -1,196 +0,0 @@
1import os
2import re
3import subprocess
4from oeqa.utils.httpserver import HTTPService
5
6from oeqa.runtime.case import OERuntimeTestCase
7from oeqa.core.decorator.depends import OETestDepends
8from oeqa.core.decorator.oeid import OETestID
9from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
10from oeqa.runtime.decorator.package import OEHasPackage
11
12class SmartTest(OERuntimeTestCase):
13
14 def smart(self, command, expected = 0):
15 command = 'smart %s' % command
16 status, output = self.target.run(command, 1500)
17 message = os.linesep.join([command, output])
18 self.assertEqual(status, expected, message)
19 self.assertFalse('Cannot allocate memory' in output, message)
20 return output
21
22class SmartBasicTest(SmartTest):
23
24 @skipIfNotFeature('package-management',
25 'Test requires package-management to be in IMAGE_FEATURES')
26 @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
27 'RPM is not the primary package manager')
28 @OEHasPackage(['smartpm'])
29 @OETestID(716)
30 @OETestDepends(['ssh.SSHTest.test_ssh'])
31 def test_smart_help(self):
32 self.smart('--help')
33
34 @OETestID(968)
35 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
36 def test_smart_version(self):
37 self.smart('--version')
38
39 @OETestID(721)
40 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
41 def test_smart_info(self):
42 self.smart('info python-smartpm')
43
44 @OETestID(421)
45 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
46 def test_smart_query(self):
47 self.smart('query python-smartpm')
48
49 @OETestID(720)
50 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
51 def test_smart_search(self):
52 self.smart('search python-smartpm')
53
54 @OETestID(722)
55 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
56 def test_smart_stats(self):
57 self.smart('stats')
58
59class SmartRepoTest(SmartTest):
60
61 @classmethod
62 def setUpClass(cls):
63 cls.repolist = []
64 cls.repo_server = HTTPService(cls.tc.td['WORKDIR'],
65 cls.tc.target.server_ip)
66 cls.repo_server.start()
67
68 @classmethod
69 def tearDownClass(cls):
70 cls.repo_server.stop()
71 for repo in cls.repolist:
72 cls.tc.target.run('smart channel -y --remove %s' % repo)
73
74 @OETestID(1143)
75 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
76 def test_smart_channel(self):
77 self.smart('channel', 1)
78
79 @OETestID(719)
80 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
81 def test_smart_channel_add(self):
82 image_pkgtype = self.tc.td['IMAGE_PKGTYPE']
83 deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
84 self.repo_server.port,
85 image_pkgtype)
86 pkgarchs = self.tc.td['PACKAGE_ARCHS'].replace("-","_").split()
87 archs = os.listdir(os.path.join(self.repo_server.root_dir,
88 image_pkgtype))
89 for arch in archs:
90 if arch in pkgarchs:
91 cmd = ('channel -y --add {a} type=rpm-md '
92 'baseurl={u}/{a}'.format(a=arch, u=deploy_url))
93 self.smart(cmd)
94 self.repolist.append(arch)
95 self.smart('update')
96
97 @OETestID(969)
98 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
99 def test_smart_channel_help(self):
100 self.smart('channel --help')
101
102 @OETestID(970)
103 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
104 def test_smart_channel_list(self):
105 self.smart('channel --list')
106
107 @OETestID(971)
108 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
109 def test_smart_channel_show(self):
110 self.smart('channel --show')
111
112 @OETestID(717)
113 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
114 def test_smart_channel_rpmsys(self):
115 self.smart('channel --show rpmsys')
116 self.smart('channel --disable rpmsys')
117 self.smart('channel --enable rpmsys')
118
119 @OETestID(1144)
120 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
121 def test_smart_install(self):
122 self.smart('remove -y psplash-default')
123 self.smart('install -y psplash-default')
124
125 @OETestID(728)
126 @OETestDepends(['smart.SmartRepoTest.test_smart_install'])
127 def test_smart_install_dependency(self):
128 self.smart('remove -y psplash')
129 self.smart('install -y psplash-default')
130
131 @OETestID(723)
132 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
133 def test_smart_install_from_disk(self):
134 self.smart('remove -y psplash-default')
135 self.smart('download psplash-default')
136 self.smart('install -y ./psplash-default*')
137
138 @OETestID(725)
139 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
140 def test_smart_install_from_http(self):
141 output = self.smart('download --urls psplash-default')
142 url = re.search('(http://.*/psplash-default.*\.rpm)', output)
143 self.assertTrue(url, msg="Couln't find download url in %s" % output)
144 self.smart('remove -y psplash-default')
145 self.smart('install -y %s' % url.group(0))
146
147 @OETestID(729)
148 @OETestDepends(['smart.SmartRepoTest.test_smart_install'])
149 def test_smart_reinstall(self):
150 self.smart('reinstall -y psplash-default')
151
152 @OETestID(727)
153 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
154 def test_smart_remote_repo(self):
155 self.smart('update')
156 self.smart('install -y psplash')
157 self.smart('remove -y psplash')
158
159 @OETestID(726)
160 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
161 def test_smart_local_dir(self):
162 self.target.run('mkdir /tmp/myrpmdir')
163 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
164 self.target.run('cd /tmp/myrpmdir')
165 self.smart('download psplash')
166 output = self.smart('channel --list')
167 for i in output.split("\n"):
168 if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
169 self.smart('channel --disable '+str(i))
170 self.target.run('cd $HOME')
171 self.smart('install psplash')
172 for i in output.split("\n"):
173 if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
174 self.smart('channel --enable '+str(i))
175 self.smart('channel --remove myrpmdir -y')
176 self.target.run("rm -rf /tmp/myrpmdir")
177
178 @OETestID(718)
179 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
180 def test_smart_add_rpmdir(self):
181 self.target.run('mkdir /tmp/myrpmdir')
182 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
183 self.smart('channel --disable myrpmdir -y')
184 output = self.smart('channel --show myrpmdir')
185 self.assertTrue("disabled = yes" in output, msg="Failed to disable rpm dir")
186 self.smart('channel --enable myrpmdir -y')
187 output = self.smart('channel --show myrpmdir')
188 self.assertFalse("disabled = yes" in output, msg="Failed to enable rpm dir")
189 self.smart('channel --remove myrpmdir -y')
190 self.target.run("rm -rf /tmp/myrpmdir")
191
192 @OETestID(731)
193 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
194 def test_smart_remove_package(self):
195 self.smart('install -y psplash')
196 self.smart('remove -y psplash')