@@ -85,6 +85,7 @@ public void setUp() {
8585 @ Test
8686 public void testOPCUAServerSink () throws Exception {
8787 int tcpPort = -1 ;
88+ int httpsPort = -1 ;
8889 try (final SyncConfigNodeIServiceClient client =
8990 (SyncConfigNodeIServiceClient ) env .getLeaderConfigNodeConnection ()) {
9091
@@ -101,7 +102,7 @@ public void testOPCUAServerSink() throws Exception {
101102 while (true ) {
102103 final int [] ports = EnvUtils .searchAvailablePorts ();
103104 tcpPort = ports [0 ];
104- final int httpsPort = ports [1 ];
105+ httpsPort = ports [1 ];
105106 sinkAttributes .put ("tcp.port" , Integer .toString (tcpPort ));
106107 sinkAttributes .put ("https.port" , Integer .toString (httpsPort ));
107108
@@ -133,10 +134,18 @@ public void testOPCUAServerSink() throws Exception {
133134 break ;
134135 }
135136
137+ // Create the region first to avoid tsFile parsing
138+ TestUtils .executeNonQueries (
139+ env ,
140+ Arrays .asList (
141+ "create aligned timeSeries root.db.opc(value double, quality boolean, other int32)" ,
142+ "insert into root.db.opc(time, value, quality, other) values (0, 0, true, 1)" ),
143+ null );
144+
136145 while (true ) {
137146 final int [] ports = EnvUtils .searchAvailablePorts ();
138147 tcpPort = ports [0 ];
139- final int httpsPort = ports [1 ];
148+ httpsPort = ports [1 ];
140149 sinkAttributes .put ("tcp.port" , Integer .toString (tcpPort ));
141150 sinkAttributes .put ("https.port" , Integer .toString (httpsPort ));
142151 sinkAttributes .put ("with-quality" , "true" );
@@ -166,12 +175,9 @@ public void testOPCUAServerSink() throws Exception {
166175 break ;
167176 }
168177
169- // Create aligned timeSeries to avoid tsFile parsing
170- TestUtils .executeNonQueries (
178+ TestUtils .executeNonQuery (
171179 env ,
172- Arrays .asList (
173- "create aligned timeSeries root.db.opc(value double, quality boolean, other int32)" ,
174- "insert into root.db.opc(time, value, quality, other) values (1, 1, false, 1)" ),
180+ "insert into root.db.opc(time, value, quality, other) values (1, 1, false, 1)" ,
175181 null );
176182
177183 long startTime = System .currentTimeMillis ();
@@ -241,11 +247,17 @@ public void testOPCUAServerSink() throws Exception {
241247 sinkAttributes .put ("password" , "conflict" );
242248 try {
243249 TestUtils .executeNonQuery (
244- env , "create pipe test1 ('sink'='opc-ua-sink', 'password'='conflict')" , null );
250+ env ,
251+ String .format (
252+ "create pipe test1 ('sink'='opc-ua-sink', 'password'='conflict@pswd', 'tcp.port'='%s', 'https.port'='%s')" ,
253+ tcpPort , httpsPort ),
254+ null );
245255 Assert .fail ();
246256 } catch (final Exception e ) {
247257 Assert .assertEquals (
248- "org.apache.iotdb.jdbc.IoTDBSQLException: 1107: The existing server with tcp port 12686 and https port 8443's password **** conflicts to the new password ****, reject reusing." ,
258+ String .format (
259+ "org.apache.iotdb.jdbc.IoTDBSQLException: 1107: The existing server with tcp port %s and https port %s's password **** conflicts to the new password ****, reject reusing." ,
260+ tcpPort , httpsPort ),
249261 e .getMessage ());
250262 }
251263 } finally {
0 commit comments