Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explorer] fix: remove database field in node status with non API roles #1195

Merged
merged 5 commits into from
Jan 13, 2025
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
31 changes: 31 additions & 0 deletions __tests__/infrastructure/NodeService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,37 @@ describe('Node Service', () => {
});
});

const runLightRestNodeTests = roles => {
it(`returns roles ${roles} node status and light rest status`, async () => {
// Arrange:
const lightNodeResponse = {
roles,
peerStatus: generateNodePeerStatus(true),
apiStatus: {
...generateNodeApiStatus(true),
nodeStatus: undefined
},
...nodeCommonField
};

const expectedLightAPIStatus = {
...expectedAPIStatus,
lightNodeStatus: true,
connectionStatus: true
};
delete expectedLightAPIStatus.databaseStatus;
delete expectedLightAPIStatus.apiNodeStatus;

await assertNodeStatus(lightNodeResponse, {
peerStatus: expectedPeerStatus,
apiStatus: expectedLightAPIStatus,
chainInfo: expectedChainInfoStatus
});
});
};

[1, 4, 5].forEach(roles => runLightRestNodeTests(roles));

runStatisticServiceFailResponseTests('getNode', 'getNodeInfo');
});
});
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/components/tables/TableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ export default {
'apiNodeStatus' === key ||
'databaseStatus' === key ||
'isHttpsEnabled' === key ||
'isAvailable' === key
'isAvailable' === key ||
'lightNodeStatus' === key
);
},

Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"connectionStatus": "Connection",
"databaseStatus": "Data Base",
"apiNodeStatus": "API Node",
"lightNodeStatus": "Light Node",
"isAvailable": "Available",
"lastStatusCheck": "Last Status Check",
"nodeChainInfoTitle": "Node Chain Info",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
"connectionStatus": "Connection",
"databaseStatus": "Data Base",
"apiNodeStatus": "API Node",
"lightNodeStatus": "Light Node",
"isAvailable": "Available",
"lastStatusCheck": "Last Status Check",
"nodeChainInfoTitle": "Node Chain Info",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"connectionStatus": "接続",
"databaseStatus": "データベース",
"apiNodeStatus": "API ノード",
"lightNodeStatus": "Light ノード",
"isAvailable": "有効",
"lastStatusCheck": "最終チェック",
"nodeChainInfoTitle": "ノードチェーン情報",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"connectionStatus": "연결",
"databaseStatus": "데이터베이스",
"apiNodeStatus": "API 노드",
"lightNodeStatus": "Light 노드",
"isAvailable": "활성",
"lastStatusCheck": "마지막 상태 확인",
"nodeChainInfoTitle": "노드 체인 정보",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
"connectionStatus": "Connection",
"databaseStatus": "Data Base",
"apiNodeStatus": "API Node",
"lightNodeStatus": "Light Node",
"isAvailable": "Available",
"lastStatusCheck": "Last Status Check",
"nodeChainInfoTitle": "Node Chain Info",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"connectionStatus": "Соединение",
"databaseStatus": "База данных",
"apiNodeStatus": "API Ноды",
"lightNodeStatus": "Light Ноды",
"isAvailable": "Доступные",
"lastStatusCheck": "Последняя проверка статуса",
"nodeChainInfoTitle": "Информация о цепочке нод",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
"connectionStatus": "Connection",
"databaseStatus": "Data Base",
"apiNodeStatus": "API Node",
"lightNodeStatus": "Light Node",
"isAvailable": "Available",
"lastStatusCheck": "Last Status Check",
"nodeChainInfoTitle": "Node Chain Info",
Expand Down
1 change: 1 addition & 0 deletions src/config/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
"connectionStatus": "Connection",
"databaseStatus": "Data Base",
"apiNodeStatus": "API Node",
"lightNodeStatus": "Light Node",
"isAvailable": "Available",
"lastStatusCheck": "Last Status Check",
"nodeChainInfoTitle": "Node Chain Info",
Expand Down
1 change: 1 addition & 0 deletions src/config/pages/node-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"connectionStatus",
"databaseStatus",
"apiNodeStatus",
"lightNodeStatus",
"isHttpsEnabled",
"restVersion",
"lastStatusCheck"
Expand Down
19 changes: 15 additions & 4 deletions src/infrastructure/NodeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,28 @@ class NodeService {
// Api status
formattedNode.apiStatus = {
connectionStatus: isAvailable,
databaseStatus:
'up' === nodeStatus?.db || Constants.Message.UNAVAILABLE,
apiNodeStatus:
'up' === nodeStatus?.apiNode || Constants.Message.UNAVAILABLE,
isHttpsEnabled,
restVersion,
lastStatusCheck: moment
.utc(lastStatusCheck)
.format('YYYY-MM-DD HH:mm:ss')
};

// Only API nodes have database status
if ([2, 3, 6, 7].includes(node.roles)) {
Wayonb marked this conversation as resolved.
Show resolved Hide resolved
formattedNode.apiStatus = {
...formattedNode.apiStatus,
apiNodeStatus:
'up' === nodeStatus?.apiNode || Constants.Message.UNAVAILABLE,
databaseStatus: 'up' === nodeStatus?.db || Constants.Message.UNAVAILABLE
};
} else {
formattedNode.apiStatus = {
...formattedNode.apiStatus,
lightNodeStatus: isAvailable || Constants.Message.UNAVAILABLE
};
};

// Chain info
formattedNode.chainInfo = {
height: chainHeight,
Expand Down