Skip to content

Commit 81bcf96

Browse files
authored
assert version from log and chart (#6307)
1 parent 95c617f commit 81bcf96

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.github/actions/smoke-tests/action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ runs:
7878
--network=kind \
7979
-v ${{ github.workspace }}/tests:/workspace/tests \
8080
-v ${{ github.workspace }}/deployments:/workspace/deployments \
81+
-v ${{ github.workspace }}/charts:/workspace/charts \
8182
-v ${{ github.workspace }}/config:/workspace/config \
8283
-v ${{ github.workspace }}/pyproject.toml:/workspace/pyproject.toml \
8384
-v ${{ steps.k8s.outputs.test_output_path }}:${{ steps.k8s.outputs.test_output_path }} \

tests/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
BASEDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
66
DEPLOYMENTS = f"{BASEDIR}/deployments"
7+
HELM_CHARTS = f"{BASEDIR}/charts/nginx-ingress"
78
CRDS = f"{BASEDIR}/config/crd/bases"
89
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
910
TEST_DATA = f"{PROJECT_ROOT}/data"

tests/suite/test_build_info.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import io
22
import logging
3-
import time
43

54
import pytest
6-
from suite.utils.resources_utils import get_first_pod_name, wait_until_all_pods_are_ready
5+
import yaml
6+
from settings import HELM_CHARTS
7+
from suite.utils.resources_utils import get_first_pod_name, wait_before_test, wait_until_all_pods_are_ready
78

89

910
@pytest.mark.ingresses
1011
@pytest.mark.smoke
1112
class TestBuildVersion:
1213
def test_build_version(self, ingress_controller, kube_apis, ingress_controller_prerequisites):
1314
"""
14-
Test Version tag of build i.e. 'Version=<VERSION>'
15+
Test Version tag of build i.e. 'Version=<VERSION>' is same as the version in the chart.yaml file
1516
"""
17+
with open(f"{HELM_CHARTS}/Chart.yaml") as f:
18+
chart = yaml.safe_load(f)
19+
ic_ver = chart["appVersion"]
20+
print(f"NIC version from chart: {ic_ver}")
21+
1622
_info = self.send_build_info(kube_apis, ingress_controller_prerequisites)
1723
_version = _info[_info.find("Version=") + len("Version=") : _info.rfind("GitCommit=")]
1824
logging.info(_version)
1925
assert _version != " "
26+
assert ic_ver in _version
2027

2128
def send_build_info(self, kube_apis, ingress_controller_prerequisites) -> str:
2229
"""
@@ -27,7 +34,7 @@ def send_build_info(self, kube_apis, ingress_controller_prerequisites) -> str:
2734
pod_name = get_first_pod_name(kube_apis.v1, ingress_controller_prerequisites.namespace)
2835
wait_until_all_pods_are_ready(kube_apis.v1, ingress_controller_prerequisites.namespace)
2936
while not ready:
30-
time.sleep(1)
37+
wait_before_test()
3138
try:
3239
api_response = kube_apis.v1.read_namespaced_pod_log(
3340
name=pod_name,
@@ -49,6 +56,7 @@ def send_build_info(self, kube_apis, ingress_controller_prerequisites) -> str:
4956
_log = br.readline().strip()
5057
try:
5158
_info = _log[_log.find("Version") :].strip()
59+
print(f"Version and GitCommit info: {_info}")
5260
logging.info(f"Version and GitCommit info: {_info}")
5361
except Exception:
5462
logging.exception(f"Tag labels not found")

0 commit comments

Comments
 (0)