summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/cases/smart.py
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2017-01-03 08:18:00 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:20 +0000
commit41e4db0eeaaa19f9f4d425960011b02c29f01c1c (patch)
tree8b11c1910f5fc94796ad02f7c8e2f2c856061957 /meta/lib/oeqa/runtime/cases/smart.py
parentb569aa0e0056a97b29577f5bda611ef3dd539db3 (diff)
downloadpoky-41e4db0eeaaa19f9f4d425960011b02c29f01c1c.tar.gz
runtime/cases/smart.py: Migrate smart tests
This migrates the smart test from the old framework to the new one. This has its own commit because smart test was using bb and oe libraries that are available when exporting the test cases to run in a different host. Because of the removal of bb and oe libraries index and packages feeds creation will be managed in testimage bbclass. [YOCTO #10234] (From OE-Core rev: 8d64ac4208e8dcb8a6fde6ea2959c9b3edfe2172) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/smart.py')
-rw-r--r--meta/lib/oeqa/runtime/cases/smart.py172
1 files changed, 75 insertions, 97 deletions
diff --git a/meta/lib/oeqa/runtime/cases/smart.py b/meta/lib/oeqa/runtime/cases/smart.py
index dde1c4d792..9b4d0d2c60 100644
--- a/meta/lib/oeqa/runtime/cases/smart.py
+++ b/meta/lib/oeqa/runtime/cases/smart.py
@@ -1,166 +1,142 @@
1import unittest 1import os
2import re 2import re
3import oe
4import subprocess 3import subprocess
5from oeqa.oetest import oeRuntimeTest, skipModule
6from oeqa.utils.decorators import *
7from oeqa.utils.httpserver import HTTPService 4from oeqa.utils.httpserver import HTTPService
8 5
9def setUpModule(): 6from oeqa.runtime.case import OERuntimeTestCase
10 if not oeRuntimeTest.hasFeature("package-management"): 7from oeqa.core.decorator.depends import OETestDepends
11 skipModule("Image doesn't have package management feature") 8from oeqa.core.decorator.oeid import OETestID
12 if not oeRuntimeTest.hasPackage("smartpm"): 9from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
13 skipModule("Image doesn't have smart installed") 10from oeqa.runtime.decorator.package import OEHasPackage
14 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES").split()[0]:
15 skipModule("Rpm is not the primary package manager")
16 11
17class SmartTest(oeRuntimeTest): 12class SmartTest(OERuntimeTestCase):
18 13
19 @skipUnlessPassed('test_smart_help')
20 def smart(self, command, expected = 0): 14 def smart(self, command, expected = 0):
21 command = 'smart %s' % command 15 command = 'smart %s' % command
22 status, output = self.target.run(command, 1500) 16 status, output = self.target.run(command, 1500)
23 message = os.linesep.join([command, output]) 17 message = os.linesep.join([command, output])
24 self.assertEqual(status, expected, message) 18 self.assertEqual(status, expected, message)
25 self.assertFalse("Cannot allocate memory" in output, message) 19 self.assertFalse('Cannot allocate memory' in output, message)
26 return output 20 return output
27 21
28class SmartBasicTest(SmartTest): 22class SmartBasicTest(SmartTest):
29 23
30 @testcase(716) 24 @skipIfNotFeature('package-management',
31 @skipUnlessPassed('test_ssh') 25 'Test requires package-management to be in IMAGE_FEATURES')
26 @skipIfNotDataVar('PACKAGE_CLASSES', 'package_rpm',
27 'RPM is not the primary package manager')
28 @OEHasPackage(['smartpm'])
29 @OETestID(716)
30 @OETestDepends(['ssh.SSHTest.test_ssh'])
32 def test_smart_help(self): 31 def test_smart_help(self):
33 self.smart('--help') 32 self.smart('--help')
34 33
35 @testcase(968) 34 @OETestID(968)
35 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
36 def test_smart_version(self): 36 def test_smart_version(self):
37 self.smart('--version') 37 self.smart('--version')
38 38
39 @testcase(721) 39 @OETestID(721)
40 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
40 def test_smart_info(self): 41 def test_smart_info(self):
41 self.smart('info python-smartpm') 42 self.smart('info python-smartpm')
42 43
43 @testcase(421) 44 @OETestID(421)
45 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
44 def test_smart_query(self): 46 def test_smart_query(self):
45 self.smart('query python-smartpm') 47 self.smart('query python-smartpm')
46 48
47 @testcase(720) 49 @OETestID(720)
50 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
48 def test_smart_search(self): 51 def test_smart_search(self):
49 self.smart('search python-smartpm') 52 self.smart('search python-smartpm')
50 53
51 @testcase(722) 54 @OETestID(722)
55 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
52 def test_smart_stats(self): 56 def test_smart_stats(self):
53 self.smart('stats') 57 self.smart('stats')
54 58
55class SmartRepoTest(SmartTest): 59class SmartRepoTest(SmartTest):
56 60
57 @classmethod 61 @classmethod
58 def create_index(self, arg): 62 def setUpClass(cls):
59 index_cmd = arg 63 cls.repolist = []
60 try: 64 cls.repo_server = HTTPService(cls.tc.td['WORKDIR'],
61 bb.note("Executing '%s' ..." % index_cmd) 65 cls.tc.target.server_ip)
62 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8") 66 cls.repo_server.start()
63 except subprocess.CalledProcessError as e:
64 return("Index creation command '%s' failed with return code %d:\n%s" %
65 (e.cmd, e.returncode, e.output.decode("utf-8")))
66 if result:
67 bb.note(result)
68 return None
69 67
70 @classmethod 68 @classmethod
71 def setUpClass(self): 69 def tearDownClass(cls):
72 self.repolist = [] 70 cls.repo_server.stop()
73 71 for repo in cls.repolist:
74 # Index RPMs 72 cls.tc.target.run('smart channel -y --remove %s' % repo)
75 rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo")
76 index_cmds = []
77 rpm_dirs_found = False
78 archs = (oeRuntimeTest.tc.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS') or "").replace('-', '_').split()
79 for arch in archs:
80 rpm_dir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM'), arch)
81 idx_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'), 'rpm', arch)
82 db_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'), 'rpmdb', arch)
83 if not os.path.isdir(rpm_dir):
84 continue
85 if os.path.exists(db_path):
86 bb.utils.remove(dbpath, True)
87 lockfilename = oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM') + "/rpm.lock"
88 lf = bb.utils.lockfile(lockfilename, False)
89 oe.path.copyhardlinktree(rpm_dir, idx_path)
90 # Full indexes overload a 256MB image so reduce the number of rpms
91 # in the feed. Filter to p* since we use the psplash packages and
92 # this leaves some allarch and machine arch packages too.
93 bb.utils.remove(idx_path + "*/[a-oq-z]*.rpm")
94 bb.utils.unlockfile(lf)
95 index_cmds.append("%s --dbpath %s --update -q %s" % (rpm_createrepo, db_path, idx_path))
96 rpm_dirs_found = True
97 # Create repodata¬
98 result = oe.utils.multiprocess_exec(index_cmds, self.create_index)
99 if result:
100 bb.fatal('%s' % ('\n'.join(result)))
101 self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('WORKDIR'), oeRuntimeTest.tc.target.server_ip)
102 self.repo_server.start()
103
104 @classmethod
105 def tearDownClass(self):
106 self.repo_server.stop()
107 for i in self.repolist:
108 oeRuntimeTest.tc.target.run('smart channel -y --remove '+str(i))
109 73
110 @testcase(1143) 74 @OETestID(1143)
75 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
111 def test_smart_channel(self): 76 def test_smart_channel(self):
112 self.smart('channel', 1) 77 self.smart('channel', 1)
113 78
114 @testcase(719) 79 @OETestID(719)
80 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
115 def test_smart_channel_add(self): 81 def test_smart_channel_add(self):
116 image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE') 82 image_pkgtype = self.tc.td['IMAGE_PKGTYPE']
117 deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype) 83 deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
118 pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-","_").split() 84 self.repo_server.port,
119 for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)): 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:
120 if arch in pkgarchs: 90 if arch in pkgarchs:
121 self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url)) 91 cmd = ('channel -y --add {a} type=rpm-md '
92 'baseurl={u}/{a}'.format(a=arch, u=deploy_url))
93 self.smart(cmd)
122 self.repolist.append(arch) 94 self.repolist.append(arch)
123 self.smart('update') 95 self.smart('update')
124 96
125 @testcase(969) 97 @OETestID(969)
98 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
126 def test_smart_channel_help(self): 99 def test_smart_channel_help(self):
127 self.smart('channel --help') 100 self.smart('channel --help')
128 101
129 @testcase(970) 102 @OETestID(970)
103 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
130 def test_smart_channel_list(self): 104 def test_smart_channel_list(self):
131 self.smart('channel --list') 105 self.smart('channel --list')
132 106
133 @testcase(971) 107 @OETestID(971)
108 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
134 def test_smart_channel_show(self): 109 def test_smart_channel_show(self):
135 self.smart('channel --show') 110 self.smart('channel --show')
136 111
137 @testcase(717) 112 @OETestID(717)
113 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
138 def test_smart_channel_rpmsys(self): 114 def test_smart_channel_rpmsys(self):
139 self.smart('channel --show rpmsys') 115 self.smart('channel --show rpmsys')
140 self.smart('channel --disable rpmsys') 116 self.smart('channel --disable rpmsys')
141 self.smart('channel --enable rpmsys') 117 self.smart('channel --enable rpmsys')
142 118
143 @testcase(1144) 119 @OETestID(1144)
144 @skipUnlessPassed('test_smart_channel_add') 120 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
145 def test_smart_install(self): 121 def test_smart_install(self):
146 self.smart('remove -y psplash-default') 122 self.smart('remove -y psplash-default')
147 self.smart('install -y psplash-default') 123 self.smart('install -y psplash-default')
148 124
149 @testcase(728) 125 @OETestID(728)
150 @skipUnlessPassed('test_smart_install') 126 @OETestDepends(['smart.SmartRepoTest.test_smart_install'])
151 def test_smart_install_dependency(self): 127 def test_smart_install_dependency(self):
152 self.smart('remove -y psplash') 128 self.smart('remove -y psplash')
153 self.smart('install -y psplash-default') 129 self.smart('install -y psplash-default')
154 130
155 @testcase(723) 131 @OETestID(723)
156 @skipUnlessPassed('test_smart_channel_add') 132 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
157 def test_smart_install_from_disk(self): 133 def test_smart_install_from_disk(self):
158 self.smart('remove -y psplash-default') 134 self.smart('remove -y psplash-default')
159 self.smart('download psplash-default') 135 self.smart('download psplash-default')
160 self.smart('install -y ./psplash-default*') 136 self.smart('install -y ./psplash-default*')
161 137
162 @testcase(725) 138 @OETestID(725)
163 @skipUnlessPassed('test_smart_channel_add') 139 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
164 def test_smart_install_from_http(self): 140 def test_smart_install_from_http(self):
165 output = self.smart('download --urls psplash-default') 141 output = self.smart('download --urls psplash-default')
166 url = re.search('(http://.*/psplash-default.*\.rpm)', output) 142 url = re.search('(http://.*/psplash-default.*\.rpm)', output)
@@ -168,19 +144,20 @@ class SmartRepoTest(SmartTest):
168 self.smart('remove -y psplash-default') 144 self.smart('remove -y psplash-default')
169 self.smart('install -y %s' % url.group(0)) 145 self.smart('install -y %s' % url.group(0))
170 146
171 @testcase(729) 147 @OETestID(729)
172 @skipUnlessPassed('test_smart_install') 148 @OETestDepends(['smart.SmartRepoTest.test_smart_install'])
173 def test_smart_reinstall(self): 149 def test_smart_reinstall(self):
174 self.smart('reinstall -y psplash-default') 150 self.smart('reinstall -y psplash-default')
175 151
176 @testcase(727) 152 @OETestID(727)
177 @skipUnlessPassed('test_smart_channel_add') 153 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
178 def test_smart_remote_repo(self): 154 def test_smart_remote_repo(self):
179 self.smart('update') 155 self.smart('update')
180 self.smart('install -y psplash') 156 self.smart('install -y psplash')
181 self.smart('remove -y psplash') 157 self.smart('remove -y psplash')
182 158
183 @testcase(726) 159 @OETestID(726)
160 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
184 def test_smart_local_dir(self): 161 def test_smart_local_dir(self):
185 self.target.run('mkdir /tmp/myrpmdir') 162 self.target.run('mkdir /tmp/myrpmdir')
186 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y') 163 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
@@ -198,7 +175,8 @@ class SmartRepoTest(SmartTest):
198 self.smart('channel --remove myrpmdir -y') 175 self.smart('channel --remove myrpmdir -y')
199 self.target.run("rm -rf /tmp/myrpmdir") 176 self.target.run("rm -rf /tmp/myrpmdir")
200 177
201 @testcase(718) 178 @OETestID(718)
179 @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
202 def test_smart_add_rpmdir(self): 180 def test_smart_add_rpmdir(self):
203 self.target.run('mkdir /tmp/myrpmdir') 181 self.target.run('mkdir /tmp/myrpmdir')
204 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y') 182 self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
@@ -211,8 +189,8 @@ class SmartRepoTest(SmartTest):
211 self.smart('channel --remove myrpmdir -y') 189 self.smart('channel --remove myrpmdir -y')
212 self.target.run("rm -rf /tmp/myrpmdir") 190 self.target.run("rm -rf /tmp/myrpmdir")
213 191
214 @testcase(731) 192 @OETestID(731)
215 @skipUnlessPassed('test_smart_channel_add') 193 @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
216 def test_smart_remove_package(self): 194 def test_smart_remove_package(self):
217 self.smart('install -y psplash') 195 self.smart('install -y psplash')
218 self.smart('remove -y psplash') 196 self.smart('remove -y psplash')