Skip to content
Draft
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 @@ -159,7 +159,8 @@ public void testBasicAlterPipe() throws Exception {

// Alter pipe (replace)
statement.execute(
"alter pipe a2b replace source ('capture.table'='true','''source'='iotdb-source', 'table-name'='test','database-name'='test')");
"alter pipe a2b replace source ('capture.table'='true','source'='iotdb-source',"
+ "'''source'='do-nothing-source','table-name'='test','database-name'='test')");

// Show pipe
{
Expand All @@ -175,6 +176,7 @@ public void testBasicAlterPipe() throws Exception {
Assert.assertEquals("STOPPED", showPipeResult.get(0).state);
// check configurations
Assert.assertTrue(showPipeResult.get(0).pipeExtractor.contains("source=iotdb-source"));
Assert.assertFalse(showPipeResult.get(0).pipeExtractor.contains("'source="));
Assert.assertTrue(showPipeResult.get(0).pipeExtractor.contains("database-name=test"));
Assert.assertTrue(showPipeResult.get(0).pipeExtractor.contains("table-name=test"));
Assert.assertFalse(showPipeResult.get(0).pipeExtractor.contains("mode.streaming=true"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void testLifeCycleLogMode() throws Exception {

sourceAttributes.put("capture.table", "true");
sourceAttributes.put("__system.sql-dialect", "table");
sourceAttributes.put("source.mode", "forced-log");
sourceAttributes.put("source.realtime.mode", "forced-log");
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "iotdb-thrift-sink");
Expand Down Expand Up @@ -324,7 +324,7 @@ public void testLifeCycleHybridMode() throws Exception {

sourceAttributes.put("capture.table", "true");
sourceAttributes.put("__system.sql-dialect", "table");
sourceAttributes.put("source.mode", "hybrid");
sourceAttributes.put("source.realtime.mode", "hybrid");
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "iotdb-thrift-sink");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ public void testZstdCompressorLevel() throws Exception {
receiverIp,
receiverPort));
fail();
} catch (SQLException e) {
// Make sure the error message in IoTDBConnector.java is returned
} catch (SQLException failure) {
Assert.assertEquals(TSStatusCode.PIPE_ERROR.getStatusCode(), failure.getErrorCode());
Assert.assertTrue(
e.getMessage().contains("Zstd compression level should be in the range"));
failure.getMessage(), failure.getMessage().contains("compressor.zstd.level"));
}

try {
Expand All @@ -358,10 +358,10 @@ public void testZstdCompressorLevel() throws Exception {
receiverIp,
receiverPort));
fail();
} catch (SQLException e) {
// Make sure the error message in IoTDBConnector.java is returned
} catch (SQLException failure) {
Assert.assertEquals(TSStatusCode.PIPE_ERROR.getStatusCode(), failure.getErrorCode());
Assert.assertTrue(
e.getMessage().contains("Zstd compression level should be in the range"));
failure.getMessage(), failure.getMessage().contains("compressor.zstd.level"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void testLifeCycleLogMode() throws Exception {
final Map<String, String> processorAttributes = new HashMap<>();
final Map<String, String> sinkAttributes = new HashMap<>();

sourceAttributes.put("source.mode", "log");
sourceAttributes.put("source.realtime.mode", "log");
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "iotdb-thrift-sink");
Expand Down Expand Up @@ -380,7 +380,7 @@ public void testLifeCycleFileMode() throws Exception {
final Map<String, String> processorAttributes = new HashMap<>();
final Map<String, String> sinkAttributes = new HashMap<>();

sourceAttributes.put("source.mode", "file");
sourceAttributes.put("source.realtime.mode", "file");
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "iotdb-thrift-sink");
Expand Down Expand Up @@ -446,7 +446,7 @@ public void testLifeCycleHybridMode() throws Exception {
final Map<String, String> processorAttributes = new HashMap<>();
final Map<String, String> sinkAttributes = new HashMap<>();

sourceAttributes.put("source.mode", "hybrid");
sourceAttributes.put("source.realtime.mode", "hybrid");
sourceAttributes.put("user", "root");

sinkAttributes.put("sink", "iotdb-thrift-sink");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,73 @@ public void testInvalidParameter() throws Exception {
}
}

@Test
public void testInvalidSinkPortOnCreateAndAlter() throws Exception {
final DataNodeWrapper receiverDataNode = receiverEnv.getDataNodeWrapper(0);
final String receiverIp = receiverDataNode.getIp();
final int receiverPort = receiverDataNode.getPort();

try (final SyncConfigNodeIServiceClient client =
(SyncConfigNodeIServiceClient) senderEnv.getLeaderConfigNodeConnection();
final Connection connection = senderEnv.getConnection();
final Statement statement = connection.createStatement()) {
statement.execute(
String.format(
"create pipe p1"
+ " with source ()"
+ " with processor ()"
+ " with sink ("
+ "'sink'='iotdb-thrift-sink',"
+ "'sink.ip'='%s',"
+ "'sink.port'='%s',"
+ "'sink.batch.enable'='false')",
receiverIp, receiverPort));

assertInvalidSinkPort(
statement,
String.format(
"create pipe p2"
+ " with source ()"
+ " with processor ()"
+ " with sink ("
+ "'sink'='iotdb-thrift-sink',"
+ "'sink.ip'='%s',"
+ "'sink.port'='65536',"
+ "'sink.batch.enable'='false')",
receiverIp));

statement.execute("stop pipe p1");
assertInvalidSinkPort(
statement,
String.format(
"alter pipe p1 replace sink ("
+ "'sink'='iotdb-thrift-sink',"
+ "'sink.ip'='%s',"
+ "'sink.port'='65536',"
+ "'sink.batch.enable'='false')",
receiverIp));

final List<TShowPipeInfo> showPipeResult =
client.showPipe(new TShowPipeReq().setUserName(SessionConfig.DEFAULT_USER)).pipeInfoList;
showPipeResult.removeIf(pipe -> pipe.getId().startsWith("__consensus"));
Assert.assertEquals(1, showPipeResult.size());
Assert.assertEquals("p1", showPipeResult.get(0).id);
Assert.assertEquals("STOPPED", showPipeResult.get(0).state);
Assert.assertTrue(showPipeResult.get(0).pipeConnector.contains("port=" + receiverPort));
}
}

private void assertInvalidSinkPort(final Statement statement, final String sql)
throws SQLException {
try {
statement.execute(sql);
fail("Expected invalid sink.port to be rejected");
} catch (final SQLException failure) {
Assert.assertEquals(TSStatusCode.PIPE_ERROR.getStatusCode(), failure.getErrorCode());
Assert.assertTrue(failure.getMessage(), failure.getMessage().contains("sink.port"));
}
}

// Traversal paths, absolute paths and platform-reserved directory names must be rejected.
@Test
public void testDirectoryErrors() throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,10 @@ private void assertCreateZstdPipeFailed(
try {
createZstdPipe(statement, pipeName, sourcePattern, zstdLevel, receiverIp, receiverPort);
fail();
} catch (final SQLException e) {
Assert.assertTrue(e.getMessage().contains("Zstd compression level should be in the range"));
} catch (final SQLException failure) {
Assert.assertEquals(TSStatusCode.PIPE_ERROR.getStatusCode(), failure.getErrorCode());
Assert.assertTrue(
failure.getMessage(), failure.getMessage().contains("compressor.zstd.level"));
}
}

Expand Down
Loading
Loading