fix: harden jt808 tdengine ingestion
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pathlib
|
||||
import types
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from tools import jt808_e2e_smoke as smoke
|
||||
|
||||
@@ -70,11 +71,64 @@ class Jt808E2ESmokeTest(unittest.TestCase):
|
||||
self.assertTrue(sqls[0].endswith("frame-1.bin'"))
|
||||
self.assertTrue(sqls[1].endswith("frame-2.bin'"))
|
||||
|
||||
def test_verify_tdengine_raw_frames_allows_probe_without_visible_raw_uri(self):
|
||||
verified = smoke.verify_tdengine_raw_frames(
|
||||
"http://localhost:6041/rest/sql/vehicle_ts",
|
||||
"root",
|
||||
"taosdata",
|
||||
[],
|
||||
0,
|
||||
1,
|
||||
)
|
||||
|
||||
self.assertEqual(verified, 0)
|
||||
|
||||
def test_expected_history_count_waits_for_pagination_sample(self):
|
||||
args = types.SimpleNamespace(frames=3, expect_history_count=1, verify_pagination=True)
|
||||
|
||||
self.assertEqual(smoke.expected_history_count(args), 2)
|
||||
|
||||
def test_send_phone_workload_can_run_session_phones_with_workers(self):
|
||||
event_time = smoke.parse_event_time("2024-01-02T03:04:05")
|
||||
args = types.SimpleNamespace(
|
||||
connection_mode="session",
|
||||
tcp_host="127.0.0.1",
|
||||
tcp_port=808,
|
||||
frames=3,
|
||||
tcp_timeout=1,
|
||||
rate=0,
|
||||
linger_ms=0,
|
||||
post_register_ms=0,
|
||||
require_register_ack=True,
|
||||
workers=2,
|
||||
)
|
||||
calls = []
|
||||
|
||||
def fake_send_phone_sequence(host, port, phone, phone_index, frames, sent_event_time,
|
||||
timeout, rate, linger_ms, post_register_ms):
|
||||
calls.append((host, port, phone, phone_index, frames, sent_event_time,
|
||||
timeout, rate, linger_ms, post_register_ms))
|
||||
return b"ack", frames
|
||||
|
||||
with mock.patch.object(smoke, "send_phone_sequence", side_effect=fake_send_phone_sequence):
|
||||
result = smoke.send_phone_workload(
|
||||
args,
|
||||
["13079962000", "13079962001", "13079962002"],
|
||||
event_time,
|
||||
)
|
||||
|
||||
self.assertEqual(result.sent_registers, 3)
|
||||
self.assertEqual(result.sent_locations, 9)
|
||||
self.assertGreater(result.elapsed_seconds, 0)
|
||||
self.assertEqual(
|
||||
sorted((call[2], call[3], call[4]) for call in calls),
|
||||
[
|
||||
("13079962000", 0, 3),
|
||||
("13079962001", 1, 3),
|
||||
("13079962002", 2, 3),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user