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
2 changes: 2 additions & 0 deletions .github/workflows/cluster-it-1c1d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
-P with-integration-tests \
-DskipUTs \
-DintegrationTest.forkCount=2 \
-DDataNodeMaxDirectMemorySize=768 \
-pl integration-test \
-am
- name: Upload Artifact
Expand Down Expand Up @@ -119,6 +120,7 @@ jobs:
-P with-integration-tests \
-DskipUTs \
-DintegrationTest.forkCount=2 \
-DDataNodeMaxDirectMemorySize=768 \
-Dfailsafe.includesFile="$RUNNER_TEMP/it-shard.txt" \
-DfailIfNoTests=false \
-Dfailsafe.failIfNoSpecifiedTests=false \
Expand Down
4 changes: 2 additions & 2 deletions integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
<scalableSingleNodeMode.configNodeConsensus>Ratis</scalableSingleNodeMode.configNodeConsensus>
<scalableSingleNodeMode.configNodeNumber>1</scalableSingleNodeMode.configNodeNumber>
<scalableSingleNodeMode.dataNodeNumber>1</scalableSingleNodeMode.dataNodeNumber>
<scalableSingleNodeMode.dataRegionConsensus>IoT</scalableSingleNodeMode.dataRegionConsensus>
<scalableSingleNodeMode.dataRegionConsensus>IoTV2</scalableSingleNodeMode.dataRegionConsensus>
<scalableSingleNodeMode.dataRegionReplicaNumber>1</scalableSingleNodeMode.dataRegionReplicaNumber>
<scalableSingleNodeMode.schemaRegionConsensus>Ratis</scalableSingleNodeMode.schemaRegionConsensus>
<scalableSingleNodeMode.schemaRegionReplicaNumber>1</scalableSingleNodeMode.schemaRegionReplicaNumber>
<highPerformanceMode.configNodeConsensus>Ratis</highPerformanceMode.configNodeConsensus>
<highPerformanceMode.configNodeNumber>1</highPerformanceMode.configNodeNumber>
<highPerformanceMode.dataNodeNumber>3</highPerformanceMode.dataNodeNumber>
<highPerformanceMode.dataRegionConsensus>IoT</highPerformanceMode.dataRegionConsensus>
<highPerformanceMode.dataRegionConsensus>IoTV2</highPerformanceMode.dataRegionConsensus>
<highPerformanceMode.dataRegionReplicaNumber>2</highPerformanceMode.dataRegionReplicaNumber>
<highPerformanceMode.schemaRegionConsensus>Ratis</highPerformanceMode.schemaRegionConsensus>
<highPerformanceMode.schemaRegionReplicaNumber>3</highPerformanceMode.schemaRegionReplicaNumber>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Arrays;
import java.util.List;

import static org.apache.iotdb.consensus.ConsensusFactory.IOT_CONSENSUS_V2;
import static org.apache.iotdb.consensus.ConsensusFactory.SIMPLE_CONSENSUS;
import static org.apache.iotdb.it.env.cluster.ClusterConstant.CN_CONNECTION_TIMEOUT_MS;
import static org.apache.iotdb.it.env.cluster.ClusterConstant.CN_CONSENSUS_DIR;
Expand Down Expand Up @@ -167,7 +168,7 @@ String getNodeType() {
protected void reloadMutableFields() {
mutableCommonProperties.setProperty(CONFIG_NODE_CONSENSUS_PROTOCOL_CLASS, SIMPLE_CONSENSUS);
mutableCommonProperties.setProperty(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS, SIMPLE_CONSENSUS);
mutableCommonProperties.setProperty(DATA_REGION_CONSENSUS_PROTOCOL_CLASS, SIMPLE_CONSENSUS);
mutableCommonProperties.setProperty(DATA_REGION_CONSENSUS_PROTOCOL_CLASS, IOT_CONSENSUS_V2);

mutableCommonProperties.setProperty(SCHEMA_REPLICATION_FACTOR, "1");
mutableCommonProperties.setProperty(DATA_REPLICATION_FACTOR, "1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Arrays;
import java.util.List;

import static org.apache.iotdb.consensus.ConsensusFactory.IOT_CONSENSUS_V2;
import static org.apache.iotdb.consensus.ConsensusFactory.SIMPLE_CONSENSUS;
import static org.apache.iotdb.it.env.cluster.ClusterConstant.CONFIG_NODE_CONSENSUS_PROTOCOL_CLASS;
import static org.apache.iotdb.it.env.cluster.ClusterConstant.DATANODE_INIT_HEAP_SIZE;
Expand Down Expand Up @@ -211,7 +212,7 @@ String getNodeType() {
protected void reloadMutableFields() {
mutableCommonProperties.setProperty(CONFIG_NODE_CONSENSUS_PROTOCOL_CLASS, SIMPLE_CONSENSUS);
mutableCommonProperties.setProperty(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS, SIMPLE_CONSENSUS);
mutableCommonProperties.setProperty(DATA_REGION_CONSENSUS_PROTOCOL_CLASS, SIMPLE_CONSENSUS);
mutableCommonProperties.setProperty(DATA_REGION_CONSENSUS_PROTOCOL_CLASS, IOT_CONSENSUS_V2);

mutableCommonProperties.setProperty(SCHEMA_REPLICATION_FACTOR, "1");
mutableCommonProperties.setProperty(DATA_REPLICATION_FACTOR, "1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class RemoteServerEnv implements BaseEnv {

private final String ip_addr = System.getProperty("RemoteIp", "127.0.0.1");
private final String port = System.getProperty("RemotePort", "6667");
private final String restPort = System.getProperty("RemoteRestPort", "18080");
private final String configNodeMetricPort =
System.getProperty("RemoteConfigNodeMetricPort", "9091");

Expand Down Expand Up @@ -233,6 +234,11 @@ public List<DataNodeWrapper> getDataNodeWrapperList() {
return null;
}

@Override
public List<String> getRestUrls() {
return Collections.singletonList("http://" + remoteEndpointUrl(restPort));
}

@Override
public IConfigNodeRPCService.Iface getLeaderConfigNodeConnection() throws ClientManagerException {
return clientManager.borrowClient(new TEndPoint(ip_addr, 10710));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.iotdb.jdbc.Config;
import org.apache.iotdb.jdbc.Constant;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.UrlUtils;

import reactor.util.annotation.Nullable;

Expand Down Expand Up @@ -239,6 +240,16 @@ default void setTestClassName(String testClassName) {

List<DataNodeWrapper> getDataNodeWrapperList();

default List<String> getRestUrls() {
return getDataNodeWrapperList().stream()
.map(
node ->
"http://"
+ UrlUtils.formatTEndPointIpv4AndIpv6Url(
node.getIp(), node.getRestServicePort()))
.toList();
}

IConfigNodeRPCService.Iface getLeaderConfigNodeConnection()
throws ClientManagerException, IOException, InterruptedException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.env.CommonConfig;

import org.apache.tsfile.utils.Pair;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -61,13 +61,12 @@
@Category({ClusterIT.class})
public class IoTDBRegionMigrateWithDeletionMultiDataDirIT {

@Before
public void setUp() throws Exception {
EnvFactory.getEnv()
.getConfig()
.getCommonConfig()
.setDataReplicationFactor(2)
.setDataRegionConsensusProtocolClass(ConsensusFactory.IOT_CONSENSUS);
private void startCluster(String protocol, String mode) throws Exception {
final CommonConfig config = EnvFactory.getEnv().getConfig().getCommonConfig();
config.setDataReplicationFactor(2).setDataRegionConsensusProtocolClass(protocol);
if (ConsensusFactory.IOT_CONSENSUS_V2.equals(protocol)) {
config.setIoTConsensusV2Mode(mode);
}
EnvFactory.getEnv().getConfig().getDataNodeConfig().setDnDataDirs(MULTI_DATA_DIRS);
EnvFactory.getEnv().initClusterEnvironment(1, 3);
}
Expand All @@ -79,6 +78,23 @@ public void tearDown() throws Exception {

@Test
public void testRegionMigratePreservesDeletionWithMultiDataDirs() throws Exception {
startCluster(ConsensusFactory.IOT_CONSENSUS, null);
assertRegionMigratePreservesDeletion();
}

@Test
public void testIoTV2BatchRegionMigratePreservesDeletion() throws Exception {
startCluster(ConsensusFactory.IOT_CONSENSUS_V2, ConsensusFactory.IOT_CONSENSUS_V2_BATCH_MODE);
assertRegionMigratePreservesDeletion();
}

@Test
public void testIoTV2StreamRegionMigratePreservesDeletion() throws Exception {
startCluster(ConsensusFactory.IOT_CONSENSUS_V2, ConsensusFactory.IOT_CONSENSUS_V2_STREAM_MODE);
assertRegionMigratePreservesDeletion();
}

private void assertRegionMigratePreservesDeletion() throws Exception {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.db");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
import org.apache.iotdb.itbase.env.BaseEnv;
import org.apache.iotdb.itbase.env.CommonConfig;

import org.apache.tsfile.utils.Pair;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -61,13 +61,12 @@
@Category({TableClusterIT.class})
public class IoTDBRegionMigrateWithDeletionMultiDataDirTableIT {

@Before
public void setUp() throws Exception {
EnvFactory.getEnv()
.getConfig()
.getCommonConfig()
.setDataReplicationFactor(2)
.setDataRegionConsensusProtocolClass(ConsensusFactory.IOT_CONSENSUS);
private void startCluster(String protocol, String mode) throws Exception {
final CommonConfig config = EnvFactory.getEnv().getConfig().getCommonConfig();
config.setDataReplicationFactor(2).setDataRegionConsensusProtocolClass(protocol);
if (ConsensusFactory.IOT_CONSENSUS_V2.equals(protocol)) {
config.setIoTConsensusV2Mode(mode);
}
EnvFactory.getEnv().getConfig().getDataNodeConfig().setDnDataDirs(MULTI_DATA_DIRS);
EnvFactory.getEnv().initClusterEnvironment(1, 3);
}
Expand All @@ -79,6 +78,23 @@ public void tearDown() throws Exception {

@Test
public void testRegionMigratePreservesDeletionWithMultiDataDirs() throws Exception {
startCluster(ConsensusFactory.IOT_CONSENSUS, null);
assertRegionMigratePreservesDeletion();
}

@Test
public void testIoTV2BatchRegionMigratePreservesDeletion() throws Exception {
startCluster(ConsensusFactory.IOT_CONSENSUS_V2, ConsensusFactory.IOT_CONSENSUS_V2_BATCH_MODE);
assertRegionMigratePreservesDeletion();
}

@Test
public void testIoTV2StreamRegionMigratePreservesDeletion() throws Exception {
startCluster(ConsensusFactory.IOT_CONSENSUS_V2, ConsensusFactory.IOT_CONSENSUS_V2_STREAM_MODE);
assertRegionMigratePreservesDeletion();
}

private void assertRegionMigratePreservesDeletion() throws Exception {
try (Connection connection = EnvFactory.getEnv().getTableConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionReq;
import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionTableResp;
import org.apache.iotdb.confignode.rpc.thrift.TTimeSlotList;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.node.ConfigNodeWrapper;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
Expand Down Expand Up @@ -315,8 +316,7 @@ public static TClusterParameters generateClusterParameters() {
clusterParameters.setClusterName("defaultCluster");
clusterParameters.setConfigNodeConsensusProtocolClass(
"org.apache.iotdb.consensus.simple.SimpleConsensus");
clusterParameters.setDataRegionConsensusProtocolClass(
"org.apache.iotdb.consensus.simple.SimpleConsensus");
clusterParameters.setDataRegionConsensusProtocolClass(ConsensusFactory.IOT_CONSENSUS_V2);
clusterParameters.setSchemaRegionConsensusProtocolClass(
"org.apache.iotdb.consensus.simple.SimpleConsensus");
clusterParameters.setSeriesPartitionSlotNum(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.iotdb.db.it;

import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
Expand Down Expand Up @@ -62,15 +61,14 @@
@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
public class GrafanaApiServiceIT {

private static int port = 18080;
private static String restUrl;

@BeforeClass
public static void setUp() throws Exception {
BaseEnv baseEnv = EnvFactory.getEnv();
baseEnv.getConfig().getDataNodeConfig().setEnableRestService(true);
baseEnv.initClusterEnvironment();
DataNodeWrapper portConflictDataNodeWrapper = EnvFactory.getEnv().getDataNodeWrapper(0);
port = portConflictDataNodeWrapper.getRestServicePort();
restUrl = baseEnv.getRestUrls().get(0);
}

@AfterClass
Expand Down Expand Up @@ -112,7 +110,7 @@ private HttpPost getHttpPost(String url) {
@Test
public void login() {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet("http://127.0.0.1:" + port + "/grafana/v1/login");
HttpGet httpGet = new HttpGet(restUrl + "/grafana/v1/login");
CloseableHttpResponse response = null;
try {
String authorization = getAuthorization("root", "root");
Expand Down Expand Up @@ -158,7 +156,7 @@ public void login() {
public void rightInsertTablet(CloseableHttpClient httpClient) {
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost("http://127.0.0.1:" + port + "/rest/v1/insertTablet");
HttpPost httpPost = getHttpPost(restUrl + "/rest/v1/insertTablet");
String json =
"{\"timestamps\":[1635232143960,1635232153960],\"measurements\":[\"s4\",\"s5\"],\"dataTypes\":[\"INT32\",\"INT32\"],\"values\":[[11,2],[15,13]],\"isAligned\":false,\"deviceId\":\"root.sg25\"}";
httpPost.setEntity(new StringEntity(json, Charset.defaultCharset()));
Expand Down Expand Up @@ -199,7 +197,7 @@ public void rightInsertTablet(CloseableHttpClient httpClient) {
public void expressionGroupByLevel(CloseableHttpClient httpClient) {
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost("http://127.0.0.1:" + port + "/grafana/v1/query/expression");
HttpPost httpPost = getHttpPost(restUrl + "/grafana/v1/query/expression");
String sql =
"{\"expression\":[\"count(s4)\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232143960,\"endTime\":1635232153960,\"control\":\"group by([1635232143960,1635232153960),1s),level=1\"}";
httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
Expand Down Expand Up @@ -233,7 +231,7 @@ public void expressionGroupByLevel(CloseableHttpClient httpClient) {
public void expression(CloseableHttpClient httpClient) {
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost("http://127.0.0.1:" + port + "/grafana/v1/query/expression");
HttpPost httpPost = getHttpPost(restUrl + "/grafana/v1/query/expression");
String sql =
"{\"expression\":[\"s4\",\"s5\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232133960,\"endTime\":1635232163960}";
httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
Expand Down Expand Up @@ -286,7 +284,7 @@ public void expression(CloseableHttpClient httpClient) {
public void expressionWithControl(CloseableHttpClient httpClient) {
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost("http://127.0.0.1:" + port + "/grafana/v1/query/expression");
HttpPost httpPost = getHttpPost(restUrl + "/grafana/v1/query/expression");
String sql =
"{\"expression\":[\"sum(s4)\",\"avg(s5)\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232133960,\"endTime\":1635232163960,\"control\":\"group by([1635232133960,1635232163960),20s)\"}";
httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
Expand Down Expand Up @@ -340,7 +338,7 @@ public void expressionWithControl(CloseableHttpClient httpClient) {
public void expressionWithConditionControl(CloseableHttpClient httpClient) {
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost("http://127.0.0.1:" + port + "/grafana/v1/query/expression");
HttpPost httpPost = getHttpPost(restUrl + "/grafana/v1/query/expression");
String sql =
"{\"expression\":[\"sum(s4)\",\"avg(s5)\"],\"prefixPath\":[\"root.sg25\"],\"condition\":\"timestamp=1635232143960\",\"startTime\":1635232133960,\"endTime\":1635232163960,\"control\":\"group by([1635232133960,1635232163960),20s)\"}";
httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
Expand Down Expand Up @@ -391,7 +389,7 @@ public void expressionWithConditionControl(CloseableHttpClient httpClient) {
public void variable(CloseableHttpClient httpClient) {
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost("http://127.0.0.1:" + port + "/grafana/v1/variable");
HttpPost httpPost = getHttpPost(restUrl + "/grafana/v1/variable");
String sql = "{\"sql\":\"show child paths root.sg25\"}";
httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
response = httpClient.execute(httpPost);
Expand Down
Loading
Loading