def test_stop_suse(self): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("stop")).action_stop() defined_resources = env.resource_list expected_resources = "[MonitorWebserver['stop'], " \ "Execute['/etc/init.d/apache2 stop']]" self.assertEqual(str(defined_resources), expected_resources)
def test_stop_redhat(self, is_redhat_family, is_ubuntu_family, is_suse_family): is_redhat_family.return_value = True is_ubuntu_family.return_value = False is_suse_family.return_value = False with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("stop")).action_stop() defined_resources = env.resource_list expected_resources = '[MonitorWebserver[\'stop\'], Execute[(\'/etc/init.d/httpd\', \'stop\')]]' self.assertEqual(str(defined_resources), expected_resources)
def test_setup_suse(self): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("start")).action_start() defined_resources = env.resource_list expected_resources = '[u"MonitorWebserver[\'start\']", u"Execute[\'grep -E \'KeepAlive (On|Off)\' ' \ '/etc/apache2/httpd.conf && /usr/bin/sudo [RMF_ENV_PLACEHOLDER] -H -E sed -i ' \ '\'s/KeepAlive Off/KeepAlive On/\' /etc/apache2/httpd.conf || echo \'KeepAlive On\' ' \ '| /usr/bin/sudo [RMF_ENV_PLACEHOLDER] -H -E tee --append /etc/apache2/httpd.conf > /dev/null\']",' \ ' u"Execute[\'(\'/etc/init.d/apache2\', \'start\')\']"]' self.assertEqual(str(defined_resources), expected_resources)
def test_setup_suse(self): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("start")).action_start() defined_resources = env.resource_list expected_resources = "[MonitorWebserver['start'], " \ "Execute['grep -E 'KeepAlive (On|Off)' /etc/apache2/httpd.conf " \ "&& sed -i 's/KeepAlive Off/KeepAlive On/' /etc/apache2/httpd.conf " \ "|| echo 'KeepAlive On' >> /etc/apache2/httpd.conf']," \ " Execute['/etc/init.d/apache2 start']]" self.assertEqual(str(defined_resources), expected_resources)
def test_setup_redhat(self, is_redhat_family, is_ubuntu_family, is_suse_family): is_redhat_family.return_value = True is_ubuntu_family.return_value = False is_suse_family.return_value = False with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("start")).action_start() defined_resources = env.resource_list expected_resources = '[MonitorWebserver[\'start\'], Execute[\'grep -E \'KeepAlive (On|Off)\' ' \ '/etc/httpd/conf/httpd.conf && ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E sed -i ' \ '\'s/KeepAlive Off/KeepAlive On/\' /etc/httpd/conf/httpd.conf || echo \'KeepAlive On\' ' \ '| ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E tee --append /etc/httpd/conf/httpd.conf > /dev/null\']' \ ', Execute[(\'/etc/init.d/httpd\', \'start\')]]' self.assertEqual(str(defined_resources), expected_resources)
def server(action=None): # 'start' or 'stop' command = as_sudo( ('service', 'hdp-gmetad', action) ) + " >> /tmp/gmetad.log 2>&1 ; /bin/ps auwx | /bin/grep [g]metad >> /tmp/gmetad.log 2>&1" Execute(command, path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin') MonitorWebserver("restart")
def test_stop_suse(self): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("stop")).action_stop() defined_resources = env.resource_list expected_resources = '[u"MonitorWebserver[\'stop\']", u"Execute[\'(\'/etc/init.d/apache2\', \'stop\')\']"]' self.assertEqual(str(defined_resources), expected_resources)