diff options
Diffstat (limited to '')
-rw-r--r-- | python/mozrelease/test/data/Firefox-62.0.3.update.json | 74 | ||||
-rw-r--r-- | python/mozrelease/test/data/Firefox-62.0b11-update.json | 74 | ||||
-rw-r--r-- | python/mozrelease/test/data/Firefox-64.0b13.update.json | 9 | ||||
-rw-r--r-- | python/mozrelease/test/data/buglist_changesets.json | 94 | ||||
-rw-r--r-- | python/mozrelease/test/data/sample-update-verify.cfg | 4 | ||||
-rw-r--r-- | python/mozrelease/test/data/whatsnew-62.0.3.yml | 65 | ||||
-rw-r--r-- | python/mozrelease/test/data/whatsnew-release.yml | 65 | ||||
-rw-r--r-- | python/mozrelease/test/python.toml | 10 | ||||
-rw-r--r-- | python/mozrelease/test/test_balrog.py | 54 | ||||
-rw-r--r-- | python/mozrelease/test/test_buglist_creator.py | 178 | ||||
-rw-r--r-- | python/mozrelease/test/test_update_verify.py | 425 | ||||
-rw-r--r-- | python/mozrelease/test/test_versions.py | 120 |
12 files changed, 1172 insertions, 0 deletions
diff --git a/python/mozrelease/test/data/Firefox-62.0.3.update.json b/python/mozrelease/test/data/Firefox-62.0.3.update.json new file mode 100644 index 0000000000..c22cf42753 --- /dev/null +++ b/python/mozrelease/test/data/Firefox-62.0.3.update.json @@ -0,0 +1,74 @@ +[ + { + "fields": { + "detailsURL": "https://www.mozilla.org/%LOCALE%/firefox/62.0.3/releasenotes/", + "type": "minor" + }, + "for": {} + }, + { + "fields": { + "actions": "showURL", + "openURL": "https://www.mozilla.org/%LOCALE%/firefox/62.0.3/whatsnew/?oldversion=%OLD_VERSION%" + }, + "for": { + "channels": [ + "release", + "release-localtest", + "release-cdntest" + ], + "locales": [ + "cak", + "cy", + "da", + "de", + "dsb", + "en-CA", + "en-US", + "es-AR", + "es-CL", + "es-ES", + "es-MX", + "et", + "fa", + "fi", + "fr", + "fy-NL", + "gn", + "gu-IN", + "hsb", + "hu", + "ia", + "id", + "it", + "ja", + "ja-JP-mac", + "ka", + "kab", + "ko", + "lij", + "lt", + "ms", + "nb-NO", + "nl", + "nn-NO", + "pl", + "pt-BR", + "pt-PT", + "sk", + "sl", + "sq", + "sr", + "sv-SE", + "tr", + "uk", + "vi", + "zh-CN", + "zh-TW" + ], + "versions": [ + "<62.0" + ] + } + } +] diff --git a/python/mozrelease/test/data/Firefox-62.0b11-update.json b/python/mozrelease/test/data/Firefox-62.0b11-update.json new file mode 100644 index 0000000000..c22cf42753 --- /dev/null +++ b/python/mozrelease/test/data/Firefox-62.0b11-update.json @@ -0,0 +1,74 @@ +[ + { + "fields": { + "detailsURL": "https://www.mozilla.org/%LOCALE%/firefox/62.0.3/releasenotes/", + "type": "minor" + }, + "for": {} + }, + { + "fields": { + "actions": "showURL", + "openURL": "https://www.mozilla.org/%LOCALE%/firefox/62.0.3/whatsnew/?oldversion=%OLD_VERSION%" + }, + "for": { + "channels": [ + "release", + "release-localtest", + "release-cdntest" + ], + "locales": [ + "cak", + "cy", + "da", + "de", + "dsb", + "en-CA", + "en-US", + "es-AR", + "es-CL", + "es-ES", + "es-MX", + "et", + "fa", + "fi", + "fr", + "fy-NL", + "gn", + "gu-IN", + "hsb", + "hu", + "ia", + "id", + "it", + "ja", + "ja-JP-mac", + "ka", + "kab", + "ko", + "lij", + "lt", + "ms", + "nb-NO", + "nl", + "nn-NO", + "pl", + "pt-BR", + "pt-PT", + "sk", + "sl", + "sq", + "sr", + "sv-SE", + "tr", + "uk", + "vi", + "zh-CN", + "zh-TW" + ], + "versions": [ + "<62.0" + ] + } + } +] diff --git a/python/mozrelease/test/data/Firefox-64.0b13.update.json b/python/mozrelease/test/data/Firefox-64.0b13.update.json new file mode 100644 index 0000000000..0d9a4405e5 --- /dev/null +++ b/python/mozrelease/test/data/Firefox-64.0b13.update.json @@ -0,0 +1,9 @@ +[ + { + "fields": { + "detailsURL": "https://www.mozilla.org/%LOCALE%/firefox/64.0/releasenotes/", + "type": "minor" + }, + "for": {} + } +] diff --git a/python/mozrelease/test/data/buglist_changesets.json b/python/mozrelease/test/data/buglist_changesets.json new file mode 100644 index 0000000000..dedcd8a810 --- /dev/null +++ b/python/mozrelease/test/data/buglist_changesets.json @@ -0,0 +1,94 @@ +{ + "entries": [ + { + "desc": "Bug 1354038 - [push-apk] taskgraph: Use rollout and deactivate dry-run on release p=jlorenzo r=aki a=release DONTBUILD" + }, + { + "desc": "Bug 1356563 - Only set global ready state on native widget loading; r=snorp a=sylvestre\n\nOur \"chrome-document-loaded\" observer may detect several different types\nof widgets that can exist in the parent process, including the Android\nnsWindow, PuppetWidget, etc. We should only set the global state to\nready when the first top-level nsWindow has loaded, and not just any\nwindow." + }, + { + "desc": "No bug, Automated blocklist update from host bld-linux64-spot-305 - a=blocklist-update" + }, + { + "desc": "Automatic version bump. CLOSED TREE NO BUG a=release" + }, + { + "desc": "No bug - Tagging d345b657d381ade5195f1521313ac651618f54a2 with FIREFOX_53_0_BUILD6, FIREFOX_53_0_RELEASE a=release CLOSED TREE" + }, + { + "desc": "No bug, Automated blocklist update from host bld-linux64-spot-305 - a=blocklist-update" + }, + { + "desc": "Bug 1344529 - Remove unused variable in widget/gtk/gtk2drawing.c. r=frg a=release DONOTBUILD in a CLOSED TREE" + }, + { + "desc": "Bug 1306543 - Avoid using g_unicode_script_from_iso15924 directly. r=jfkthame a=release in a CLOSED TREE DONTBUILD" + }, + { + "desc": "Bug 1320072 - Backout intent change - broke partner Google test. r=snorp, a=lizzard" + }, + { + "desc": "Bug 1328762 - Cherry-pick ANGLE a4aaa2de57dc51243da35ea147d289a21a9f0c49. a=lizzard\n\nMozReview-Commit-ID: WVK0smAfAW" + }, + { + "desc": "Bug 1341190 - Remove .popup-anchor visibility rule. r=mconley, a=lizzard\n\nMozReview-Commit-ID: DFMIKMMnLx5" + }, + { + "desc": "Bug 1348409 - Stop supporting the showDialog argument for window.find. r=mrbkap, a=lizzard\n\nThe dialog functionality of the non-standard window.find API has been broken\nwith e10s since it shipped, and bug 1182569 or bug 1232432 (or both) have\nbroken it for non-e10s.\n\nThis patch remove showDialog support entirely, for both e10s and non-e10s,\nin a more deliberate way. We now ignore the argument.\n\nMozReview-Commit-ID: 1CTzgEkDhHW" + }, + { + "desc": "Bug 1358089 - [RTL] Separate xml drawable into v17 folder. r=ahunt, a=lizzard\n\nMozReview-Commit-ID: LaOwxXwhsHA" + }, + { + "desc": "Bug 1360626 - Create a blacklist for adaptive playback support. r=jolin, a=lizzard\n\nOn some devices / os combinations, enabling adaptive playback causes decoded frame unusable.\nIt may cause the decode frame to be black and white or return tiled frames.\nSo we should do the blacklist according to the report.\n\nMozReview-Commit-ID: j3PZXTtkXG" + }, + { + "desc": "Bug 1354038 - part2: [push-apk] taskgraph: Use rollout and deactivate dry-run on release r=aki a=bustage DONTBUILD\n\nMozReview-Commit-ID: 1f22BcAZkvp" + }, + { + "desc": "bug 1354038 - empty commit to force builds. a=release" + }, + { + "desc": "Bug 1337861 - [Fennec-Relpro] Enforce the presence of $MOZ_BUILD_DATE r=jlund a=release\n\nMozReview-Commit-ID: DzEeeYQjwLW" + }, + { + "desc": "Bug 1332731 - Follow-up to fix accessibility breakage. r=sebastian, a=lizzard\n\nFollow-up to fix breakage in accessibility caused by the bundle\nconversion. In particular, optString(foo) should have been converted to\ngetString(foo, \"\") because optString returns \"\" by default.\n\nAlso fix a small bug in Presentation.jsm where an array or null should\nbe used instead of a string." + }, + { + "desc": "Bug 1355870 - Allow a system preference to determine distribution dir. r=nalexander, a=lizzard" + }, + { + "desc": "Bug 1354911 - Guard against null menu item names. r=sebastian, a=lizzard\n\nAddons may give us invalid menu item names; bail instead of crashing in\nsuch cases." + }, + { + "desc": "Bug 1356563 - Remove chrome-document-loaded observer only after handling it. r=me, a=gchang\n\nOnly remove the \"chrome-document-loaded\" observer after handling it in\nnsAppShell. Otherwise we may never end up handling it." + }, + { + "desc": "Bug 1352333 - remove autophone webrtc test manifests, r=dminor, a=test-only." + }, + { + "desc": "Bug 1352333 - sync autophone webrtc test manifests with normal webrtc manifests, r=jmaher,dminor, a=test-only." + }, + { + "desc": "No bug - Tagging f239279b709072490993b099832fa8c18f07713a with FENNEC_53_0_BUILD1, FENNEC_53_0_RELEASE a=release CLOSED TREE" + }, + { + "desc": "Automated checkin: version bump for fennec 53.0.1 release. DONTBUILD CLOSED TREE a=release" + }, + { + "desc": "Added FENNEC_53_0_1_RELEASE FENNEC_53_0_1_BUILD1 tag(s) for changeset f029d1a1324b. DONTBUILD CLOSED TREE a=release" + }, + { + "desc": "Backout Bug 1337861 (Enforce MOZ_BUILD_DATE) due to Bug 1360550. r=catlee a=catlee\n\nBug 1360550 resulted in the buildid the Linux builds had being different than the directory they were uploaded to. This had fallout affects for QA's firefox-ui tests and presumably anything using mozdownload.\n\nMozReview-Commit-ID: 8lMvLU0vGiS" + }, + { + "desc": "No bug, Automated blocklist update from host bld-linux64-spot-303 - a=blocklist-update" + }, + { + "desc": "Automatic version bump. CLOSED TREE NO BUG a=release" + }, + { + "desc": "No bug - Tagging 5cbf464688a47129c0ea36fe38f42f59926e4b2c with FENNEC_53_0_1_BUILD2, FENNEC_53_0_1_RELEASE a=release CLOSED TREE" + } + ] +} diff --git a/python/mozrelease/test/data/sample-update-verify.cfg b/python/mozrelease/test/data/sample-update-verify.cfg new file mode 100644 index 0000000000..b8c87457b5 --- /dev/null +++ b/python/mozrelease/test/data/sample-update-verify.cfg @@ -0,0 +1,4 @@ +release="4.0" product="Firefox" platform="Linux_x86-gcc3" build_id="888" locales="af de en-US ja zh-TW" channel="betatest" patch_types="partial complete" from="/firefox/4.0rc1.tar.bz2" aus_server="https://aus4.mozilla.org" ftp_server_from="stage.mozilla.org/firefox" ftp_server_to="stage.mozilla.org/firefox" to="/firefox/4.0rc2.tar.bz2" mar_channel_IDs="firefox-mozilla-beta" to_build_id="999" to_display_version="99.0 Zeta 9" to_app_version="99.0" +release="4.0b12" product="Firefox" platform="Linux_x86-gcc3" build_id="777" locales="af en-US" channel="betatest" patch_types="complete" from="/firefox/4.0b12.tar.bz2" ftp_server_from="stage.mozilla.org/firefox" ftp_server_to="stage.mozilla.org/firefox" +release="4.0b12" product="Firefox" platform="Linux_x86-gcc3" build_id="777" locales="de ja zh-TW" channel="betatest" patch_types="complete" ftp_server_from="stage.mozilla.org/firefox" ftp_server_to="stage.mozilla.org/firefox" +release="3.7a1" product="Firefox" platform="Linux_x86-gcc3" build_id="666" locales="en-US" channel="betatest" patch_types="complete" ftp_server_from="stage.mozilla.org/firefox" ftp_server_to="stage.mozilla.org/firefox" diff --git a/python/mozrelease/test/data/whatsnew-62.0.3.yml b/python/mozrelease/test/data/whatsnew-62.0.3.yml new file mode 100644 index 0000000000..5a9e4c9a1f --- /dev/null +++ b/python/mozrelease/test/data/whatsnew-62.0.3.yml @@ -0,0 +1,65 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +--- +- type: product-details + url: "https://www.mozilla.org/%LOCALE%/{product}/{version}/releasenotes/" +# %LOCALE% is automatically replaced by Balrog. +- type: show-url + # yamllint disable-line rule:line-length + url: "https://www.mozilla.org/%LOCALE%/{product}/{version}/whatsnew/?oldversion=%OLD_VERSION%" + conditions: + release-types: [release] + products: [firefox] + update-channel: release + # e.g.: ["<61.0"]. {version.major_number} reflects the current version. + # This is done by taskgraph. + versions: ["<{version.major_number}.0"] + locales: + - cak + - cy + - da + - de + - dsb + - en-CA + - en-US + - es-AR + - es-CL + - es-ES + - es-MX + - et + - fa + - fi + - fr + - fy-NL + - gn + - gu-IN + - hsb + - hu + - ia + - id + - it + - ja + - ja-JP-mac + - ka + - kab + - ko + - lij + - lt + - ms + - nb-NO + - nl + - nn-NO + - pl + - pt-BR + - pt-PT + - sk + - sl + - sq + - sr + - sv-SE + - tr + - uk + - vi + - zh-CN + - zh-TW diff --git a/python/mozrelease/test/data/whatsnew-release.yml b/python/mozrelease/test/data/whatsnew-release.yml new file mode 100644 index 0000000000..5a9e4c9a1f --- /dev/null +++ b/python/mozrelease/test/data/whatsnew-release.yml @@ -0,0 +1,65 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +--- +- type: product-details + url: "https://www.mozilla.org/%LOCALE%/{product}/{version}/releasenotes/" +# %LOCALE% is automatically replaced by Balrog. +- type: show-url + # yamllint disable-line rule:line-length + url: "https://www.mozilla.org/%LOCALE%/{product}/{version}/whatsnew/?oldversion=%OLD_VERSION%" + conditions: + release-types: [release] + products: [firefox] + update-channel: release + # e.g.: ["<61.0"]. {version.major_number} reflects the current version. + # This is done by taskgraph. + versions: ["<{version.major_number}.0"] + locales: + - cak + - cy + - da + - de + - dsb + - en-CA + - en-US + - es-AR + - es-CL + - es-ES + - es-MX + - et + - fa + - fi + - fr + - fy-NL + - gn + - gu-IN + - hsb + - hu + - ia + - id + - it + - ja + - ja-JP-mac + - ka + - kab + - ko + - lij + - lt + - ms + - nb-NO + - nl + - nn-NO + - pl + - pt-BR + - pt-PT + - sk + - sl + - sq + - sr + - sv-SE + - tr + - uk + - vi + - zh-CN + - zh-TW diff --git a/python/mozrelease/test/python.toml b/python/mozrelease/test/python.toml new file mode 100644 index 0000000000..fc971f1f81 --- /dev/null +++ b/python/mozrelease/test/python.toml @@ -0,0 +1,10 @@ +[DEFAULT] +subsuite = "mozrelease" + +["test_balrog.py"] + +["test_buglist_creator.py"] + +["test_update_verify.py"] + +["test_versions.py"] diff --git a/python/mozrelease/test/test_balrog.py b/python/mozrelease/test/test_balrog.py new file mode 100644 index 0000000000..0c3adfacac --- /dev/null +++ b/python/mozrelease/test/test_balrog.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import json +from pathlib import Path + +import mozunit +import pytest +from mozilla_version.gecko import GeckoVersion + +from mozrelease.balrog import generate_update_properties +from mozrelease.util import load as yaml_load + +DATA_PATH = Path(__file__).parent.joinpath("data") + + +@pytest.mark.parametrize( + "context,config_file,output_file", + [ + ( + { + "release-type": "release", + "product": "firefox", + "version": GeckoVersion.parse("62.0.3"), + }, + "whatsnew-62.0.3.yml", + "Firefox-62.0.3.update.json", + ), + ( + { + "release-type": "beta", + "product": "firefox", + "version": GeckoVersion.parse("64.0"), + }, + "whatsnew-62.0.3.yml", + "Firefox-64.0b13.update.json", + ), + ], +) +def test_update_properties(context, config_file, output_file): + with DATA_PATH.joinpath(config_file).open("r", encoding="utf-8") as f: + config = yaml_load(f) + + update_line = generate_update_properties(context, config) + + assert update_line == json.load( + DATA_PATH.joinpath(output_file).open("r", encoding="utf-8") + ) + + +if __name__ == "__main__": + mozunit.main() diff --git a/python/mozrelease/test/test_buglist_creator.py b/python/mozrelease/test/test_buglist_creator.py new file mode 100644 index 0000000000..03c76b1d8a --- /dev/null +++ b/python/mozrelease/test/test_buglist_creator.py @@ -0,0 +1,178 @@ +# -*- coding: utf-8 -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# -*- coding: utf-8 -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import json +from pathlib import Path + +import mozunit +import pytest +from mozilla_version.gecko import GeckoVersion + +from mozrelease.buglist_creator import ( + create_bugs_url, + get_bugs_in_changeset, + get_previous_tag_version, + is_backout_bug, + is_excluded_change, + parse_tag_version, + tag_version, +) + +DATA_PATH = Path(__file__).with_name("data") + + +def test_beta_1_release(): + buglist_str_54_0b1 = create_bugs_url( + product="firefox", + current_version=GeckoVersion.parse("54.0b1"), + current_revision="cf76e00dcd6f", + ) + assert buglist_str_54_0b1 == "", "There should be no bugs to compare for beta 1." + + +@pytest.mark.parametrize( + "description,is_excluded", + ( + ( + "something something something a=test-only something something something", + True, + ), + ("this is a a=release change!", True), + ), +) +def test_is_excluded_change(description, is_excluded): + assert is_excluded_change({"desc": description}) == is_excluded + + +@pytest.mark.parametrize( + "description,is_backout", + ( + ("I backed out this bug because", True), + ("Backing out this bug due to", True), + ("Backout bug xyz", True), + ("Back out bug xyz", True), + ("this is a regular bug description", False), + ), +) +def test_is_backout_bug(description, is_backout): + assert is_backout_bug(description) == is_backout + + +@pytest.mark.parametrize( + "product,version,tag", + ( + ("firefox", GeckoVersion.parse("53.0b10"), "FIREFOX_53_0b10_RELEASE"), + ("firefox", GeckoVersion.parse("52.0"), "FIREFOX_52_0_RELEASE"), + ("fennec", GeckoVersion.parse("52.0.2"), "FENNEC_52_0_2_RELEASE"), + ), +) +def test_tag_version(product, version, tag): + assert tag_version(product, version) == tag + + +@pytest.mark.parametrize( + "tag,version", + ( + ("FIREFOX_53_0b10_RELEASE", GeckoVersion.parse("53.0b10")), + ("FIREFOX_52_0_RELEASE", GeckoVersion.parse("52.0")), + ("FENNEC_52_0_2_RELEASE", GeckoVersion.parse("52.0.2")), + ), +) +def test_parse_tag_version(tag, version): + assert parse_tag_version(tag) == version + + +@pytest.mark.parametrize( + "version,tag,previous_tag", + ( + ( + GeckoVersion.parse("48.0b4"), + "FIREFOX_48_0b4_RELEASE", + "FIREFOX_48_0b3_RELEASE", + ), + ( + GeckoVersion.parse("48.0b9"), + "FIREFOX_48_0b9_RELEASE", + "FIREFOX_48_0b7_RELEASE", + ), + ( + GeckoVersion.parse("48.0.2"), + "FIREFOX_48_0_2_RELEASE", + "FIREFOX_48_0_1_RELEASE", + ), + ( + GeckoVersion.parse("48.0.1"), + "FIREFOX_48_0_1_RELEASE", + "FIREFOX_48_0_RELEASE", + ), + ), +) +def test_get_previous_tag_version(version, tag, previous_tag): + product = "firefox" + ff_48_tags = [ + "FIREFOX_BETA_48_END", + "FIREFOX_RELEASE_48_END", + "FIREFOX_48_0_2_RELEASE", + "FIREFOX_48_0_2_BUILD1", + "FIREFOX_48_0_1_RELEASE", + "FIREFOX_48_0_1_BUILD3", + "FIREFOX_48_0_RELEASE", + "FIREFOX_48_0_BUILD2", + "FIREFOX_RELEASE_48_BASE", + "FIREFOX_48_0b10_RELEASE", + "FIREFOX_48_0b10_BUILD1", + "FIREFOX_48_0b9_RELEASE", + "FIREFOX_48_0b9_BUILD1", + "FIREFOX_48_0b7_RELEASE", + "FIREFOX_48_0b7_BUILD1", + "FIREFOX_48_0b6_RELEASE", + "FIREFOX_48_0b6_BUILD1", + "FIREFOX_48_0b5_RELEASE", + "FIREFOX_48_0b5_BUILD1", + "FIREFOX_48_0b4_RELEASE", + "FIREFOX_48_0b4_BUILD1", + "FIREFOX_48_0b3_RELEASE", + "FIREFOX_48_0b3_BUILD1", + "FIREFOX_48_0b2_RELEASE", + "FIREFOX_48_0b2_BUILD2", + "FIREFOX_48_0b1_RELEASE", + "FIREFOX_48_0b1_BUILD2", + "FIREFOX_AURORA_48_END", + "FIREFOX_BETA_48_BASE", + "FIREFOX_AURORA_48_BASE", + ] + + mock_hg_json = {"tags": [{"tag": ff_48_tag} for ff_48_tag in ff_48_tags]} + + assert get_previous_tag_version(product, version, tag, mock_hg_json) == previous_tag + + +def test_get_bugs_in_changeset(): + with DATA_PATH.joinpath("buglist_changesets.json").open("r") as fp: + changeset_data = json.load(fp) + bugs, backouts = get_bugs_in_changeset(changeset_data) + + assert bugs == { + "1356563", + "1348409", + "1341190", + "1360626", + "1332731", + "1328762", + "1355870", + "1358089", + "1354911", + "1354038", + } + assert backouts == {"1337861", "1320072"} + + +if __name__ == "__main__": + mozunit.main() diff --git a/python/mozrelease/test/test_update_verify.py b/python/mozrelease/test/test_update_verify.py new file mode 100644 index 0000000000..6f1cb197f7 --- /dev/null +++ b/python/mozrelease/test/test_update_verify.py @@ -0,0 +1,425 @@ +# -*- coding: utf-8 -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +import unittest +from pathlib import Path +from tempfile import mkstemp + +import mozunit + +from mozrelease.update_verify import UpdateVerifyConfig, UpdateVerifyError + +DATA_PATH = Path(__file__).with_name("data") + + +class TestUpdateVerifyConfig(unittest.TestCase): + config = str(DATA_PATH.joinpath("sample-update-verify.cfg")) + + def setUp(self): + self.uvc = UpdateVerifyConfig() + fd, self.tmpfilename = mkstemp() + self.tmpfile = os.fdopen(fd, "wb") + + def tearDown(self): + self.tmpfile.close() + os.unlink(self.tmpfilename) + + def testEq(self): + self.uvc.product = "foo" + self.uvc.channel = "betatest" + self.uvc.aus_server = "aus" + self.uvc.ftp_server_from = "ftp" + self.uvc.ftp_server_to = "ftp" + self.uvc.to = "/firefox/4.0rc2.tar.bz2" + self.uvc.mar_channel_IDs = "baz" + self.uvc.to_build_id = "999" + self.uvc.to_display_version = "99.0 Zeta 9" + self.uvc.to_app_version = "99.0" + uvc2 = UpdateVerifyConfig() + uvc2.product = "foo" + uvc2.channel = "betatest" + uvc2.aus_server = "aus" + uvc2.ftp_server_form = "ftp" + uvc2.ftp_server_to = "ftp" + uvc2.to = "/firefox/4.0rc2.tar.bz2" + uvc2.mar_channel_IDs = "baz" + uvc2.to_build_id = "999" + uvc2.to_display_version = "99.0 Zeta 9" + uvc2.to_app_version = "99.0" + self.assertEqual(self.uvc, uvc2) + + def testNe(self): + self.uvc.product = "foo" + uvc2 = UpdateVerifyConfig() + # assertNotEqual doesn't test the __ne__ function, so we do this + self.assertTrue(self.uvc != uvc2) + + def testAddRelease(self): + releases = [ + { + "release": "4.0", + "platform": "bar", + "build_id": 555, + "locales": ["af", "de"], + "patch_types": ["partial", "complete"], + "from": "/pub/firefox/foo.bz2", + "ftp_server_from": "from", + "ftp_server_to": "to", + "mar_channel_IDs": "firefox-mozilla-booyah", + "updater_package": None, + } + ] + self.uvc.addRelease( + "4.0", + build_id=555, + locales=["af", "de"], + patch_types=["partial", "complete"], + from_path="/pub/firefox/foo.bz2", + ftp_server_from="from", + ftp_server_to="to", + mar_channel_IDs="firefox-mozilla-booyah", + platform="bar", + ) + self.assertEqual(self.uvc.releases, releases) + + def testAddReleasesWithDifferentPlatforms(self): + releases = [ + { + "release": "4.0", + "platform": "WINNT_x86-msvc", + "build_id": 555, + "locales": ["af", "de"], + "patch_types": ["partial", "complete"], + "from": "/pub/firefox/foo.bz2", + "ftp_server_from": "from", + "ftp_server_to": "to", + "mar_channel_IDs": "firefox-mozilla-booyah", + "updater_package": None, + }, + { + "release": "5.0", + "platform": "WINNT_x86-msvc-x86", + "build_id": 666, + "locales": ["af", "de"], + "patch_types": ["partial", "complete"], + "from": "/pub/firefox/foo2.bz2", + "ftp_server_from": "from", + "ftp_server_to": "to", + "mar_channel_IDs": "firefox-mozilla-booyah", + "updater_package": None, + }, + ] + self.uvc.addRelease( + "4.0", + build_id=555, + locales=["af", "de"], + patch_types=["partial", "complete"], + from_path="/pub/firefox/foo.bz2", + ftp_server_from="from", + ftp_server_to="to", + mar_channel_IDs="firefox-mozilla-booyah", + platform="WINNT_x86-msvc", + ) + self.uvc.addRelease( + "5.0", + build_id=666, + locales=["af", "de"], + patch_types=["partial", "complete"], + from_path="/pub/firefox/foo2.bz2", + ftp_server_from="from", + ftp_server_to="to", + mar_channel_IDs="firefox-mozilla-booyah", + platform="WINNT_x86-msvc-x86", + ) + self.assertEqual(self.uvc.releases, releases) + + def testRead(self): + ftp_server_from = "stage.mozilla.org/firefox" + ftp_server_to = "stage.mozilla.org/firefox" + uvc2 = UpdateVerifyConfig() + uvc2.product = "Firefox" + uvc2.channel = "betatest" + uvc2.aus_server = "https://aus4.mozilla.org" + uvc2.to = "/firefox/4.0rc2.tar.bz2" + uvc2.to_build_id = "999" + uvc2.to_display_version = "99.0 Zeta 9" + uvc2.to_app_version = "99.0" + uvc2.addRelease( + "4.0", + build_id="888", + platform="Linux_x86-gcc3", + locales=["af", "de", "en-US", "ja", "zh-TW"], + patch_types=["partial", "complete"], + from_path="/firefox/4.0rc1.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + mar_channel_IDs="firefox-mozilla-beta", + ) + uvc2.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=["af", "en-US"], + from_path="/firefox/4.0b12.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + uvc2.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=["de", "ja", "zh-TW"], + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + uvc2.addRelease( + "3.7a1", + build_id="666", + locales=["en-US"], + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + platform="Linux_x86-gcc3", + ) + + self.uvc.read(self.config) + self.assertEqual(self.uvc, uvc2) + + def testWrite(self): + ftp_server_from = "stage.mozilla.org/firefox" + ftp_server_to = "stage.mozilla.org/firefox" + self.uvc.product = "Firefox" + self.uvc.channel = "betatest" + self.uvc.aus_server = "https://aus4.mozilla.org" + self.uvc.to = "/firefox/4.0rc2.tar.bz2" + self.uvc.to_build_id = "999" + self.uvc.to_display_version = "99.0 Zeta 9" + self.uvc.to_app_version = "99.0" + self.uvc.addRelease( + "4.0", + build_id="888", + platform="Linux_x86-gcc3", + locales=("af", "de", "en-US", "ja", "zh-TW"), + patch_types=("partial", "complete"), + from_path="/firefox/4.0rc1.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + mar_channel_IDs="firefox-mozilla-beta", + ) + self.uvc.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=["af", "en-US"], + from_path="/firefox/4.0b12.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + self.uvc.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=("de", "ja", "zh-TW"), + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + self.uvc.addRelease( + "3.7a1", + build_id="666", + locales=("en-US",), + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + platform="Linux_x86-gcc3", + ) + + self.uvc.write(self.tmpfile) + self.tmpfile.close() + self.assertEqual(open(self.config).read(), open(self.tmpfilename).read()) + + def testReadInvalidKey(self): + invalidLine = 'foo="bar"' + self.assertRaises(UpdateVerifyError, self.uvc._parseLine, invalidLine) + + def testReadDuplicateKey(self): + invalidLine = 'release="bar" release="blah"' + self.assertRaises(UpdateVerifyError, self.uvc._parseLine, invalidLine) + + def testParseLineBad(self): + invalidLine = "abh nthntuehonhuh nhhueont hntueoh nthouo" + self.assertRaises(UpdateVerifyError, self.uvc._parseLine, invalidLine) + + def testGetChunk(self): + ftp_server_from = "stage.mozilla.org/firefox" + ftp_server_to = "stage.mozilla.org/firefox" + self.uvc.read(self.config) + uvc2 = UpdateVerifyConfig() + uvc2.product = "Firefox" + uvc2.channel = "betatest" + uvc2.aus_server = "https://aus4.mozilla.org" + uvc2.to = "/firefox/4.0rc2.tar.bz2" + uvc2.to_build_id = "999" + uvc2.to_display_version = "99.0 Zeta 9" + uvc2.to_app_version = "99.0" + uvc2.addRelease( + "4.0", + build_id="888", + platform="Linux_x86-gcc3", + locales=["af", "de", "en-US"], + patch_types=["partial", "complete"], + from_path="/firefox/4.0rc1.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + mar_channel_IDs="firefox-mozilla-beta", + ) + uvc2.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=["de", "ja"], + patch_types=["complete"], + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + from_path=None, + ) + chunkedConfig = self.uvc.getChunk(chunks=3, thisChunk=1) + self.assertEqual(chunkedConfig, uvc2) + + def testGetChunkWithPathWithSpaces(self): + self.uvc.product = "Firefox" + self.uvc.channel = "betatest" + self.uvc.aus_server = "https://aus4.mozilla.org" + self.uvc.ftp_server_from = "stage.mozilla.org/firefox" + self.uvc.ftp_server_to = "stage.mozilla.org/firefox" + self.uvc.to = "/firefox/Firefox 4.0 Beta 2.exe" + self.uvc.to_build_id = "999" + self.uvc.to_display_version = "99.0 Zeta 9" + self.uvc.to_app_version = "99.0" + self.uvc.addRelease( + "4.0b1", + build_id="222", + platform="Linux_x86-gcc3", + locales=["en-US", "ja", "zh-TW"], + patch_types=["complete"], + from_path="/firefox/Firefox 4.0 Beta 1.exe", + ) + uvc2 = UpdateVerifyConfig() + uvc2.product = "Firefox" + uvc2.channel = "betatest" + uvc2.aus_server = "https://aus4.mozilla.org" + uvc2.ftp_server_from = "stage.mozilla.org/firefox" + uvc2.ftp_server_to = "stage.mozilla.org/firefox" + uvc2.to = "/firefox/Firefox 4.0 Beta 2.exe" + uvc2.to_build_id = "999" + uvc2.to_display_version = "99.0 Zeta 9" + uvc2.to_app_version = "99.0" + uvc2.addRelease( + "4.0b1", + build_id="222", + platform="Linux_x86-gcc3", + locales=["en-US", "ja"], + patch_types=["complete"], + from_path="/firefox/Firefox 4.0 Beta 1.exe", + ) + chunkedConfig = self.uvc.getChunk(chunks=2, thisChunk=1) + self.assertEqual(chunkedConfig, uvc2) + + def testAddLocaleToRelease(self): + from_path = "/firefox/4.0rc1.tar.bz2" + self.uvc.read(self.config) + self.uvc.addLocaleToRelease("888", "he", from_path) + self.assertEqual( + self.uvc.getRelease("888", from_path)["locales"], + ["af", "de", "en-US", "he", "ja", "zh-TW"], + ) + + def testAddLocaleToReleaseMultipleBuildIDs(self): + from_path = None + self.uvc.read(self.config) + self.uvc.addLocaleToRelease("777", "he", from_path) + self.assertEqual( + self.uvc.getRelease("777", from_path)["locales"], + ["de", "he", "ja", "zh-TW"], + ) + + def testAddLocaleToNonexistentRelease(self): + self.uvc.read(self.config) + self.assertRaises(UpdateVerifyError, self.uvc.addLocaleToRelease, "123", "he") + + def testGetReleaseNonexistenceRelease(self): + self.uvc.read(self.config) + self.assertEqual(self.uvc.getRelease("123", None), {}) + + def testGetFullReleaseTests(self): + ftp_server_from = "stage.mozilla.org/firefox" + ftp_server_to = "stage.mozilla.org/firefox" + self.uvc.read(self.config) + uvc2 = UpdateVerifyConfig() + uvc2.product = "Firefox" + uvc2.channel = "betatest" + uvc2.aus_server = "https://aus4.mozilla.org" + uvc2.to = "/firefox/4.0rc2.tar.bz2" + uvc2.to_build_id = "999" + uvc2.to_display_version = "99.0 Zeta 9" + uvc2.to_app_version = "99.0" + uvc2.addRelease( + "4.0", + build_id="888", + platform="Linux_x86-gcc3", + locales=["af", "de", "en-US", "ja", "zh-TW"], + patch_types=["partial", "complete"], + from_path="/firefox/4.0rc1.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + mar_channel_IDs="firefox-mozilla-beta", + ) + uvc2.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=["af", "en-US"], + patch_types=["complete"], + from_path="/firefox/4.0b12.tar.bz2", + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + self.assertEqual(self.uvc.getFullReleaseTests(), uvc2.releases) + + def testGetQuickReleaseTests(self): + ftp_server_from = "stage.mozilla.org/firefox" + ftp_server_to = "stage.mozilla.org/firefox" + self.uvc.read(self.config) + uvc2 = UpdateVerifyConfig() + uvc2.product = "Firefox" + uvc2.channel = "betatest" + uvc2.aus_server = "https://aus4.mozilla.org" + uvc2.to = "/firefox/4.0rc2.tar.bz2" + uvc2.to_build_id = "999" + uvc2.to_display_version = "99.0 Zeta 9" + uvc2.to_app_version = "99.0" + uvc2.addRelease( + "4.0b12", + build_id="777", + platform="Linux_x86-gcc3", + locales=["de", "ja", "zh-TW"], + patch_types=["complete"], + from_path=None, + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + uvc2.addRelease( + "3.7a1", + build_id="666", + platform="Linux_x86-gcc3", + locales=["en-US"], + patch_types=["complete"], + from_path=None, + ftp_server_from=ftp_server_from, + ftp_server_to=ftp_server_to, + ) + self.assertEqual(self.uvc.getQuickReleaseTests(), uvc2.releases) + + +if __name__ == "__main__": + mozunit.main() diff --git a/python/mozrelease/test/test_versions.py b/python/mozrelease/test/test_versions.py new file mode 100644 index 0000000000..eaf7d653db --- /dev/null +++ b/python/mozrelease/test/test_versions.py @@ -0,0 +1,120 @@ +import mozunit +import pytest + +from mozrelease.versions import ( + AncientMozillaVersion, + ModernMozillaVersion, + MozillaVersion, +) + +ALL_VERSIONS = [ # Keep this sorted + "3.0", + "3.0.1", + "3.0.2", + "3.0.3", + "3.0.4", + "3.0.5", + "3.0.6", + "3.0.7", + "3.0.8", + "3.0.9", + "3.0.10", + "3.0.11", + "3.0.12", + "3.0.13", + "3.0.14", + "3.0.15", + "3.0.16", + "3.0.17", + "3.0.18", + "3.0.19", + "3.1b1", + "3.1b2", + "3.1b3", + "3.5b4", + "3.5b99", + "3.5rc1", + "3.5rc2", + "3.5rc3", + "3.5", + "3.5.1", + "3.5.2", + "3.5.3", + "3.5.4", + "3.5.5", + "3.5.6", + "3.5.7", + "3.5.8", + "3.5.9", + "3.5.10", + # ... Start skipping around... + "4.0b9", + "10.0.2esr", + "10.0.3esr", + "32.0", + "49.0a1", + "49.0a2", + "59.0", + "60.0", + "60.0esr", + "60.0.1esr", + "60.1", + "60.1esr", + "61.0", +] + + +@pytest.fixture( + scope="function", + params=range(len(ALL_VERSIONS) - 1), + ids=lambda x: "{}, {}".format(ALL_VERSIONS[x], ALL_VERSIONS[x + 1]), +) +def comparable_versions(request): + index = request.param + return ALL_VERSIONS[index], ALL_VERSIONS[index + 1] + + +@pytest.mark.parametrize("version", ALL_VERSIONS) +def test_versions_parseable(version): + """Test that we can parse previously shipped versions. + + We only test 3.0 and up, since we never generate updates against + versions that old.""" + assert MozillaVersion(version) is not None + + +def test_versions_compare_less(comparable_versions): + """Test that versions properly compare in order.""" + smaller_version, larger_version = comparable_versions + assert MozillaVersion(smaller_version) < MozillaVersion(larger_version) + + +def test_versions_compare_greater(comparable_versions): + """Test that versions properly compare in order.""" + smaller_version, larger_version = comparable_versions + assert MozillaVersion(larger_version) > MozillaVersion(smaller_version) + + +def test_ModernMozillaVersion(): + """Test properties specific to ModernMozillaVersion""" + assert isinstance(MozillaVersion("1.2.4"), ModernMozillaVersion) + assert isinstance(MozillaVersion("1.2.4rc3"), ModernMozillaVersion) + assert MozillaVersion("1.2rc3") == MozillaVersion("1.2.0rc3") + + +def test_AncientMozillaVersion(): + """Test properties specific to AncientMozillaVersion""" + assert isinstance(MozillaVersion("1.2.0.4"), AncientMozillaVersion) + assert isinstance(MozillaVersion("1.2.0.4pre1"), AncientMozillaVersion) + assert MozillaVersion("1.2pre1") == MozillaVersion("1.2.0pre1") + assert MozillaVersion("1.2.0.4pre1") == MozillaVersion("1.2.4pre1") + + +@pytest.mark.parametrize("version", ALL_VERSIONS) +def test_versions_compare_equal(version): + """Test that versions properly compare as equal through multiple passes.""" + assert MozillaVersion(version) == MozillaVersion(version) + + +if __name__ == "__main__": + mozunit.main() |