From a02b2ce263734e0a395801f6b44b3e1997539366 Mon Sep 17 00:00:00 2001 From: Szymon Date: Tue, 15 Oct 2024 09:56:24 +0200 Subject: [PATCH 1/5] update pipelines so they would be testing python3.13 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f660e8e..0024c783 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: matrix: os: - ubuntu-latest - python: [ 3.7, 3.9] + python: [ 3.7, 3.9, 3.13] splunk-version: - "8.1" - "8.2" From 6ec2559b79cccb4f550c675ae3749fa4c66e48a2 Mon Sep 17 00:00:00 2001 From: Szymon Date: Thu, 24 Oct 2024 09:20:34 +0200 Subject: [PATCH 2/5] remove commands used to run test directly from setup.py --- setup.py | 111 +------------------------------------------------------ 1 file changed, 1 insertion(+), 110 deletions(-) diff --git a/setup.py b/setup.py index c80ddf37..d19a09eb 100755 --- a/setup.py +++ b/setup.py @@ -14,124 +14,15 @@ # License for the specific language governing permissions and limitations # under the License. -from setuptools import setup, Command - -import os -import sys +from setuptools import setup import splunklib -failed = False - -def run_test_suite(): - import unittest - - def mark_failed(): - global failed - failed = True - - class _TrackingTextTestResult(unittest._TextTestResult): - def addError(self, test, err): - unittest._TextTestResult.addError(self, test, err) - mark_failed() - - def addFailure(self, test, err): - unittest._TextTestResult.addFailure(self, test, err) - mark_failed() - - class TrackingTextTestRunner(unittest.TextTestRunner): - def _makeResult(self): - return _TrackingTextTestResult( - self.stream, self.descriptions, self.verbosity) - - original_cwd = os.path.abspath(os.getcwd()) - os.chdir('tests') - suite = unittest.defaultTestLoader.discover('.') - runner = TrackingTextTestRunner(verbosity=2) - runner.run(suite) - os.chdir(original_cwd) - - return failed - - -def run_test_suite_with_junit_output(): - try: - import unittest2 as unittest - except ImportError: - import unittest - import xmlrunner - original_cwd = os.path.abspath(os.getcwd()) - os.chdir('tests') - suite = unittest.defaultTestLoader.discover('.') - xmlrunner.XMLTestRunner(output='../test-reports').run(suite) - os.chdir(original_cwd) - - -class CoverageCommand(Command): - """setup.py command to run code coverage of the test suite.""" - description = "Create an HTML coverage report from running the full test suite." - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - import coverage - except ImportError: - print("Could not import coverage. Please install it and try again.") - exit(1) - cov = coverage.coverage(source=['splunklib']) - cov.start() - run_test_suite() - cov.stop() - cov.html_report(directory='coverage_report') - - -class TestCommand(Command): - """setup.py command to run the whole test suite.""" - description = "Run test full test suite." - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - failed = run_test_suite() - if failed: - sys.exit(1) - - -class JunitXmlTestCommand(Command): - """setup.py command to run the whole test suite.""" - description = "Run test full test suite with JUnit-formatted output." - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - run_test_suite_with_junit_output() - - setup( author="Splunk, Inc.", author_email="devinfo@splunk.com", - cmdclass={'coverage': CoverageCommand, - 'test': TestCommand, - 'testjunit': JunitXmlTestCommand}, - description="The Splunk Software Development Kit for Python.", license="http://www.apache.org/licenses/LICENSE-2.0", From 1b441352b332dcd50960f5818723b84b731c903a Mon Sep 17 00:00:00 2001 From: Szymon Date: Thu, 24 Oct 2024 09:28:32 +0200 Subject: [PATCH 3/5] modify tox ini not to use deprecated libraries for unittests and add python 3.13 to tests --- tox.ini | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index e45dbfb9..e69c2e6a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = clean,docs,py37,py39 +envlist = clean,docs,py37,py39,313 skipsdist = {env:TOXBUILD:false} [testenv:pep8] @@ -28,8 +28,6 @@ setenv = SPLUNK_HOME=/opt/splunk allowlist_externals = make deps = pytest pytest-cov - xmlrunner - unittest-xml-reporting python-dotenv distdir = build From 2f2e17465656b647d5e2bf1fc039ba67eb0b9588 Mon Sep 17 00:00:00 2001 From: Szymon Date: Thu, 24 Oct 2024 10:13:43 +0200 Subject: [PATCH 4/5] modify testing traceback so it would filter out additions to tracback coming from python 3.13 --- tests/modularinput/test_script.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/modularinput/test_script.py b/tests/modularinput/test_script.py index bb471710..49c25972 100644 --- a/tests/modularinput/test_script.py +++ b/tests/modularinput/test_script.py @@ -252,6 +252,7 @@ def stream_events(self, inputs, ew): # Remove paths and line numbers err = re.sub(r'File "[^"]+', 'File "...', err.getvalue()) err = re.sub(r'line \d+', 'line 123', err) + err = re.sub(r' +~+\^+', '', err) assert out.getvalue() == "" assert err == ( From a8948f8f7baff673a043797a6ec085dcf2a89534 Mon Sep 17 00:00:00 2001 From: Szymon Date: Tue, 29 Oct 2024 08:28:05 +0100 Subject: [PATCH 5/5] resolve conflicts --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e4fcd4a..c8e67c15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Run docker-compose + - name: Run docker compose run: SPLUNK_VERSION=${{matrix.splunk-version}} docker compose up -d - name: Setup Python