From f7d3cc4ae77513a9294fa96fad720641a3e4ecef Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Fri, 25 Oct 2024 10:39:49 -0500 Subject: [PATCH 1/4] update tests for mismatching plugins --- core/dbt/version.py | 6 +++- tests/unit/test_version.py | 62 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/core/dbt/version.py b/core/dbt/version.py index 4413a9e0536..c4cd8ffd0b7 100644 --- a/core/dbt/version.py +++ b/core/dbt/version.py @@ -130,7 +130,11 @@ def _get_plugin_msg_info( needs_update = False - if plugin.major != core.major or plugin.minor != core.minor: + assert plugin.major is not None + assert plugin.minor is not None + assert core.major is not None + assert core.minor is not None + if plugin.major != core.major or plugin.minor < core.minor: compatibility_msg = red("Not compatible!") needs_update = True return (compatibility_msg, needs_update) diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index efd51872576..5e1ca4f1fc5 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -489,6 +489,68 @@ def test_plugin_diff_core_minor_ahead_latest(self, mocker): assert expected == actual + def test_plugin_diff_plugin_minor_ahead_latest(self, mocker): + """ + Now that adapters are decoupled from core, a higher minor version of a plugin + is compatible with a lower minor version of core. + """ + + mock_versions( + mocker, + installed="1.8.0", + latest="1.8.0", + plugins={ + "foobar": ("1.9.0", "1.9.0"), + }, + ) + + actual = dbt.version.get_version_information() + expected = "\n".join( + [ + "Core:", + " - installed: 1.8.0", + f" - latest: 1.8.0 - {green('Up to date!')}", + "", + "Plugins:", + f" - foobar: 1.9.0 - {green('Up to date!')}", + "", + "", + ] + ) + + assert expected == actual + + def test_plugin_diff_plugin_minor_ahead_no_latest(self, mocker): + """ + Now that adapters are decoupled from core, a higher minor version of a plugin + is compatible with a lower minor version of core. + """ + + mock_versions( + mocker, + installed="1.8.0", + latest="1.8.0", + plugins={ + "foobar": ("1.9.0", None), + }, + ) + + actual = dbt.version.get_version_information() + expected = "\n".join( + [ + "Core:", + " - installed: 1.8.0", + f" - latest: 1.8.0 - {green('Up to date!')}", + "", + "Plugins:", + f" - foobar: 1.9.0 - {yellow('Could not determine latest version')}", + "", + "", + ] + ) + + assert expected == actual + def test_plugin_diff_core_minor_behind_latest(self, mocker): mock_versions( mocker, From 1d9a0eee86339e48d9a1277904c64c1610675ce8 Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Fri, 25 Oct 2024 10:44:35 -0500 Subject: [PATCH 2/4] changie --- .changes/unreleased/Fixes-20241025-104339.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20241025-104339.yaml diff --git a/.changes/unreleased/Fixes-20241025-104339.yaml b/.changes/unreleased/Fixes-20241025-104339.yaml new file mode 100644 index 00000000000..ea7f4e060b6 --- /dev/null +++ b/.changes/unreleased/Fixes-20241025-104339.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: update adapter version messages +time: 2024-10-25T10:43:39.274723-05:00 +custom: + Author: dave-connors-3 + Issue: "10230" From 3529df4528aaed634e5c549a98b08098deac3527 Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Fri, 25 Oct 2024 10:48:10 -0500 Subject: [PATCH 3/4] add patch version test case --- tests/unit/test_version.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index 5e1ca4f1fc5..e3541906fdd 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -520,6 +520,37 @@ def test_plugin_diff_plugin_minor_ahead_latest(self, mocker): assert expected == actual + def test_plugin_diff_plugin_patch_ahead_latest(self, mocker): + """ + Now that adapters are decoupled from core, a higher minor version of a plugin + is compatible with a lower minor version of core. + """ + + mock_versions( + mocker, + installed="1.8.0", + latest="1.8.0", + plugins={ + "foobar": ("1.8.4", "1.8.4"), + }, + ) + + actual = dbt.version.get_version_information() + expected = "\n".join( + [ + "Core:", + " - installed: 1.8.0", + f" - latest: 1.8.0 - {green('Up to date!')}", + "", + "Plugins:", + f" - foobar: 1.8.4 - {green('Up to date!')}", + "", + "", + ] + ) + + assert expected == actual + def test_plugin_diff_plugin_minor_ahead_no_latest(self, mocker): """ Now that adapters are decoupled from core, a higher minor version of a plugin From 894b1149445d0a150dfa4ff583d6e312479aabbc Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Wed, 4 Dec 2024 17:10:09 -0600 Subject: [PATCH 4/4] remove check and tests with erroneous package matches --- core/dbt/version.py | 17 +--- tests/unit/test_version.py | 183 ++++++++----------------------------- 2 files changed, 44 insertions(+), 156 deletions(-) diff --git a/core/dbt/version.py b/core/dbt/version.py index c4cd8ffd0b7..fe0902afdee 100644 --- a/core/dbt/version.py +++ b/core/dbt/version.py @@ -8,7 +8,7 @@ import requests import dbt_common.semver as semver -from dbt_common.ui import green, red, yellow +from dbt_common.ui import green, yellow PYPI_VERSION_URL = "https://pypi.org/pypi/dbt-core/json" @@ -19,7 +19,7 @@ def get_version_information() -> str: core_msg_lines, core_info_msg = _get_core_msg_lines(installed, latest) core_msg = _format_core_msg(core_msg_lines) - plugin_version_msg = _get_plugins_msg(installed) + plugin_version_msg = _get_plugins_msg() msg_lines = [core_msg] @@ -97,7 +97,7 @@ def _format_core_msg(lines: List[List[str]]) -> str: return msg + "\n".join(msg_lines) -def _get_plugins_msg(installed: semver.VersionSpecifier) -> str: +def _get_plugins_msg() -> str: msg_lines = ["Plugins:"] plugins = [] @@ -113,7 +113,7 @@ def _get_plugins_msg(installed: semver.VersionSpecifier) -> str: if display_update_msg: update_msg = ( - " At least one plugin is out of date or incompatible with dbt-core.\n" + " At least one plugin is out of date with dbt-core.\n" " You can find instructions for upgrading here:\n" " https://docs.getdbt.com/docs/installation" ) @@ -130,15 +130,6 @@ def _get_plugin_msg_info( needs_update = False - assert plugin.major is not None - assert plugin.minor is not None - assert core.major is not None - assert core.minor is not None - if plugin.major != core.major or plugin.minor < core.minor: - compatibility_msg = red("Not compatible!") - needs_update = True - return (compatibility_msg, needs_update) - if not latest_plugin: compatibility_msg = yellow("Could not determine latest version") return (compatibility_msg, needs_update) diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index e3541906fdd..bf4afb37e84 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -1,5 +1,5 @@ import dbt.version -from dbt_common.ui import green, red, yellow +from dbt_common.ui import green, yellow class TestGetVersionInformation: @@ -239,7 +239,7 @@ def test_plugin_match_core_behind_latest(self, mocker): "Plugins:", f" - foobar: 1.0.0 - {yellow('Update available!')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "", @@ -269,127 +269,7 @@ def test_plugin_match_core_ahead_latest(self, mocker): "Plugins:", f" - foobar: 1.0.0 - {yellow('Update available!')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", - "", - "", - ] - ) - - assert expected == actual - - def test_plugin_diff_core_major_match_latest(self, mocker): - mock_versions( - mocker, - installed="2.0.0", - latest="2.0.0", - plugins={ - "foobar": ("1.0.0", "1.0.0"), - }, - ) - - actual = dbt.version.get_version_information() - expected = "\n".join( - [ - "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", - "", - "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", - "", - "", - ] - ) - - assert expected == actual - - def test_plugin_diff_core_major_no_latest(self, mocker): - mock_versions( - mocker, - installed="2.0.0", - latest="2.0.0", - plugins={ - "foobar": ("1.0.0", None), - }, - ) - - actual = dbt.version.get_version_information() - expected = "\n".join( - [ - "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", - "", - "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", - "", - "", - ] - ) - - assert expected == actual - - def test_plugin_diff_core_major_ahead_latest(self, mocker): - mock_versions( - mocker, - installed="2.0.0", - latest="2.0.0", - plugins={ - "foobar": ("1.0.0", "0.0.1"), - }, - ) - - actual = dbt.version.get_version_information() - expected = "\n".join( - [ - "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", - "", - "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", - "", - "", - ] - ) - - assert expected == actual - - def test_plugin_diff_core_major_behind_latest(self, mocker): - mock_versions( - mocker, - installed="2.0.0", - latest="2.0.0", - plugins={ - "foobar": ("1.0.0", "1.1.0"), - }, - ) - - actual = dbt.version.get_version_information() - expected = "\n".join( - [ - "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", - "", - "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "", @@ -417,11 +297,7 @@ def test_plugin_diff_core_minor_match_latest(self, mocker): f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.0.0 - {green('Up to date!')}", "", "", ] @@ -447,11 +323,7 @@ def test_plugin_diff_core_minor_no_latest(self, mocker): f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.0.0 - {yellow('Could not determine latest version')}", "", "", ] @@ -477,11 +349,7 @@ def test_plugin_diff_core_minor_ahead_latest(self, mocker): f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.0.0 - {yellow('Ahead of latest version!')}", "", "", ] @@ -582,6 +450,37 @@ def test_plugin_diff_plugin_minor_ahead_no_latest(self, mocker): assert expected == actual + def test_plugin_diff_plugin_minor_behind_core_no_latest(self, mocker): + """ + Now that adapters are decoupled from core, a lower minor version of a plugin (1.8) + is compatible with a higher minor version of core. (1.9) + """ + + mock_versions( + mocker, + installed="1.9.0", + latest="1.9.0", + plugins={ + "foobar": ("1.8.0", "1.8.0"), + }, + ) + + actual = dbt.version.get_version_information() + expected = "\n".join( + [ + "Core:", + " - installed: 1.9.0", + f" - latest: 1.9.0 - {green('Up to date!')}", + "", + "Plugins:", + f" - foobar: 1.8.0 - {green('Up to date!')}", + "", + "", + ] + ) + + assert expected == actual + def test_plugin_diff_core_minor_behind_latest(self, mocker): mock_versions( mocker, @@ -600,9 +499,9 @@ def test_plugin_diff_core_minor_behind_latest(self, mocker): f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", + f" - foobar: 1.0.0 - {yellow('Update available!')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "", @@ -621,7 +520,6 @@ def test_plugins_various(self, mocker): "foobar": ("2.1.0", "2.1.0"), "bazqux": ("2.1.0", None), "quuux": ("2.1.0", "2.1.0"), - "corge": ("22.21.20", "22.21.21"), "grault": ("2.1.0", "2.1.1"), "garply": ("2.1.0-b1", None), }, @@ -638,11 +536,10 @@ def test_plugins_various(self, mocker): f" - foobar: 2.1.0 - {green('Up to date!')}", f" - bazqux: 2.1.0 - {yellow('Could not determine latest version')}", f" - quuux: 2.1.0 - {green('Up to date!')}", - f" - corge: 22.21.20 - {red('Not compatible!')}", f" - grault: 2.1.0 - {yellow('Update available!')}", f" - garply: 2.1.0-b1 - {yellow('Could not determine latest version')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "",