def test_log_screen(self): """ Test Log screen configuration. """ host3 = DockerHost( "cali-host3", additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, post_docker_commands=POST_DOCKER_COMMANDS, start_calico=False) host3_hostname = host3.execute("hostname") # Start calico node on host which disable file logging. host3.start_calico_node( env_options="-e CALICO_DISABLE_FILE_LOGGING=true") # Wait for felix to start and get snapshot conf_name = "node.%s" % host3_hostname self.wait_for_felix(host3) self.log_screen_snapshot(host3, "snapshot") # Check DEBUG and INFO in snapshot. levels = {"DEBUG": False, "INFO": True} self.check_log_levels(host3, "snapshot", levels, 3) # Change severity to DEBUG. Check DEBUG INFO again since last snaphost. self.add_felix_config(conf_name, {'LogSeverityScreen': 'DEBUG'}) levels = {"DEBUG": True, "INFO": True} self.check_log_levels(host3, "log_diff", levels, 3, "snapshot") # Change severity to ERROR. self.add_felix_config(conf_name, {'LogSeverityScreen': 'ERROR'}) # Restart felix wait for FATAL message and take snapshot. self.restart_felix_no_config_file(host3) levels = {"FATAL": True} self.check_log_levels(host3, "log_diff", levels, 3, "snapshot") self.log_screen_snapshot(host3, "snapshot") # Remove ipset command. self.remove_ipset_command(host3) # Don't expect DEBUG INFO WARNING FATAL message from last snapshot. levels = { "DEBUG": False, "INFO": False, "WARNING": False, "FATAL": False } self.check_log_levels(host3, "log_diff", levels, 3, "snapshot") # Should have ERROR message. self.check_log_levels(host3, "log_diff", {"ERROR": True}, 20, "snapshot") self.restore_ipset_command(host3) host3.cleanup()
def test_log_file(self): """ Test Log file configuration. """ host3 = DockerHost( "cali-host3", additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, post_docker_commands=POST_DOCKER_COMMANDS, start_calico=False) host3_hostname = host3.execute("hostname") host3.start_calico_node() conf_name = "node.%s" % host3_hostname default = "/var/log/calico/felix/current" # Check default log file is good. levels = {"DEBUG": False, "INFO": True} self.check_log_levels(host3, default, levels, 3) # Change severity to DEBUG. self.add_felix_config(conf_name, {'LogSeverityFile': 'DEBUG'}) # Make sure new severity setting is taken by felix. self.check_log_levels(host3, default, {"DEBUG": True}, 3) # Empty log file and check again for DEBUG and INFO. self.empty_log_file(host3, default) levels = {"DEBUG": True, "INFO": True} self.check_log_levels(host3, default, levels, 3) # Change log file and severity to FATAL. new_path = "/var/log/calico/st_test0" self.add_felix_config(conf_name, { 'logFilePath': new_path, 'LogSeverityFile': 'FATAL' }) self.restart_felix_no_config_file(host3) # Don't expect DEBUG INFO WARNING FATAL message from new log file. levels = { "DEBUG": False, "INFO": False, "WARNING": False, "FATAL": False } self.check_log_levels(host3, new_path, levels, 3) # Send a termination signal. We should see FATAL but not DEBUG INFO WARNING. self.restart_felix_no_config_file(host3) levels = { "DEBUG": False, "INFO": False, "WARNING": False, "FATAL": True } self.check_log_levels(host3, new_path, levels, 3) # Change log file and severity to WARNING and send termination signal. new_path = "/var/log/calico/st_test1" self.add_felix_config(conf_name, { 'logFilePath': new_path, 'LogSeverityFile': 'WARNING' }) self.restart_felix_no_config_file(host3) # Dont expect DEBUG INFO WARNING FATAL messages from new log file. levels = { "DEBUG": False, "INFO": False, "WARNING": False, "FATAL": False } self.check_log_levels(host3, new_path, levels, 3) # Send a termination signal. Expect both FATAL WARNING messages but not DEBUG INFO. self.restart_felix_no_config_file(host3) levels = { "DEBUG": False, "INFO": False, "WARNING": True, "FATAL": True } self.check_log_levels(host3, new_path, levels, 3) # Should have error message when log severity is WARNING. # This could take up to 20 retries waiting for an ERROR messages. self.remove_ipset_command(host3) self.check_log_levels(host3, new_path, {"ERROR": True}, retries=20) # Should not expect DEBUG INFO messages. levels = {"DEBUG": False, "INFO": False} self.check_log_levels(host3, new_path, levels, 3) self.restore_ipset_command(host3) # Restore log config self.add_felix_config(conf_name, { 'logFilePath': default, 'LogSeverityFile': 'INFO' }) self.restart_felix_no_config_file(host3) host3.cleanup(ignore_list=["Received OS signal terminated", "ipsets"])