Skip to content
Merged
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 @@ -152,9 +152,6 @@ public static List<List<String>> getBackendInfos() {
// heartbeat failure counter
backendInfo.add(backend.getHeartbeatFailureCounter());

// node role, show the value only when backend is alive.
backendInfo.add(backend.isAlive() ? backend.getNodeRoleTag().value : "");

// cpu cores
backendInfo.add(String.valueOf(backend.getCputCores()));

Expand All @@ -167,6 +164,9 @@ public static List<List<String>> getBackendInfos() {
// runningFragments
backendInfo.add(String.valueOf(backend.getRunningTasks()));

// node role, show the value only when backend is alive.
backendInfo.add(backend.isAlive() ? backend.getNodeRoleTag().value : "");

comparableBackendInfos.add(backendInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
import org.apache.doris.system.Backend;
import org.apache.doris.system.SystemInfoService;

import com.google.common.collect.Lists;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class BackendsProcDirTest {
private Backend b1;
private Backend b2;
Expand Down Expand Up @@ -183,4 +186,39 @@ public void testFetchResultNormal() throws AnalysisException {
Assert.assertNotNull(result);
Assert.assertTrue(result instanceof BaseProcResult);
}

@Test
public void testBackendInfoFieldOrder() throws AnalysisException {
b1.setCpuCores(192);
b1.setLastUpdateMs(System.currentTimeMillis());
b1.setRunningTasks(10L);

new Expectations() {
{
systemInfoService.getAllBackendIds(false);
minTimes = 0;
result = Lists.newArrayList(1000L);

systemInfoService.getTabletNumByBackendId(1000L);
minTimes = 0;
result = 10;
}
};

BackendsProcDir dir = new BackendsProcDir(systemInfoService);
ProcResult result = dir.fetchResult();

List<String> columnNames = result.getColumnNames();

int cpuCoresIdx = columnNames.indexOf("CpuCores");
int memoryIdx = columnNames.indexOf("Memory");
int liveSinceIdx = columnNames.indexOf("LiveSince");
int runningTasksIdx = columnNames.indexOf("RunningTasks");
int nodeRoleIdx = columnNames.indexOf("NodeRole");

Assert.assertTrue("CpuCores should be before Memory", cpuCoresIdx < memoryIdx);
Assert.assertTrue("Memory should be before LiveSince", memoryIdx < liveSinceIdx);
Assert.assertTrue("LiveSince should be before RunningTasks", liveSinceIdx < runningTasksIdx);
Assert.assertTrue("RunningTasks should be before NodeRole", runningTasksIdx < nodeRoleIdx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,41 @@ public void testNormal() throws Exception {
List<Column> columnList = showResultSet.getMetaData().getColumns();
ImmutableList<String> backendsTitleNames = BackendsTableValuedFunction.getBackendsTitleNames();
Assertions.assertTrue(!columnList.isEmpty() && columnList.size() == backendsTitleNames.size());

for (int i = 0; i < backendsTitleNames.size(); i++) {
Assertions.assertTrue(columnList.get(i).getName().equalsIgnoreCase(backendsTitleNames.get(i)));
Assertions.assertEquals(backendsTitleNames.get(i), columnList.get(i).getName(),
"Column at index " + i + " should be " + backendsTitleNames.get(i));
}

Assertions.assertEquals("BackendId", columnList.get(0).getName());
Assertions.assertEquals("Host", columnList.get(1).getName());
Assertions.assertEquals("HeartbeatPort", columnList.get(2).getName());
Assertions.assertEquals("BePort", columnList.get(3).getName());
Assertions.assertEquals("HttpPort", columnList.get(4).getName());
Assertions.assertEquals("BrpcPort", columnList.get(5).getName());
Assertions.assertEquals("ArrowFlightSqlPort", columnList.get(6).getName());
Assertions.assertEquals("LastStartTime", columnList.get(7).getName());
Assertions.assertEquals("LastHeartbeat", columnList.get(8).getName());
Assertions.assertEquals("Alive", columnList.get(9).getName());
Assertions.assertEquals("SystemDecommissioned", columnList.get(10).getName());
Assertions.assertEquals("TabletNum", columnList.get(11).getName());
Assertions.assertEquals("DataUsedCapacity", columnList.get(12).getName());
Assertions.assertEquals("TrashUsedCapacity", columnList.get(13).getName());
Assertions.assertEquals("AvailCapacity", columnList.get(14).getName());
Assertions.assertEquals("TotalCapacity", columnList.get(15).getName());
Assertions.assertEquals("UsedPct", columnList.get(16).getName());
Assertions.assertEquals("MaxDiskUsedPct", columnList.get(17).getName());
Assertions.assertEquals("RemoteUsedCapacity", columnList.get(18).getName());
Assertions.assertEquals("Tag", columnList.get(19).getName());
Assertions.assertEquals("ErrMsg", columnList.get(20).getName());
Assertions.assertEquals("Version", columnList.get(21).getName());
Assertions.assertEquals("Status", columnList.get(22).getName());
Assertions.assertEquals("HeartbeatFailureCounter", columnList.get(23).getName());
Assertions.assertEquals("CpuCores", columnList.get(24).getName());
Assertions.assertEquals("Memory", columnList.get(25).getName());
Assertions.assertEquals("LiveSince", columnList.get(26).getName());
Assertions.assertEquals("RunningTasks", columnList.get(27).getName());
Assertions.assertEquals("NodeRole", columnList.get(28).getName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void testCreateDbAndTable() throws Exception {
+ "\"lastFragmentUpdateTime\":0}",
result.getRows().get(0).get(backendsTitleNames.size() - 7));
Assert.assertEquals("0", result.getRows().get(0).get(backendsTitleNames.size() - 6));
Assert.assertEquals(Tag.VALUE_MIX, result.getRows().get(0).get(backendsTitleNames.size() - 5));
Assert.assertEquals(Tag.VALUE_MIX, result.getRows().get(0).get(backendsTitleNames.size() - 1));
}

protected void alterTable(String sql, ConnectContext connectContext) throws Exception {
Expand Down
Loading