1
1
import io
2
2
import logging
3
- import time
4
3
5
4
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
7
8
8
9
9
10
@pytest .mark .ingresses
10
11
@pytest .mark .smoke
11
12
class TestBuildVersion :
12
13
def test_build_version (self , ingress_controller , kube_apis , ingress_controller_prerequisites ):
13
14
"""
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
15
16
"""
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
+
16
22
_info = self .send_build_info (kube_apis , ingress_controller_prerequisites )
17
23
_version = _info [_info .find ("Version=" ) + len ("Version=" ) : _info .rfind ("GitCommit=" )]
18
24
logging .info (_version )
19
25
assert _version != " "
26
+ assert ic_ver in _version
20
27
21
28
def send_build_info (self , kube_apis , ingress_controller_prerequisites ) -> str :
22
29
"""
@@ -27,7 +34,7 @@ def send_build_info(self, kube_apis, ingress_controller_prerequisites) -> str:
27
34
pod_name = get_first_pod_name (kube_apis .v1 , ingress_controller_prerequisites .namespace )
28
35
wait_until_all_pods_are_ready (kube_apis .v1 , ingress_controller_prerequisites .namespace )
29
36
while not ready :
30
- time . sleep ( 1 )
37
+ wait_before_test ( )
31
38
try :
32
39
api_response = kube_apis .v1 .read_namespaced_pod_log (
33
40
name = pod_name ,
@@ -49,6 +56,7 @@ def send_build_info(self, kube_apis, ingress_controller_prerequisites) -> str:
49
56
_log = br .readline ().strip ()
50
57
try :
51
58
_info = _log [_log .find ("Version" ) :].strip ()
59
+ print (f"Version and GitCommit info: { _info } " )
52
60
logging .info (f"Version and GitCommit info: { _info } " )
53
61
except Exception :
54
62
logging .exception (f"Tag labels not found" )
0 commit comments