|
@@ -1,4 +1,4 @@
|
|
|
-// Copyright 2021-2022 EMQ Technologies Co., Ltd.
|
|
|
+// Copyright 2021-2023 EMQ Technologies Co., Ltd.
|
|
|
//
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
// you may not use this file except in compliance with the License.
|
|
@@ -123,3 +123,98 @@ func TestCheckpoint(t *testing.T) {
|
|
|
DoCheckpointRuleTest(t, tests, j, opt)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestTableJoinCheckpoint(t *testing.T) {
|
|
|
+ conf.IsTesting = true
|
|
|
+ streamList := []string{"demo", "table1"}
|
|
|
+ HandleStream(false, streamList, t)
|
|
|
+ tests := []RuleCheckpointTest{
|
|
|
+ {
|
|
|
+ RuleTest: RuleTest{
|
|
|
+ Name: `TestCheckpointRule2`,
|
|
|
+ Sql: `SELECT * FROM demo INNER JOIN table1 on demo.ts = table1.id`,
|
|
|
+ R: [][]map[string]interface{}{
|
|
|
+ {{
|
|
|
+ "id": float64(1541152486013),
|
|
|
+ "name": "name1",
|
|
|
+ "color": "red",
|
|
|
+ "size": float64(3),
|
|
|
+ "ts": float64(1541152486013),
|
|
|
+ }},
|
|
|
+ {{
|
|
|
+ "id": float64(1541152487632),
|
|
|
+ "name": "name2",
|
|
|
+ "color": "blue",
|
|
|
+ "size": float64(2),
|
|
|
+ "ts": float64(1541152487632),
|
|
|
+ }},
|
|
|
+ {{
|
|
|
+ "id": float64(1541152487632),
|
|
|
+ "name": "name2",
|
|
|
+ "color": "blue",
|
|
|
+ "size": float64(2),
|
|
|
+ "ts": float64(1541152487632),
|
|
|
+ }},
|
|
|
+ {{
|
|
|
+ "id": float64(1541152489252),
|
|
|
+ "name": "name3",
|
|
|
+ "color": "red",
|
|
|
+ "size": float64(1),
|
|
|
+ "ts": float64(1541152489252),
|
|
|
+ }},
|
|
|
+ },
|
|
|
+ M: map[string]interface{}{
|
|
|
+ "op_3_join_aligner_0_records_in_total": int64(4),
|
|
|
+ "op_3_join_aligner_0_records_out_total": int64(3),
|
|
|
+
|
|
|
+ "op_4_join_0_exceptions_total": int64(0),
|
|
|
+ "op_4_join_0_records_in_total": int64(3),
|
|
|
+ "op_4_join_0_records_out_total": int64(2),
|
|
|
+
|
|
|
+ "op_5_project_0_exceptions_total": int64(0),
|
|
|
+ "op_5_project_0_records_in_total": int64(2),
|
|
|
+ "op_5_project_0_records_out_total": int64(2),
|
|
|
+
|
|
|
+ "sink_mockSink_0_exceptions_total": int64(0),
|
|
|
+ "sink_mockSink_0_records_in_total": int64(2),
|
|
|
+ "sink_mockSink_0_records_out_total": int64(2),
|
|
|
+
|
|
|
+ "source_demo_0_exceptions_total": int64(0),
|
|
|
+ "source_demo_0_records_in_total": int64(3),
|
|
|
+ "source_demo_0_records_out_total": int64(3),
|
|
|
+
|
|
|
+ "source_table1_0_exceptions_total": int64(0),
|
|
|
+ "source_table1_0_records_in_total": int64(4),
|
|
|
+ "source_table1_0_records_out_total": int64(1),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ PauseSize: 3,
|
|
|
+ Cc: 2,
|
|
|
+ PauseMetric: map[string]interface{}{
|
|
|
+ "sink_mockSink_0_exceptions_total": int64(0),
|
|
|
+ "sink_mockSink_0_records_in_total": int64(2),
|
|
|
+ "sink_mockSink_0_records_out_total": int64(2),
|
|
|
+
|
|
|
+ "source_demo_0_exceptions_total": int64(0),
|
|
|
+ "source_demo_0_records_in_total": int64(3),
|
|
|
+ "source_demo_0_records_out_total": int64(3),
|
|
|
+
|
|
|
+ "source_table1_0_exceptions_total": int64(0),
|
|
|
+ "source_table1_0_records_in_total": int64(4),
|
|
|
+ "source_table1_0_records_out_total": int64(1),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ HandleStream(true, streamList, t)
|
|
|
+ options := []*api.RuleOption{
|
|
|
+ {
|
|
|
+ BufferLength: 100,
|
|
|
+ Qos: api.AtLeastOnce,
|
|
|
+ CheckpointInterval: 600,
|
|
|
+ SendError: true,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for j, opt := range options {
|
|
|
+ DoCheckpointRuleTest(t, tests, j, opt)
|
|
|
+ }
|
|
|
+}
|