Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq;
import org.apache.iotdb.db.it.utils.TestUtils;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
Expand All @@ -44,13 +45,26 @@ public class IoTDBPipeWriteBackSinkIT extends AbstractPipeDualTreeModelManualIT

@Test
public void testWriteBackSinkWithTargetDatabaseForTreeModel() throws Exception {
testWriteBackSinkWithTargetDatabaseForTreeModel("root.target.db");
}

@Test
public void testWriteBackSinkPreservesTreeModelTargetDatabaseCase() throws Exception {
testWriteBackSinkWithTargetDatabaseForTreeModel("TargetDB");
}

private void testWriteBackSinkWithTargetDatabaseForTreeModel(final String targetDatabase)
throws Exception {
final String qualifiedTargetDatabase = PathUtils.qualifyDatabaseName(targetDatabase);
TestUtils.executeNonQueries(
senderEnv,
Arrays.asList(
"create database root.source",
"create timeseries root.source.d1.s1 with datatype=INT32,encoding=PLAIN",
"create database root.target.db",
"create timeseries root.target.db.d1.s1 with datatype=INT32,encoding=PLAIN"),
"create database " + qualifiedTargetDatabase,
"create timeseries "
+ qualifiedTargetDatabase
+ ".d1.s1 with datatype=INT32,encoding=PLAIN"),
null);

try (final SyncConfigNodeIServiceClient client =
Expand All @@ -65,7 +79,7 @@ public void testWriteBackSinkWithTargetDatabaseForTreeModel() throws Exception {
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "write-back-sink");
sinkAttributes.put("sink.database", "root.target.db");
sinkAttributes.put("sink.database", targetDatabase);
sinkAttributes.put("user", "root");

final TSStatus status =
Expand All @@ -89,8 +103,8 @@ public void testWriteBackSinkWithTargetDatabaseForTreeModel() throws Exception {

TestUtils.assertDataEventuallyOnEnv(
senderEnv,
"select * from root.target.db.**",
"Time,root.target.db.d1.s1,",
"select * from " + qualifiedTargetDatabase + ".**",
"Time," + qualifiedTargetDatabase + ".d1.s1,",
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("1,1,", "2,2,"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ private void customizeTargetDatabase(final String targetDatabase) {
// runtime model. Normalize one configured target database to both model names, and later use
// the one matching the incoming event model.
if (PathUtils.isTableModelDatabase(targetDatabase)) {
// Table-model database names are case-insensitive, while tree-model paths are case-sensitive.
targetTableModelDatabaseName = targetDatabase.toLowerCase(Locale.ENGLISH);
targetTreeModelDatabaseName =
validateAndNormalizeTreeModelDatabaseName(
PathUtils.qualifyDatabaseName(targetTableModelDatabaseName));
validateAndNormalizeTreeModelDatabaseName(PathUtils.qualifyDatabaseName(targetDatabase));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public void testWriteBackSinkTargetDatabaseCustomization() throws Exception {
"testtarget", getWriteBackSinkDatabaseName(sink, "targetTableModelDatabaseName"));
Assert.assertNull(getWriteBackSinkDatabaseName(sink, "invalidTargetTableModelDatabaseName"));
Assert.assertEquals(
"root.testtarget", getWriteBackSinkDatabaseName(sink, "targetTreeModelDatabaseName"));
"root.TestTarget", getWriteBackSinkDatabaseName(sink, "targetTreeModelDatabaseName"));
}

try (final WriteBackSink sink = createCustomizedWriteBackSink("root.target")) {
Expand Down
Loading