blob: 64a35023703fd065feb461acb4c014b659cd05b3 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001from oeqa.core.decorator.depends import OETestDepends
2from oeqa.runtime.cases.dnf import DnfTest
3from oeqa.utils.httpserver import HTTPService
Brad Bishopd5ae7d92018-06-14 09:52:03 -07004from oeqa.core.decorator.data import skipIfDataVar
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005
6class DnfSelftest(DnfTest):
7
8 @classmethod
9 def setUpClass(cls):
10 import tempfile
11 cls.temp_dir = tempfile.TemporaryDirectory(prefix="oeqa-remotefeeds-")
12 cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-rootfs-repo'),
13 cls.tc.target.server_ip)
14 cls.repo_server.start()
15
16 @classmethod
17 def tearDownClass(cls):
18 cls.repo_server.stop()
19 cls.temp_dir.cleanup()
20
21 @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
Brad Bishopd5ae7d92018-06-14 09:52:03 -070022 @skipIfDataVar('PACKAGE_FEED_URIS', None,
23 'Not suitable as PACKAGE_FEED_URIS is not set')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024 def test_verify_package_feeds(self):
25 """
26 Summary: Check correct setting of PACKAGE_FEED_URIS var
27 Expected: 1. Feeds were correctly set for dnf
28 2. Update recovers packages from host's repo
29 Author: Humberto Ibarra <humberto.ibarra.lopez@intel.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030 Author: Alexander Kanavin <alex.kanavin@gmail.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031 """
32 # When we created an image, we had to supply fake ip and port
33 # for the feeds. Now we can patch the real ones into the config file.
34 temp_file = os.path.join(self.temp_dir.name, 'tmp.repo')
35 self.tc.target.copyFrom("/etc/yum.repos.d/oe-remote-repo.repo", temp_file)
36 fixed_config = open(temp_file, "r").read().replace("bogus_ip", self.tc.target.server_ip).replace("bogus_port", str(self.repo_server.port))
37 with open(temp_file, "w") as f:
38 f.write(fixed_config)
39 self.tc.target.copyTo(temp_file, "/etc/yum.repos.d/oe-remote-repo.repo")
40
41 import re
42 # Use '-y' for non-interactive mode: automatically import the feed signing key
43 output_makecache = self.dnf('-vy makecache')
44 self.assertTrue(re.match(r".*Failed to synchronize cache", output_makecache, re.DOTALL) is None, msg = "dnf makecache failed to synchronize repo: %s" %(output_makecache))
45 self.assertTrue(re.match(r".*Metadata cache created", output_makecache, re.DOTALL) is not None, msg = "dnf makecache failed: %s" %(output_makecache))
46
47 output_repoinfo = self.dnf('-v repoinfo')
48 matchobj = re.match(r".*Repo-pkgs\s*:\s*(?P<n_pkgs>[0-9]+)", output_repoinfo, re.DOTALL)
49 self.assertTrue(matchobj is not None, msg = "Could not find the amount of packages in dnf repoinfo output: %s" %(output_repoinfo))
50 self.assertTrue(int(matchobj.group('n_pkgs')) > 0, msg = "Amount of remote packages is not more than zero: %s\n" %(output_repoinfo))