fix: keep telemetry fields out of default history api
This commit is contained in:
@@ -82,7 +82,6 @@ lsof -nP -iTCP:32960 -sTCP:LISTEN
|
|||||||
```bash
|
```bash
|
||||||
HTTP_PORT=20200 \
|
HTTP_PORT=20200 \
|
||||||
KAFKA_CONSUMER_ENABLED=true \
|
KAFKA_CONSUMER_ENABLED=true \
|
||||||
EVENT_FILE_STORE_PATH=./target/tdengine-verification/event-store \
|
|
||||||
TDENGINE_TELEMETRY_FIELDS_ENABLED=false \
|
TDENGINE_TELEMETRY_FIELDS_ENABLED=false \
|
||||||
java -jar modules/apps/vehicle-history-app/target/vehicle-history-app.jar
|
java -jar modules/apps/vehicle-history-app/target/vehicle-history-app.jar
|
||||||
```
|
```
|
||||||
@@ -92,10 +91,10 @@ java -jar modules/apps/vehicle-history-app/target/vehicle-history-app.jar
|
|||||||
```bash
|
```bash
|
||||||
curl -sS http://127.0.0.1:20200/actuator/health
|
curl -sS http://127.0.0.1:20200/actuator/health
|
||||||
curl -sS http://127.0.0.1:20200/v3/api-docs \
|
curl -sS http://127.0.0.1:20200/v3/api-docs \
|
||||||
| grep -E '/api/event-history/jt808/locations|/api/event-history/gb32960/snapshots|/api/event-history/telemetry/fields'
|
| grep -E '/api/event-history/locations|/api/event-history/raw-frames'
|
||||||
```
|
```
|
||||||
|
|
||||||
预期:健康检查为 `UP`,OpenAPI 中包含 JT808 TDengine 分页查询接口和 GB32960 snapshot 接口。`/api/event-history/telemetry/fields` 会存在,但只有在 `TDENGINE_TELEMETRY_FIELDS_ENABLED=true` 后才会持续写入新字段数据。
|
预期:健康检查为 `UP`,OpenAPI 中包含通用位置分页查询和 RAW 帧查询接口。`/api/event-history/telemetry/fields` 只有在 `TDENGINE_TELEMETRY_FIELDS_ENABLED=true` 后才会暴露;默认高吞吐模式不暴露该接口,也不会持续写入逐字段宽表。
|
||||||
|
|
||||||
## 本机 launchctl 部署
|
## 本机 launchctl 部署
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ class PortainerComposeResourceLimitsTest {
|
|||||||
.doesNotContain("再回读共享 archive")
|
.doesNotContain("再回读共享 archive")
|
||||||
.doesNotContain("读取共享 archive 中的原始 `.bin`")
|
.doesNotContain("读取共享 archive 中的原始 `.bin`")
|
||||||
.doesNotContain("EVENT_FILE_STORE_ENABLED")
|
.doesNotContain("EVENT_FILE_STORE_ENABLED")
|
||||||
|
.doesNotContain("EVENT_FILE_STORE_PATH")
|
||||||
|
.doesNotContain("/api/event-history/telemetry/fields' 会存在")
|
||||||
.doesNotContain("/api/event-history/records");
|
.doesNotContain("/api/event-history/records");
|
||||||
assertThat(splitRunbook)
|
assertThat(splitRunbook)
|
||||||
.contains("TDengine `raw_frames`")
|
.contains("TDengine `raw_frames`")
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.lingniu.ingest.sink.kafka.KafkaEnvelopeConsumerRunner;
|
|||||||
import com.lingniu.ingest.sink.kafka.KafkaSinkProperties;
|
import com.lingniu.ingest.sink.kafka.KafkaSinkProperties;
|
||||||
import com.lingniu.ingest.sink.kafka.KafkaSinkAutoConfiguration;
|
import com.lingniu.ingest.sink.kafka.KafkaSinkAutoConfiguration;
|
||||||
import com.lingniu.ingest.tdenginehistory.TdengineHistorySchema;
|
import com.lingniu.ingest.tdenginehistory.TdengineHistorySchema;
|
||||||
|
import com.lingniu.ingest.tdenginehistory.TdengineHistoryReader;
|
||||||
import com.lingniu.ingest.tdenginehistory.TdengineHistoryWriter;
|
import com.lingniu.ingest.tdenginehistory.TdengineHistoryWriter;
|
||||||
import com.lingniu.ingest.tdenginehistory.config.TdengineHistoryAutoConfiguration;
|
import com.lingniu.ingest.tdenginehistory.config.TdengineHistoryAutoConfiguration;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
@@ -133,6 +134,27 @@ class VehicleHistoryAppCompositionTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void applicationScanDoesNotExposeTelemetryFieldControllerByDefault() {
|
||||||
|
new ApplicationContextRunner()
|
||||||
|
.withUserConfiguration(VehicleHistoryApplication.class)
|
||||||
|
.withBean(TdengineHistoryReader.class, () -> mock(TdengineHistoryReader.class))
|
||||||
|
.withPropertyValues(
|
||||||
|
"spring.cloud.nacos.config.enabled=false",
|
||||||
|
"spring.config.import=",
|
||||||
|
"lingniu.ingest.event-history.enabled=true",
|
||||||
|
"lingniu.ingest.tdengine-history.telemetry-fields-enabled=false",
|
||||||
|
"lingniu.ingest.tdengine-history.enabled=false",
|
||||||
|
"lingniu.ingest.sink.kafka.enabled=false",
|
||||||
|
"lingniu.ingest.sink.kafka.consumer.enabled=false",
|
||||||
|
"lingniu.ingest.gb32960.enabled=false")
|
||||||
|
.run(context -> {
|
||||||
|
assertThat(context).hasSingleBean(LocationHistoryController.class);
|
||||||
|
assertThat(context).hasSingleBean(RawFrameHistoryController.class);
|
||||||
|
assertThat(context).doesNotHaveBean(TelemetryFieldHistoryController.class);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createsKafkaConsumerRunnerWhenTdengineHistoryRuntimeConsumesKafka() {
|
void createsKafkaConsumerRunnerWhenTdengineHistoryRuntimeConsumesKafka() {
|
||||||
new ApplicationContextRunner()
|
new ApplicationContextRunner()
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ConditionalOnProperty(prefix = "lingniu.ingest.event-history", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(
|
||||||
|
name = {
|
||||||
|
"lingniu.ingest.event-history.enabled",
|
||||||
|
"lingniu.ingest.tdengine-history.telemetry-fields-enabled"
|
||||||
|
},
|
||||||
|
havingValue = "true")
|
||||||
@ConditionalOnBean(TdengineHistoryReader.class)
|
@ConditionalOnBean(TdengineHistoryReader.class)
|
||||||
@RequestMapping("/api/event-history/telemetry")
|
@RequestMapping("/api/event-history/telemetry")
|
||||||
@Tag(name = "telemetry-field-history-controller", description = "遥测字段历史分页查询接口。")
|
@Tag(name = "telemetry-field-history-controller", description = "遥测字段历史分页查询接口。")
|
||||||
|
|||||||
Reference in New Issue
Block a user