Skip to content

Commit 440d0f8

Browse files
author
Alexandre Lissy
committed
Bug 2031290 - Enterprise: PackageKit DBus handling for Updates
1 parent b34f224 commit 440d0f8

23 files changed

Lines changed: 3669 additions & 85 deletions

python/sites/mach.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pth:tools/moztreedocs
5656
pth:xpcom/ds/tools
5757
pth:xpcom/geckoprocesstypes_generator
5858
pth:xpcom/idl-parser
59+
pypi-optional:dbus-python==1.3.2:linux
5960
# glean-sdk may not be installable if a wheel isn't available
6061
# and it has to be built from source.
6162
pypi-optional:glean-sdk==68.0.0:telemetry will not be collected
@@ -64,6 +65,7 @@ pypi-optional:orjson>=3.10:json operations will be slower in various tools
6465
# We aren't (yet) able to pin packages in automation, so we have to
6566
# support down to the oldest locally-installed version (5.4.2).
6667
pypi-optional:psutil>=5.4.2:telemetry will be missing some data
68+
pypi-optional:python-dbusmock==0.32.2:linux
6769
pypi-optional:rtoml>=0.11.0:toml operations will be slower in various tools
6870
pypi-optional:zstandard>=0.11.1,<=0.25.0:zstd archives will not be possible to extract
6971
vendored-fallback:pyyaml:third_party/python/pyyaml/lib/:faster native loading is disabled

taskcluster/kinds/test/kind.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ task-defaults:
9292
default:
9393
- linux64-minidump-stackwalk
9494
- linux64-fix-stacks
95+
- linux-python-dbusmock
9596
- linux64-2404-dbus-python

taskcluster/kinds/test/marionette.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ task-defaults:
2222
- marionette/windows_taskcluster_config.py
2323
linux.*:
2424
- marionette/prod_config.py
25-
- unittests/linux_dbus-python.py
2625
- remove_executables.py
2726
default:
2827
- marionette/prod_config.py
@@ -154,6 +153,11 @@ marionette-enterprise:
154153
windows.*:
155154
- marionette/windows_taskcluster_config.py
156155
- marionette/enterprise_config.py
156+
linux.*:
157+
- marionette/prod_config.py
158+
- marionette/enterprise_config.py
159+
- unittests/linux_dbus-python.py
160+
- remove_executables.py
157161
default:
158162
- marionette/prod_config.py
159163
- marionette/enterprise_config.py

testing/enterprise/test_felt_updates_apply.py renamed to testing/enterprise/felt_updates.py

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,12 @@
88
import sys
99
import time
1010

11-
import mozversion
12-
import requests
13-
1411
sys.path.append(os.path.dirname(__file__))
1512

1613
from felt_tests import FeltTests
1714

1815

19-
class FeltUpdatesApplyFromFelt(FeltTests):
20-
EXTRA_PREFS = {
21-
"app.update.log": True,
22-
"app.update.disabledForTesting": False,
23-
"app.update.BITS.enabled": False,
24-
"enterprise.felt_tests.is_updates_testing": True,
25-
"enterprise.felt_tests.read_update_url_from_prefs": True,
26-
}
27-
28-
def setup(self):
29-
self._logger.info("Enabling updates")
30-
version_info = mozversion.get_version(binary=self._driver.instance.binary)
31-
requests.post(
32-
f"http://localhost:{self.console_port}/api/browser/updates",
33-
data=version_info,
34-
)
35-
self._logger.info(f"Version: {version_info}")
36-
self._logger.info("Updates ready")
37-
super().setup()
38-
16+
class FeltUpdatesBase(FeltTests):
3917
def get_update_config_file_path(self):
4018
self._driver.set_context("chrome")
4119
rv = self._driver.execute_script(
@@ -47,30 +25,55 @@ def get_update_config_file_path(self):
4725
self._driver.set_context("content")
4826
return rv
4927

50-
def test_felt_updates_apply_from_felt(self):
51-
self._update_root = os.path.dirname(self.get_update_config_file_path())
28+
def get_latest_update_from_history(self):
29+
with self._driver.using_context(self._driver.CONTEXT_CHROME):
30+
result = self._driver.execute_async_script("""
31+
const callback = arguments[arguments.length - 1];
32+
Cc["@mozilla.org/updates/update-manager;1"]
33+
.getService(Ci.nsIUpdateManager)
34+
.getHistory()
35+
.then(history => callback(history[0]))
36+
.catch(err => callback({ error: err.toString() }));
37+
""")
38+
39+
assert "error" not in result, f"UpdateManager failed: {result.get('error')}"
40+
return result
41+
42+
def assert_latest_update_url(self, state, expected_start, expected_end):
43+
update_data = self.get_latest_update_from_history()
44+
45+
assert update_data is not None, "Update data payload is missing."
46+
assert update_data["state"] == state, (
47+
f"Update state {update_data['state']} is not the expected state {state}"
48+
)
5249

53-
self._logger.info("Updates ready: running tests")
54-
self.run_verify_update_ui()
55-
self.run_verify_update_check_run()
56-
# This is required since in marionette we use MAR that are not signed
57-
# so we cannot reach the real restart point
58-
# We also cannot close the window without loosing our Marionette access
59-
with self._driver.using_prefs({
60-
"enterprise.felt.previousBuildID": "20250701120000"
61-
}):
62-
self.reload_chrome_window()
63-
self.run_verify_update_applied()
50+
patch = update_data.get("selectedPatch", {})
51+
assert patch is not None, "The update history entry does not contain any patch."
6452

65-
def teardown(self):
66-
self.run_updates_cleanup()
53+
url = patch.get("URL")
54+
# Split query string that does not matter
55+
final_url = patch.get("finalURL").split("?")[0]
6756

68-
self._logger.info("Disabling updates")
69-
requests.post(f"http://localhost:{self.console_port}/api/browser/updates")
57+
assert url is not None, "Patch is missing a URL descriptor."
58+
assert url == final_url, (
59+
f"URL mismatch: '{url}' does not equal finalURL '{final_url}'."
60+
)
61+
assert url.startswith(expected_start), (
62+
f"Expected URL to start with '{expected_start}', but got '{url}'."
63+
)
64+
assert url.endswith(expected_end), (
65+
f"Expected URL to end with '{expected_end}', but got '{url}'."
66+
)
7067

68+
def run_felt_updates_apply(self):
7169
# We are not going to start the browser so do not try to close it
7270
self._manually_closed_child = True
73-
super().teardown()
71+
72+
self._update_root = os.path.dirname(self.get_update_config_file_path())
73+
74+
self._logger.info("Updates ready: running tests")
75+
self.run_verify_update_ui()
76+
self.run_verify_update_check_run()
7477

7578
def run_verify_update_ui(self):
7679
self._logger.info("Checking update UI ...")

testing/enterprise/manifest.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ run-if = [
5252
"buildapp == 'browser'", # open new tab
5353
]
5454

55+
["test_felt_browser_packagekit_no_firefox_update.py"]
56+
run-if = [
57+
"os == 'linux'",
58+
]
59+
60+
["test_felt_browser_packagekit_one_firefox_update.py"]
61+
run-if = [
62+
"os == 'linux'",
63+
]
64+
5565
["test_felt_browser_rapid_new_tabs_from_cli.py"]
5666
run-if = [
5767
"os == 'mac' && buildapp == 'browser'",
@@ -143,7 +153,12 @@ run-if = [
143153

144154
["test_felt_updater_errors.py"]
145155

146-
["test_felt_updates_apply.py"]
156+
["test_felt_updates_apply_from_packagekit.py"]
157+
run-if = [
158+
"os == 'linux'",
159+
]
160+
161+
["test_felt_updates_apply_from_updater.py"]
147162

148163
["test_felt_updates_basic.py"]
149164

0 commit comments

Comments
 (0)