aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukasz.rajewski@t-mobile.pl <lukasz.rajewski@t-mobile.pl>2024-03-25 12:43:54 +0000
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-03-25 15:00:08 +0100
commit25bfd5e306de7336b5dff32425da6b6958b99a47 (patch)
tree95b33600403b2b0f85fc9f4bb18035c8b96bdbf8
parent8125d537e3b6ef82e0853eb7ba8f896c968af6a1 (diff)
Fix SDC v2 distribution status
Check in the status if DOWNLOAD_OK is present Issue-ID: TEST-404 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: I270cdc6abfbe658fcd1940f25fa440e11f52e778
-rw-r--r--src/onapsdk/sdc2/service.py21
-rw-r--r--src/onapsdk/version.py2
-rw-r--r--tests/test_sdc2_service.py13
-rw-r--r--tests/test_version.py2
4 files changed, 32 insertions, 6 deletions
diff --git a/src/onapsdk/sdc2/service.py b/src/onapsdk/sdc2/service.py
index 1ec64b5..079fff5 100644
--- a/src/onapsdk/sdc2/service.py
+++ b/src/onapsdk/sdc2/service.py
@@ -58,6 +58,19 @@ class ServiceDistribution(SDC):
error_reason: str
@property
+ def distributed(self) -> bool:
+ """Flag to detrmine if status is distributed.
+
+ If status is not DOWNLOAD_OK it means that component is not yet
+ distributed and we need to wait for status update.
+
+ Returns:
+ bool: True if distribution of component was completed.
+
+ """
+ return self.status == "DOWNLOAD_OK"
+
+ @property
def failed(self) -> bool:
"""Flag to determine if distribution status is failed or not.
@@ -137,17 +150,19 @@ class ServiceDistribution(SDC):
@property
def _distribution_components_test(self) -> bool:
- """Test to check if all required components were notified about distribution.
+ """Test to check if all required components were notified and downloaded artifacts.
List of required components can be configured via SDC_SERVICE_DISTRIBUTION_COMPONENTS
setting value.
Returns:
- bool: True if all required components were notified, False otherwise
+ bool: True if all required components were notified and artifacts were downloaded
+ False otherwise
"""
notified_components_set: Set[str] = {
- distribution.component_id for distribution in self.distribution_status_list
+ distribution.component_id for distribution in filter(
+ lambda item: item.distributed, self.distribution_status_list)
}
return set(settings.SDC_SERVICE_DISTRIBUTION_COMPONENTS).issubset(notified_components_set)
diff --git a/src/onapsdk/version.py b/src/onapsdk/version.py
index d606f96..33acbae 100644
--- a/src/onapsdk/version.py
+++ b/src/onapsdk/version.py
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "13.0.5"
+__version__ = "13.0.6"
diff --git a/tests/test_sdc2_service.py b/tests/test_sdc2_service.py
index 69b732b..23fab64 100644
--- a/tests/test_sdc2_service.py
+++ b/tests/test_sdc2_service.py
@@ -540,13 +540,24 @@ def test_service_distribution_distribution_components_test(mock_distribution_sta
error_reason=str(uuid4())
) for component_id in settings.SDC_SERVICE_DISTRIBUTION_COMPONENTS
]
+ assert sd._distribution_components_test is False
+
+ mock_distribution_status_list.return_value = [
+ ServiceDistribution.DistributionStatus(
+ component_id=component_id,
+ timestamp=str(randint(0, maxsize)),
+ status="DOWNLOAD_OK",
+ url=str(uuid4()),
+ error_reason=str(uuid4())
+ ) for component_id in settings.SDC_SERVICE_DISTRIBUTION_COMPONENTS
+ ]
assert sd._distribution_components_test is True
mock_distribution_status_list.return_value = [
ServiceDistribution.DistributionStatus(
component_id=component_id,
timestamp=str(randint(0, maxsize)),
- status=str(uuid4()),
+ status="DOWNLOAD_OK",
url=str(uuid4()),
error_reason=str(uuid4())
) for component_id in settings.SDC_SERVICE_DISTRIBUTION_COMPONENTS + ["additional-test-component"]
diff --git a/tests/test_version.py b/tests/test_version.py
index 7633f9f..9afad27 100644
--- a/tests/test_version.py
+++ b/tests/test_version.py
@@ -17,4 +17,4 @@ import onapsdk.version as version
def test_version():
"""Check version is the right one."""
- assert version.__version__ == '13.0.5'
+ assert version.__version__ == '13.0.6'