diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/prservice.py')
-rw-r--r-- | meta/lib/oeqa/selftest/prservice.py | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/meta/lib/oeqa/selftest/prservice.py b/meta/lib/oeqa/selftest/prservice.py deleted file mode 100644 index 34d419762c..0000000000 --- a/meta/lib/oeqa/selftest/prservice.py +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | import unittest | ||
2 | import os | ||
3 | import logging | ||
4 | import re | ||
5 | import shutil | ||
6 | import datetime | ||
7 | |||
8 | import oeqa.utils.ftools as ftools | ||
9 | from oeqa.selftest.base import oeSelfTest | ||
10 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
11 | from oeqa.utils.decorators import testcase | ||
12 | from oeqa.utils.network import get_free_port | ||
13 | |||
14 | class BitbakePrTests(oeSelfTest): | ||
15 | |||
16 | @classmethod | ||
17 | def setUpClass(cls): | ||
18 | cls.pkgdata_dir = get_bb_var('PKGDATA_DIR') | ||
19 | |||
20 | def get_pr_version(self, package_name): | ||
21 | package_data_file = os.path.join(self.pkgdata_dir, 'runtime', package_name) | ||
22 | package_data = ftools.read_file(package_data_file) | ||
23 | find_pr = re.search("PKGR: r[0-9]+\.([0-9]+)", package_data) | ||
24 | self.assertTrue(find_pr, "No PKG revision found in %s" % package_data_file) | ||
25 | return int(find_pr.group(1)) | ||
26 | |||
27 | def get_task_stamp(self, package_name, recipe_task): | ||
28 | stampdata = get_bb_var('STAMP', target=package_name).split('/') | ||
29 | prefix = stampdata[-1] | ||
30 | package_stamps_path = "/".join(stampdata[:-1]) | ||
31 | stamps = [] | ||
32 | for stamp in os.listdir(package_stamps_path): | ||
33 | find_stamp = re.match("%s\.%s\.([a-z0-9]{32})" % (re.escape(prefix), recipe_task), stamp) | ||
34 | if find_stamp: | ||
35 | stamps.append(find_stamp.group(1)) | ||
36 | self.assertFalse(len(stamps) == 0, msg="Cound not find stamp for task %s for recipe %s" % (recipe_task, package_name)) | ||
37 | self.assertFalse(len(stamps) > 1, msg="Found multiple %s stamps for the %s recipe in the %s directory." % (recipe_task, package_name, package_stamps_path)) | ||
38 | return str(stamps[0]) | ||
39 | |||
40 | def increment_package_pr(self, package_name): | ||
41 | inc_data = "do_package_append() {\n bb.build.exec_func('do_test_prserv', d)\n}\ndo_test_prserv() {\necho \"The current date is: %s\"\n}" % datetime.datetime.now() | ||
42 | self.write_recipeinc(package_name, inc_data) | ||
43 | res = bitbake(package_name, ignore_status=True) | ||
44 | self.delete_recipeinc(package_name) | ||
45 | self.assertEqual(res.status, 0, msg=res.output) | ||
46 | self.assertTrue("NOTE: Started PRServer with DBfile" in res.output, msg=res.output) | ||
47 | |||
48 | def config_pr_tests(self, package_name, package_type='rpm', pr_socket='localhost:0'): | ||
49 | config_package_data = 'PACKAGE_CLASSES = "package_%s"' % package_type | ||
50 | self.write_config(config_package_data) | ||
51 | config_server_data = 'PRSERV_HOST = "%s"' % pr_socket | ||
52 | self.append_config(config_server_data) | ||
53 | |||
54 | def run_test_pr_service(self, package_name, package_type='rpm', track_task='do_package', pr_socket='localhost:0'): | ||
55 | self.config_pr_tests(package_name, package_type, pr_socket) | ||
56 | |||
57 | self.increment_package_pr(package_name) | ||
58 | pr_1 = self.get_pr_version(package_name) | ||
59 | stamp_1 = self.get_task_stamp(package_name, track_task) | ||
60 | |||
61 | self.increment_package_pr(package_name) | ||
62 | pr_2 = self.get_pr_version(package_name) | ||
63 | stamp_2 = self.get_task_stamp(package_name, track_task) | ||
64 | |||
65 | self.assertTrue(pr_2 - pr_1 == 1, "Step between same pkg. revision is greater than 1") | ||
66 | self.assertTrue(stamp_1 != stamp_2, "Different pkg rev. but same stamp: %s" % stamp_1) | ||
67 | |||
68 | def run_test_pr_export_import(self, package_name, replace_current_db=True): | ||
69 | self.config_pr_tests(package_name) | ||
70 | |||
71 | self.increment_package_pr(package_name) | ||
72 | pr_1 = self.get_pr_version(package_name) | ||
73 | |||
74 | exported_db_path = os.path.join(self.builddir, 'export.inc') | ||
75 | export_result = runCmd("bitbake-prserv-tool export %s" % exported_db_path, ignore_status=True) | ||
76 | self.assertEqual(export_result.status, 0, msg="PR Service database export failed: %s" % export_result.output) | ||
77 | |||
78 | if replace_current_db: | ||
79 | current_db_path = os.path.join(get_bb_var('PERSISTENT_DIR'), 'prserv.sqlite3') | ||
80 | self.assertTrue(os.path.exists(current_db_path), msg="Path to current PR Service database is invalid: %s" % current_db_path) | ||
81 | os.remove(current_db_path) | ||
82 | |||
83 | import_result = runCmd("bitbake-prserv-tool import %s" % exported_db_path, ignore_status=True) | ||
84 | os.remove(exported_db_path) | ||
85 | self.assertEqual(import_result.status, 0, msg="PR Service database import failed: %s" % import_result.output) | ||
86 | |||
87 | self.increment_package_pr(package_name) | ||
88 | pr_2 = self.get_pr_version(package_name) | ||
89 | |||
90 | self.assertTrue(pr_2 - pr_1 == 1, "Step between same pkg. revision is greater than 1") | ||
91 | |||
92 | @testcase(930) | ||
93 | def test_import_export_replace_db(self): | ||
94 | self.run_test_pr_export_import('m4') | ||
95 | |||
96 | @testcase(931) | ||
97 | def test_import_export_override_db(self): | ||
98 | self.run_test_pr_export_import('m4', replace_current_db=False) | ||
99 | |||
100 | @testcase(932) | ||
101 | def test_pr_service_rpm_arch_dep(self): | ||
102 | self.run_test_pr_service('m4', 'rpm', 'do_package') | ||
103 | |||
104 | @testcase(934) | ||
105 | def test_pr_service_deb_arch_dep(self): | ||
106 | self.run_test_pr_service('m4', 'deb', 'do_package') | ||
107 | |||
108 | @testcase(933) | ||
109 | def test_pr_service_ipk_arch_dep(self): | ||
110 | self.run_test_pr_service('m4', 'ipk', 'do_package') | ||
111 | |||
112 | @testcase(935) | ||
113 | def test_pr_service_rpm_arch_indep(self): | ||
114 | self.run_test_pr_service('xcursor-transparent-theme', 'rpm', 'do_package') | ||
115 | |||
116 | @testcase(937) | ||
117 | def test_pr_service_deb_arch_indep(self): | ||
118 | self.run_test_pr_service('xcursor-transparent-theme', 'deb', 'do_package') | ||
119 | |||
120 | @testcase(936) | ||
121 | def test_pr_service_ipk_arch_indep(self): | ||
122 | self.run_test_pr_service('xcursor-transparent-theme', 'ipk', 'do_package') | ||
123 | |||
124 | @testcase(1419) | ||
125 | def test_stopping_prservice_message(self): | ||
126 | port = get_free_port() | ||
127 | |||
128 | runCmd('bitbake-prserv --host localhost --port %s --loglevel=DEBUG --start' % port) | ||
129 | ret = runCmd('bitbake-prserv --host localhost --port %s --loglevel=DEBUG --stop' % port) | ||
130 | |||
131 | self.assertEqual(ret.status, 0) | ||
132 | |||