@@ -138,5 +138,36 @@ def test_channels(host):
138138 # ensure that repository exists
139139 assert repo_name in cmd_channels .stdout .strip ().split ("\n " )
140140
141- # TODO: def test_monitoring_packages(host):
142- # TODO: def test_monitoring_enabled(host):
141+ def test_monitoring_packages (host ):
142+ """
143+ check if monitoring packages have been installed
144+ """
145+ # get variables from file
146+ ansible_vars = host .ansible ("include_vars" , "file=molecule/default/vars/main.yml" )
147+ # set packages
148+ pkgs = []
149+ if ansible_vars ["ansible_facts" ]["uyuni_enable_monitoring" ]:
150+ pkgs = pkgs + ansible_vars ["ansible_facts" ]["uyuni_monitoring_packages" ]
151+ if ansible_vars ["ansible_facts" ]["uyuni_install_monitoring_formulas" ]:
152+ pkgs = pkgs + ansible_vars ["ansible_facts" ]["uyuni_monitoring_formulas_packages" ]
153+ # check packages
154+ for pkg in pkgs :
155+ print (pkg )
156+ assert host .package (pkg ).is_installed
157+
158+
159+ def test_monitoring_enabled (host ):
160+ """
161+ check if monitoring is enabled
162+ """
163+ # get variables from file
164+ ansible_vars = host .ansible ("include_vars" , "file=molecule/default/vars/main.yml" )
165+ # check configuration
166+ if ansible_vars ["ansible_facts" ]["uyuni_enable_monitoring" ]:
167+ with host .sudo ():
168+ rhn_cfg = host .file ("/etc/rhn/rhn.conf" )
169+ assert rhn_cfg .contains ("prometheus_monitoring_enabled" )
170+ # check status
171+ with host .sudo ():
172+ mon_status = host .run ("mgr-monitoring-ctl status" )
173+ assert "error" not in mon_status .stdout .strip ().lower ()
0 commit comments