path: root/meta-selftest/lib
diff options
authorAlexander Kanavin <>2017-03-16 15:19:04 +0200
committerRichard Purdie <>2017-03-17 16:53:04 +0000
commit2b77735c72cb5100dbd850e79d4f639e82629842 (patch)
tree859dde4d0a69b2392ad36d8278dc92d1d8b23554 /meta-selftest/lib
parentcb05db0d034494ab2dfba6797225d18ac7b6a105 (diff)
rpm: add support for remote package feeds via PACKAGE_FEED_URIS variable
I've used a previous patch (which was never merged) by Humberto Ibarra <> as a model for how to do runtime testing of this feature (e.g. we need to boot an image, run dnf on it, and check that it is indeed able to access the remote repo over http). Here's his original commit message: ===== Testing that feeds specified with PACKAGE_FEED_URIS var are set correctly has two parts. First a build with this var set is required, and then smart update needs to be issued in the running taget. The previous is not a common selftest practice because this is a simple test, but requires building and running a specific image, which takes a lot of time. testimage is not a good fit either, since the images tested there do not have the PACKAGE_FEED_URIS var set. For this test, the runtime-test module is being used, which is a selftest module but runs a testimage command. The var and test environment were set in and the actual test is done in a new testcase added to meta-selftest layer. ===== [YOCTO #10872] (From OE-Core rev: 3a9e2fdef9316e24b52ce99ac355fc2b09786c72) Signed-off-by: Alexander Kanavin <> Signed-off-by: Richard Purdie <>
Diffstat (limited to 'meta-selftest/lib')
1 files changed, 42 insertions, 0 deletions
diff --git a/meta-selftest/lib/oeqa/runtime/cases/ b/meta-selftest/lib/oeqa/runtime/cases/
index 19de740623..e4985a6edd 100644
--- a/meta-selftest/lib/oeqa/runtime/cases/
+++ b/meta-selftest/lib/oeqa/runtime/cases/
@@ -1,5 +1,7 @@
from import OERuntimeTestCase
from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.cases.dnf import DnfTest
+from oeqa.utils.httpserver import HTTPService
class Selftest(OERuntimeTestCase):
@@ -29,3 +31,43 @@ class Selftest(OERuntimeTestCase):
(status, output) ="socat -V")
self.assertNotEqual(status, 0, msg="socat is still installed")
+class DnfSelftest(DnfTest):
+ @classmethod
+ def setUpClass(cls):
+ cls.repo_server = HTTPService(os.path.join(['WORKDIR'], 'oe-rootfs-repo'),
+ cls.repo_server.start()
+ @classmethod
+ def tearDownClass(cls):
+ cls.repo_server.stop()
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_verify_package_feeds(self):
+ """
+ Summary: Check correct setting of PACKAGE_FEED_URIS var
+ Expected: 1. Feeds were correctly set for dnf
+ 2. Update recovers packages from host's repo
+ Author: Humberto Ibarra <>
+ Author: Alexander Kanavin <>
+ """
+ # When we created an image, we had to supply fake ip and port
+ # for the feeds. Now we can patch the real ones into the config file.
+ import tempfile
+ temp_file = tempfile.TemporaryDirectory(prefix="oeqa-remotefeeds-").name
+"/etc/yum.repos.d/oe-remote-repo.repo", temp_file)
+ fixed_config = open(temp_file, "r").read().replace("bogus_ip","bogus_port", str(self.repo_server.port))
+ open(temp_file, "w").write(fixed_config)
+, "/etc/yum.repos.d/oe-remote-repo.repo")
+ import re
+ output_makecache = self.dnf('makecache')
+ self.assertTrue(re.match(r".*Metadata cache created", output_makecache, re.DOTALL) is not None, msg = "dnf makecache failed: %s" %(output_makecache))
+ output_repoinfo = self.dnf('repoinfo')
+ matchobj = re.match(r".*Repo-pkgs\s*:\s*(?P<n_pkgs>[0-9]+)", output_repoinfo, re.DOTALL)
+ self.assertTrue(matchobj is not None, msg = "Could not find the amount of packages in dnf repoinfo output: %s" %(output_repoinfo))
+ self.assertTrue(int('n_pkgs')) > 0, msg = "Amount of remote packages is not more than zero: %s\n" %(output_repoinfo))