Validates that a streaming logs connection will stream logs with sampling.
(self, tmp_path, component_tests_config)
| 88 | |
| 89 | @pytest.mark.asyncio |
| 90 | async def test_streaming_logs_sampling(self, tmp_path, component_tests_config): |
| 91 | """ |
| 92 | Validates that a streaming logs connection will stream logs with sampling. |
| 93 | """ |
| 94 | print("test_streaming_logs_sampling") |
| 95 | config = component_tests_config(cfd_mode=CfdModes.NAMED, provide_ingress=False) |
| 96 | LOGGER.debug(config) |
| 97 | config_path = write_config(tmp_path, config.full_config) |
| 98 | with start_cloudflared(tmp_path, config, cfd_args=["run", "--hello-world"], new_process=True): |
| 99 | wait_tunnel_ready(tunnel_url=config.get_url(), require_min_connections=1) |
| 100 | cfd_cli = CloudflaredCli(config, config_path, LOGGER) |
| 101 | url = cfd_cli.get_management_wsurl("logs", config, config_path, resource="logs") |
| 102 | async with connect(url, open_timeout=5, close_timeout=5) as websocket: |
| 103 | # send start_streaming with info logs only |
| 104 | await websocket.send(json.dumps({ |
| 105 | "type": "start_streaming", |
| 106 | "filters": { |
| 107 | "sampling": 0.5, |
| 108 | "events": ["http"] |
| 109 | } |
| 110 | })) |
| 111 | # don't expect any http logs |
| 112 | count = await generate_and_validate_http_events(websocket, config.get_url(), 10) |
| 113 | assert count < (10 * 2) # There are typically always two log lines for http requests (request and response) |
| 114 | # send stop_streaming |
| 115 | await websocket.send('{"type": "stop_streaming"}') |
| 116 | |
| 117 | @pytest.mark.asyncio |
| 118 | async def test_streaming_logs_actor_override(self, tmp_path, component_tests_config): |
nothing calls this directly
no test coverage detected