Skip to content

Commit

Permalink
AINode: Introduce IT framework (#13387)
Browse files Browse the repository at this point in the history
  • Loading branch information
ycycse authored Sep 4, 2024
1 parent 0f6e0d6 commit 51ee13b
Show file tree
Hide file tree
Showing 15 changed files with 486 additions and 18 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/cluster-it-1c1d1a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Cluster IT - 1C1D1A

on:
push:
branches:
- master
- 'rel/1.*'
- 'rc/1.*'
paths-ignore:
- 'docs/**'
- 'site/**'
pull_request:
branches:
- master
- 'rel/1.*'
- 'rc/1.*'
paths-ignore:
- 'docs/**'
- 'site/**'
# allow manually run the action:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
MAVEN_ARGS: --batch-mode --no-transfer-progress
DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }}

jobs:
AINode:
strategy:
fail-fast: false
max-parallel: 15
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Build AINode
shell: bash
run: mvn clean package -DskipTests -P with-ainode
- name: IT Test
shell: bash
run: |
mvn clean verify \
-P with-integration-tests \
-DskipUTs \
-DintegrationTest.forkCount=2 \
-pl integration-test \
-am \
-PAIClusterIT
- name: Upload Artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: cluster-log-ainode-${{ matrix.os }}
path: integration-test/target/ainode-logs
retention-days: 30
14 changes: 14 additions & 0 deletions integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,20 @@
<integrationTest.testEnv>Cluster1</integrationTest.testEnv>
</properties>
</profile>
<profile>
<id>AIClusterIT</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<integrationTest.excludedGroups/>
<integrationTest.includedGroups>org.apache.iotdb.itbase.category.AIClusterIT</integrationTest.includedGroups>
<integrationTest.launchNodeInSameJVM>false</integrationTest.launchNodeInSameJVM>
<integrationTest.randomSelectWriteNode>false</integrationTest.randomSelectWriteNode>
<integrationTest.readAndVerifyWithMultiNode>false</integrationTest.readAndVerifyWithMultiNode>
<integrationTest.testEnv>AI</integrationTest.testEnv>
</properties>
</profile>
<profile>
<id>DailyIT</id>
<activation>
Expand Down
19 changes: 19 additions & 0 deletions integration-test/src/assembly/mpp-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<outputDirectory>conf</outputDirectory>
<directory>${project.basedir}/../iotdb-core/metrics/interface/src/main/assembly/resources/conf</directory>
</fileSet>
<fileSet>
<outputDirectory>conf</outputDirectory>
<directory>${project.basedir}/../iotdb-core/ainode/resources/conf</directory>
</fileSet>
<fileSet>
<outputDirectory>sbin</outputDirectory>
<directory>${project.basedir}/../iotdb-core/datanode/src/assembly/resources/sbin</directory>
Expand All @@ -52,6 +56,16 @@
<directory>${project.basedir}/../iotdb-core/confignode/src/assembly/resources/sbin</directory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<outputDirectory>sbin</outputDirectory>
<directory>${project.basedir}/../iotdb-core/ainode/resources/sbin</directory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<outputDirectory>venv</outputDirectory>
<directory>${project.basedir}/../iotdb-core/ainode/venv</directory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<outputDirectory>tools</outputDirectory>
<directory>${project.basedir}/../iotdb-core/datanode/src/assembly/resources/tools</directory>
Expand All @@ -67,6 +81,11 @@
<directory>${project.basedir}/../iotdb-client/cli/src/assembly/resources/tools</directory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<outputDirectory>lib</outputDirectory>
<directory>${project.basedir}/../iotdb-core/ainode/dist/</directory>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
<files>
<file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.iotdb.it.env;

import org.apache.iotdb.it.env.cluster.env.AIEnv;
import org.apache.iotdb.it.env.cluster.env.Cluster1Env;
import org.apache.iotdb.it.env.cluster.env.SimpleEnv;
import org.apache.iotdb.it.env.remote.env.RemoteServerEnv;
Expand Down Expand Up @@ -54,6 +55,9 @@ public static BaseEnv getEnv() {
case Remote:
env = new RemoteServerEnv();
break;
case AI:
env = new AIEnv();
break;
case MultiCluster:
logger.warn(
"EnvFactory only supports EnvType Simple, Cluster1 and Remote, please use MultiEnvFactory instead.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum EnvType {
Simple,
Cluster1,
MultiCluster,
AI,
TABLE_SIMPLE,
TABLE_CLUSTER1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,12 @@ public class ClusterConstant {
// Paths
public static final String USER_DIR = "user.dir";
public static final String TARGET = "target";
public static final String PYTHON_PATH = "venv/bin/python3";

public static final String DATA_NODE_NAME = "DataNode";

public static final String AI_NODE_NAME = "AINode";

public static final String LOCK_FILE_PATH =
System.getProperty(USER_DIR) + File.separator + TARGET + File.separator + "lock-";
public static final String TEMPLATE_NODE_PATH =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.it.env.cluster.env;

public class AIEnv extends AbstractEnv {
@Override
public void initClusterEnvironment() {
initClusterEnvironment(1, 1);
}

@Override
public void initClusterEnvironment(int configNodesNum, int dataNodesNum) {
super.initEnvironment(configNodesNum, dataNodesNum, 10000, true);
}

@Override
public void initClusterEnvironment(
int configNodesNum, int dataNodesNum, int testWorkingRetryCount) {
super.initEnvironment(configNodesNum, dataNodesNum, testWorkingRetryCount, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.EnvUtils;
import org.apache.iotdb.it.env.cluster.config.*;
import org.apache.iotdb.it.env.cluster.node.AINodeWrapper;
import org.apache.iotdb.it.env.cluster.node.AbstractNodeWrapper;
import org.apache.iotdb.it.env.cluster.node.ConfigNodeWrapper;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
Expand Down Expand Up @@ -81,6 +82,7 @@ public abstract class AbstractEnv implements BaseEnv {
private final Random rand = new Random();
protected List<ConfigNodeWrapper> configNodeWrapperList = Collections.emptyList();
protected List<DataNodeWrapper> dataNodeWrapperList = Collections.emptyList();
protected List<AINodeWrapper> aiNodeWrapperList = Collections.emptyList();
protected String testMethodName = null;
protected int index = 0;
protected long startTime;
Expand Down Expand Up @@ -144,7 +146,12 @@ protected void initEnvironment(int configNodesNum, int dataNodesNum) {
initEnvironment(configNodesNum, dataNodesNum, retryCount);
}

protected void initEnvironment(int configNodesNum, int dataNodesNum, int retryCount) {
protected void initEnvironment(int configNodesNum, int dataNodesNum, int testWorkingRetryCount) {
initEnvironment(configNodesNum, dataNodesNum, testWorkingRetryCount, false);
}

protected void initEnvironment(
int configNodesNum, int dataNodesNum, int retryCount, boolean addAINode) {
this.retryCount = retryCount;
this.configNodeWrapperList = new ArrayList<>();
this.dataNodeWrapperList = new ArrayList<>();
Expand Down Expand Up @@ -256,9 +263,45 @@ protected void initEnvironment(int configNodesNum, int dataNodesNum, int retryCo
throw new AssertionError();
}

if (addAINode) {
this.aiNodeWrapperList = new ArrayList<>();
startAINode(seedConfigNode, testClassName);
}

checkClusterStatusWithoutUnknown();
}

private void startAINode(String seedConfigNode, String testClassName) {
String aiNodeEndPoint;
AINodeWrapper aiNodeWrapper =
new AINodeWrapper(
seedConfigNode,
testClassName,
testMethodName,
index,
EnvUtils.searchAvailablePorts(),
startTime);
aiNodeWrapperList.add(aiNodeWrapper);
aiNodeEndPoint = aiNodeWrapper.getIpAndPortString();
aiNodeWrapper.createNodeDir();
aiNodeWrapper.createLogDir();
RequestDelegate<Void> AINodesDelegate =
new ParallelRequestDelegate<>(
Collections.singletonList(aiNodeEndPoint), NODE_START_TIMEOUT);

AINodesDelegate.addRequest(
() -> {
aiNodeWrapper.start();
return null;
});

try {
AINodesDelegate.requestAll();
} catch (SQLException e) {
logger.error("Start aiNodes failed", e);
}
}

public String getTestClassName() {
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
for (StackTraceElement stackTraceElement : stack) {
Expand Down Expand Up @@ -319,7 +362,9 @@ public void checkClusterStatus(Predicate<Map<Integer, String>> statusCheck) {

// Check the number of nodes
if (showClusterResp.getNodeStatus().size()
!= configNodeWrapperList.size() + dataNodeWrapperList.size()) {
!= configNodeWrapperList.size()
+ dataNodeWrapperList.size()
+ aiNodeWrapperList.size()) {
flag = false;
}

Expand Down Expand Up @@ -356,7 +401,9 @@ public void checkClusterStatus(Predicate<Map<Integer, String>> statusCheck) {
@Override
public void cleanClusterEnvironment() {
List<AbstractNodeWrapper> allNodeWrappers =
Stream.concat(this.dataNodeWrapperList.stream(), this.configNodeWrapperList.stream())
Stream.concat(
dataNodeWrapperList.stream(),
Stream.concat(configNodeWrapperList.stream(), aiNodeWrapperList.stream()))
.collect(Collectors.toList());
allNodeWrappers.stream()
.findAny()
Expand Down
Loading

0 comments on commit 51ee13b

Please sign in to comment.