Skip to content

Commit

Permalink
Fixes the is_suma functions to support Suma 4.x and 5.x scenarios(#396
Browse files Browse the repository at this point in the history
)
  • Loading branch information
apozsuse authored Sep 19, 2024
1 parent cf3552d commit 19d1032
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions usr/share/lib/img_proof/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import pytest
import xml.etree.ElementTree as ET

from susepubliccloudinfoclient import infoserverrequests

Expand Down Expand Up @@ -146,31 +147,49 @@ def f():


@pytest.fixture()
def is_suma_server(host, get_baseproduct):
def is_suma_server(host, get_baseproduct, get_suma_version):
def f():
suma_server_product = '/etc/products.d/SUSE-Manager-Server.prod'
suma_server = host.file(suma_server_product)
base_product = get_baseproduct()
suma_version = get_suma_version(suma_server_product)

if suma_version and suma_version.startswith('4'):
# For suma 4.3 baseproduct HAS to be SUMA server
expected_product = suma_server_product
else:
# For suma >=5 baseproduct has to be Micro
# SUMA is included as an additional product
expected_product = '/etc/products.d/SLE-Micro.prod'

return all([
suma_server.exists,
suma_server.is_file,
base_product == suma_server_product
base_product == expected_product
])
return f


@pytest.fixture()
def is_suma_proxy(host, get_baseproduct):
def is_suma_proxy(host, get_baseproduct, get_suma_version):
def f():
suma_proxy_product = '/etc/products.d/SUSE-Manager-Proxy.prod'
suma_proxy = host.file(suma_proxy_product)
base_product = get_baseproduct()
suma_version = get_suma_version(suma_proxy_product)

if suma_version and suma_version.startswith('4'):
# For suma 4.3 baseproduct HAS to be SUMA proxy
expected_product = suma_proxy_product
else:
# For suma >=5 baseproduct has to be Micro
# SUMA is included as an additional product
expected_product = '/etc/products.d/SLE-Micro.prod'

return all([
suma_proxy.exists,
suma_proxy.is_file,
base_product == suma_proxy_product
base_product == expected_product
])
return f

Expand All @@ -182,6 +201,20 @@ def f():
return f


@pytest.fixture()
def get_suma_version(host):
def f(product_file):
version = ''
try:
suma_product = host.file(product_file)
xmlroot = ET.fromstring(suma_product.content_string)
version = xmlroot.find('./version').text
except Exception:
pass
return version
return f


@pytest.fixture()
def is_sles_sapcal(host):
def f():
Expand Down

0 comments on commit 19d1032

Please sign in to comment.