spl2-testing-framework 1.0.0b1__tar.gz → 1.0.1b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/PKG-INFO +1 -1
  2. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/pyproject.toml +2 -3
  3. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/jobs/cloud_job.py +20 -22
  4. spl2_testing_framework-1.0.1b1/spl2_testing_framework/tools/jobs/test_cloud_job.py +113 -0
  5. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/LICENSE +0 -0
  6. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/README.md +0 -0
  7. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/__init__.py +0 -0
  8. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/conftest.py +0 -0
  9. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/launch_remotely_spl2.py +0 -0
  10. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/logger_manager.py +0 -0
  11. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/pytest.ini.sample +0 -0
  12. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/single_spl2_file_runner.py +0 -0
  13. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/spl2_test_config.json +0 -0
  14. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/spl2_utils/assertions.spl2 +0 -0
  15. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/spl2_utils/logs_to_metrics.spl2 +0 -0
  16. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/test_runner.py +0 -0
  17. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/__init__.py +0 -0
  18. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/jobs/__init__.py +0 -0
  19. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/jobs/cli_job.py +0 -0
  20. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/jobs/job.py +0 -0
  21. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/jobs/splunk_job.py +0 -0
  22. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/performance.py +0 -0
  23. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/results.py +0 -0
  24. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/search_clients/__init__.py +0 -0
  25. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/search_clients/cli_search_client.py +0 -0
  26. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/search_clients/cloud_search_client.py +0 -0
  27. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/search_clients/search_client.py +0 -0
  28. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/search_clients/splunk_search_client.py +0 -0
  29. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/spl2test_runner.py +0 -0
  30. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/test_discovery.py +0 -0
  31. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/test_types.py +0 -0
  32. {spl2_testing_framework-1.0.0b1 → spl2_testing_framework-1.0.1b1}/spl2_testing_framework/tools/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spl2-testing-framework
3
- Version: 1.0.0b1
3
+ Version: 1.0.1b1
4
4
  Summary: SPL2 Testing Framework
5
5
  Home-page: https://cd.splunkdev.com/data-availability/spl2-content-tools
6
6
  Keywords: SPL2 testing framework
@@ -16,13 +16,13 @@
16
16
 
17
17
  [tool.poetry]
18
18
  name = "spl2-testing-framework"
19
- version = "1.0.0-beta.1"
19
+ version = "1.0.1-beta.1"
20
20
  description = "SPL2 Testing Framework"
21
21
  authors = ["mgazda-splunk <mgazda@splunk.com>"]
22
22
  readme = "README.md"
23
23
  keywords = ["SPL2 testing framework"]
24
24
  repository = "https://cd.splunkdev.com/data-availability/spl2-content-tools"
25
- exclude=["spl2_testing_framework/tests/"]
25
+ exclude = ["spl2_testing_framework/tests/"]
26
26
 
27
27
  [[tool.poetry.packages]]
28
28
  include = "spl2_testing_framework"
@@ -49,7 +49,6 @@ requires = ["poetry-core"]
49
49
  build-backend = "poetry.core.masonry.api"
50
50
 
51
51
 
52
-
53
52
  [[tool.poetry.source]]
54
53
  name = "pypi-test"
55
54
  url = "https://repo.splunkdev.net/artifactory/api/pypi/pypi-test"
@@ -19,7 +19,23 @@ from requests import Response
19
19
  from .job import Job
20
20
 
21
21
 
22
- class CloudJob(Job):
22
+ class CloudBaseJob(Job):
23
+ @property
24
+ def _query_details(self) -> dict:
25
+ return {
26
+ "earliest": "-30m@m",
27
+ "latest": "now",
28
+ "profile": "ingestProcessor",
29
+ "runtime": "ingest.preview",
30
+ "collectFieldSummary": True,
31
+ "collectTimeBuckets": True,
32
+ "extractFields": "all",
33
+ "enablePreview": True,
34
+ "allowSideEffects": False,
35
+ }
36
+
37
+
38
+ class CloudJob(CloudBaseJob):
23
39
  """A job that is executed on the cloud tenant in unit tests."""
24
40
 
25
41
  def create(self):
@@ -39,16 +55,7 @@ class CloudJob(Job):
39
55
  "module": self.test_module,
40
56
  "namespace": "",
41
57
  "queryParameters": {
42
- "defaults": {
43
- "earliest": "-30m@m",
44
- "latest": "now",
45
- "profile": "ingestProcessor",
46
- "collectFieldSummary": True,
47
- "collectTimeBuckets": True,
48
- "extractFields": "all",
49
- "enablePreview": True,
50
- "allowSideEffects": False,
51
- },
58
+ "defaults": self._query_details,
52
59
  self.test_name: {"saveAllResults": True},
53
60
  },
54
61
  }
@@ -64,7 +71,7 @@ class CloudJob(Job):
64
71
  ]
65
72
 
66
73
 
67
- class CloudSimpleJob(Job):
74
+ class CloudSimpleJob(CloudBaseJob):
68
75
  """A job that is executed on the cloud tenant in box tests."""
69
76
 
70
77
  def __init__(
@@ -80,16 +87,7 @@ class CloudSimpleJob(Job):
80
87
  "module": self.code_module_content,
81
88
  "namespace": "shared.pipelines",
82
89
  "queryParameters": {
83
- "defaults": {
84
- "earliest": "-30m@m",
85
- "latest": "now",
86
- "profile": "ingestProcessor",
87
- "collectFieldSummary": True,
88
- "collectTimeBuckets": True,
89
- "extractFields": "all",
90
- "enablePreview": True,
91
- "allowSideEffects": False,
92
- },
90
+ "defaults": self._query_details,
93
91
  "pipeline": {"saveAllResults": False},
94
92
  },
95
93
  }
@@ -0,0 +1,113 @@
1
+ #
2
+ # Copyright 2025 Splunk Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ import unittest
18
+ from unittest.mock import MagicMock
19
+ from requests import Response
20
+
21
+ from spl2_testing_framework.tools.jobs.cloud_job import CloudJob, CloudSimpleJob
22
+
23
+
24
+ class TestCloudJob(unittest.TestCase):
25
+ def setUp(self):
26
+ self.job = CloudJob(
27
+ code_module_name="test_code_module",
28
+ code_module_content="test_content",
29
+ test_name="test_name",
30
+ test_content="test_code",
31
+ )
32
+
33
+ def test_create_sets_job_content(self):
34
+ self.job.create()
35
+ self.assertIn("wipModules", self.job.job_content)
36
+ self.assertIn("queryParameters", self.job.job_content)
37
+ self.assertEqual(
38
+ "import * from test_code_module\ntest_code", self.job.job_content["module"]
39
+ )
40
+
41
+ def test_assign_ids_from_response_success(self):
42
+ response = MagicMock(spec=Response)
43
+ response.ok = True
44
+ response.json.return_value = {
45
+ "queryParameters": {"test_name": {"sid": "12345"}}
46
+ }
47
+ self.job._assign_ids_from_response(response)
48
+ self.assertEqual("12345", self.job.ids["test_name"])
49
+
50
+ def test_assign_ids_from_response_failure(self):
51
+ response = MagicMock(spec=Response)
52
+ response.ok = False
53
+ response.status_code = 400
54
+ response.content = b"error"
55
+ with self.assertRaises(Exception):
56
+ self.job._assign_ids_from_response(response)
57
+
58
+ def test_create_sets_query_details(self):
59
+ self.job.create()
60
+ defaults = self.job.job_content["queryParameters"]["defaults"]
61
+ self.assertEqual(defaults["earliest"], "-30m@m")
62
+ self.assertEqual(defaults["latest"], "now")
63
+ self.assertEqual(defaults["profile"], "ingestProcessor")
64
+ self.assertEqual(defaults["runtime"], "ingest.preview")
65
+ self.assertTrue(defaults["collectFieldSummary"])
66
+ self.assertTrue(defaults["collectTimeBuckets"])
67
+ self.assertEqual(defaults["extractFields"], "all")
68
+ self.assertTrue(defaults["enablePreview"])
69
+ self.assertFalse(defaults["allowSideEffects"])
70
+
71
+
72
+ class TestCloudSimpleJob(unittest.TestCase):
73
+ def setUp(self):
74
+ self.job = CloudSimpleJob(
75
+ source="src",
76
+ code_module_name="mod",
77
+ code_module_content="code",
78
+ test_name="pipeline",
79
+ )
80
+
81
+ def test_create_sets_job_content(self):
82
+ self.job.create()
83
+ self.assertIn("wipModules", self.job.job_content)
84
+ self.assertIn("queryParameters", self.job.job_content)
85
+ self.assertEqual("shared.pipelines", self.job.job_content["namespace"])
86
+
87
+ def test_assign_ids_from_response_success(self):
88
+ response = MagicMock(spec=Response)
89
+ response.ok = True
90
+ response.json.return_value = {
91
+ "queryParameters": {
92
+ "destination": {"sid": "dest123"},
93
+ "metrics_destination": {"sid": "met123"},
94
+ }
95
+ }
96
+ self.job._assign_ids_from_response(response)
97
+ self.assertEqual("dest123", self.job.ids["destination"])
98
+ self.assertEqual("met123", self.job.ids["metrics_destination"])
99
+
100
+ def test_assign_ids_from_response_missing_keys(self):
101
+ response = MagicMock(spec=Response)
102
+ response.ok = True
103
+ response.json.return_value = {"queryParameters": {}}
104
+ # Should not raise
105
+ self.job._assign_ids_from_response(response)
106
+
107
+ def test_assign_ids_from_response_failure(self):
108
+ response = MagicMock(spec=Response)
109
+ response.ok = False
110
+ response.status_code = 500
111
+ response.content = b"fail"
112
+ with self.assertRaises(Exception):
113
+ self.job._assign_ids_from_response(response)