|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.iotdb.ainode.it; |
| 21 | + |
| 22 | +import org.apache.iotdb.it.env.EnvFactory; |
| 23 | +import org.apache.iotdb.it.framework.IoTDBTestRunner; |
| 24 | +import org.apache.iotdb.itbase.category.AIClusterIT; |
| 25 | + |
| 26 | +import org.junit.AfterClass; |
| 27 | +import org.junit.BeforeClass; |
| 28 | +import org.junit.Test; |
| 29 | +import org.junit.experimental.categories.Category; |
| 30 | +import org.junit.runner.RunWith; |
| 31 | + |
| 32 | +import java.sql.Connection; |
| 33 | +import java.sql.ResultSet; |
| 34 | +import java.sql.ResultSetMetaData; |
| 35 | +import java.sql.SQLException; |
| 36 | +import java.sql.Statement; |
| 37 | + |
| 38 | +import static org.apache.iotdb.ainode.utils.AINodeTestUtils.checkHeader; |
| 39 | +import static org.junit.Assert.assertEquals; |
| 40 | + |
| 41 | +@RunWith(IoTDBTestRunner.class) |
| 42 | +@Category({AIClusterIT.class}) |
| 43 | +public class AINodeClusterConfigIT { |
| 44 | + |
| 45 | + @BeforeClass |
| 46 | + public static void setUp() throws Exception { |
| 47 | + // Init 1C1D1A cluster environment |
| 48 | + EnvFactory.getEnv().initClusterEnvironment(1, 1); |
| 49 | + } |
| 50 | + |
| 51 | + @AfterClass |
| 52 | + public static void tearDown() throws Exception { |
| 53 | + EnvFactory.getEnv().cleanClusterEnvironment(); |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + public void aiNodeRegisterTest() throws SQLException { |
| 58 | + String sql = "SHOW AINODES"; |
| 59 | + String title = "NodeID,Status,InternalAddress,InternalPort"; |
| 60 | + try (Connection connection = EnvFactory.getEnv().getConnection(); |
| 61 | + Statement statement = connection.createStatement()) { |
| 62 | + |
| 63 | + try (ResultSet resultSet = statement.executeQuery(sql)) { |
| 64 | + ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); |
| 65 | + checkHeader(resultSetMetaData, title); |
| 66 | + int count = 0; |
| 67 | + while (resultSet.next()) { |
| 68 | + assertEquals("2", resultSet.getString(1)); |
| 69 | + assertEquals("Running", resultSet.getString(2)); |
| 70 | + count++; |
| 71 | + } |
| 72 | + assertEquals(1, count); |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments