|
1 | 1 | import pytest |
2 | 2 | from settings import TEST_DATA |
3 | 3 | from suite.utils.resources_utils import ( |
| 4 | + extract_block, |
4 | 5 | get_nginx_template_conf, |
5 | 6 | replace_configmap_from_yaml, |
6 | 7 | wait_before_test, |
|
25 | 26 |
|
26 | 27 | @pytest.mark.otel |
27 | 28 | class TestOtel: |
28 | | - def extract_block(self, nginx_config, block_name): |
29 | | - """ |
30 | | - Extract a block of configuration from the nginx config file. |
31 | | -
|
32 | | - :param nginx_config: The nginx config file content as a string. |
33 | | - :param block_name: The name of the block to extract. |
34 | | - :return: The extracted block as a string. |
35 | | - """ |
36 | | - start = nginx_config.find(block_name) |
37 | | - end = nginx_config.find("}", start) + 1 |
38 | | - return nginx_config[start:end] |
39 | 29 |
|
40 | 30 | def test_otel_not_enabled( |
41 | 31 | self, |
@@ -96,7 +86,7 @@ def test_otel_endpoint( |
96 | 86 | print("Step 2: Ensure that the otel module is loaded") |
97 | 87 | assert otel_module in (nginx_config) |
98 | 88 |
|
99 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 89 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
100 | 90 |
|
101 | 91 | print("Step 3: Ensure that the otel_exporter is enabled") |
102 | 92 | assert "otel_exporter" in (exporter_block) |
@@ -147,7 +137,7 @@ def test_otel_header( |
147 | 137 | print("Step 2: Ensure that the otel module is loaded") |
148 | 138 | assert otel_module in (nginx_config) |
149 | 139 |
|
150 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 140 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
151 | 141 |
|
152 | 142 | print("Step 3: Ensure that the otel_exporter is enabled") |
153 | 143 | assert "otel_exporter" in (exporter_block) |
@@ -199,7 +189,7 @@ def test_otel_header_name_only( |
199 | 189 | print("Step 2: Ensure that the otel module is loaded") |
200 | 190 | assert otel_module in (nginx_config) |
201 | 191 |
|
202 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 192 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
203 | 193 |
|
204 | 194 | print("Step 3: Ensure that the otel_exporter is enabled") |
205 | 195 | assert "otel_exporter" in (exporter_block) |
@@ -251,7 +241,7 @@ def test_otel_header_value_only( |
251 | 241 | print("Step 2: Ensure that the otel module is loaded") |
252 | 242 | assert otel_module in (nginx_config) |
253 | 243 |
|
254 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 244 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
255 | 245 |
|
256 | 246 | print("Step 3: Ensure that the otel_exporter is enabled") |
257 | 247 | assert "otel_exporter" in (exporter_block) |
@@ -303,7 +293,7 @@ def test_otel_service_name( |
303 | 293 | print("Step 2: Ensure that the otel module is loaded") |
304 | 294 | assert otel_module in (nginx_config) |
305 | 295 |
|
306 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 296 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
307 | 297 |
|
308 | 298 | print("Step 3: Ensure that the otel_exporter is enabled") |
309 | 299 | assert "otel_exporter" in (exporter_block) |
@@ -354,7 +344,7 @@ def test_otel_trace( |
354 | 344 | print("Step 2: Ensure that the otel module is loaded") |
355 | 345 | assert otel_module in (nginx_config) |
356 | 346 |
|
357 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 347 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
358 | 348 |
|
359 | 349 | print("Step 3: Ensure that the otel_exporter is enabled") |
360 | 350 | assert "otel_exporter" in (exporter_block) |
@@ -405,7 +395,7 @@ def test_otel_all( |
405 | 395 | print("Step 2: Ensure that the otel module is loaded") |
406 | 396 | assert otel_module in (nginx_config) |
407 | 397 |
|
408 | | - exporter_block = self.extract_block(nginx_config, "otel_exporter") |
| 398 | + exporter_block = extract_block(nginx_config, "otel_exporter") |
409 | 399 |
|
410 | 400 | print("Step 3: Ensure that the otel_exporter is enabled") |
411 | 401 | assert "otel_exporter" in (exporter_block) |
|
0 commit comments