@@ -56,68 +56,72 @@ def test_subscription_status_hub(openshift_dyn_client):
5656
5757 cluster_version = subscription .openshift_version (openshift_dyn_client )
5858 logger .info (f"Openshift version:\n { cluster_version .instance .status .history } " )
59- shortversion = re .sub ("(.[0-9]+$)" , "" , os .getenv ("OPENSHIFT_VER" ))
60-
61- currentfile = os .getcwd () + "/operators_hub_current"
62- sourceFile = open (currentfile , "w" )
63- for line in operator_versions :
64- logger .info (line )
65- print (line , file = sourceFile )
66- sourceFile .close ()
67-
68- logger .info ("Clone operator-versions repo" )
69- try :
70- operator_versions_repo = (
71- "[email protected] :mpqe/mps/vp/operator-versions.git" 72- )
73- clone = subprocess .run (
74- ["git" , "clone" , operator_versions_repo ], capture_output = True , text = True
75- )
76- logger .info (clone .stdout )
77- logger .info (clone .stderr )
78- except Exception :
79- pass
80-
81- previouspath = os .getcwd () + f"/operator-versions/aegitops_hub_{ shortversion } "
82- previousfile = f"aegitops_hub_{ shortversion } "
83-
84- logger .info ("Ensure previous file exists" )
85- checkpath = os .path .exists (previouspath )
86- logger .info (checkpath )
87-
88- if checkpath is True :
89- logger .info ("Diff current operator list with previous file" )
90- diff = opdiff (open (previouspath ).readlines (), open (currentfile ).readlines ())
91- diffstring = "" .join (diff )
92- logger .info (diffstring )
93-
94- logger .info ("Write diff to file" )
95- sourceFile = open ("operator_diffs_hub.log" , "w" )
96- print (diffstring , file = sourceFile )
59+
60+ if os .getenv ("EXTERNAL_TEST" ) != "true" :
61+ shortversion = re .sub ("(.[0-9]+$)" , "" , os .getenv ("OPENSHIFT_VER" ))
62+ currentfile = os .getcwd () + "/operators_hub_current"
63+ sourceFile = open (currentfile , "w" )
64+ for line in operator_versions :
65+ logger .info (line )
66+ print (line , file = sourceFile )
9767 sourceFile .close ()
98- else :
99- logger .info ("Skipping operator diff - previous file not found" )
68+
69+ logger .info ("Clone operator-versions repo" )
70+ try :
71+ operator_versions_repo = (
72+ "[email protected] :mpqe/mps/vp/operator-versions.git" 73+ )
74+ clone = subprocess .run (
75+ ["git" , "clone" , operator_versions_repo ], capture_output = True , text = True
76+ )
77+ logger .info (clone .stdout )
78+ logger .info (clone .stderr )
79+ except Exception :
80+ pass
81+
82+ previouspath = os .getcwd () + f"/operator-versions/aegitops_hub_{ shortversion } "
83+ previousfile = f"aegitops_hub_{ shortversion } "
84+
85+ logger .info ("Ensure previous file exists" )
86+ checkpath = os .path .exists (previouspath )
87+ logger .info (checkpath )
88+
89+ if checkpath is True :
90+ logger .info ("Diff current operator list with previous file" )
91+ diff = opdiff (open (previouspath ).readlines (), open (currentfile ).readlines ())
92+ diffstring = "" .join (diff )
93+ logger .info (diffstring )
94+
95+ logger .info ("Write diff to file" )
96+ sourceFile = open ("operator_diffs_hub.log" , "w" )
97+ print (diffstring , file = sourceFile )
98+ sourceFile .close ()
99+ else :
100+ logger .info ("Skipping operator diff - previous file not found" )
100101
101102 if missing_subs or unhealthy_subs or missing_installplans or upgrades_pending :
102103 err_msg = "Subscription status check failed"
103104 logger .error (f"FAIL: { err_msg } " )
104105 assert False , err_msg
105106 else :
106107 # Only push the new operarator list if the test passed
107- if checkpath is True :
108- os .remove (previouspath )
109- os .rename (currentfile , previouspath )
110-
111- cwd = os .getcwd () + "/operator-versions"
112- logger .info (f"CWD: { cwd } " )
113-
114- logger .info ("Push new operator list" )
115- subprocess .run (["git" , "add" , previousfile ], cwd = cwd )
116- subprocess .run (
117- ["git" , "commit" , "-m" , "Update operator versions list" ],
118- cwd = cwd ,
119- )
120- subprocess .run (["git" , "push" ], cwd = cwd )
108+ # and we are not testing a pre-release operator nor
109+ # running externally
110+ if os .getenv ("EXTERNAL_TEST" ) != "true" :
111+ if checkpath is True and not os .environ ["INDEX_IMAGE" ]:
112+ os .remove (previouspath )
113+ os .rename (currentfile , previouspath )
114+
115+ cwd = os .getcwd () + "/operator-versions"
116+ logger .info (f"CWD: { cwd } " )
117+
118+ logger .info ("Push new operator list" )
119+ subprocess .run (["git" , "add" , previousfile ], cwd = cwd )
120+ subprocess .run (
121+ ["git" , "commit" , "-m" , "Update operator versions list" ],
122+ cwd = cwd ,
123+ )
124+ subprocess .run (["git" , "push" ], cwd = cwd )
121125
122126 logger .info ("PASS: Subscription status check passed" )
123127
0 commit comments