Skip to content

Commit 43af15b

Browse files
Vivek/poll testnet status ci fix (#743)
* ansible: codify dashmon status monitoring access * feat: poll testnet status and open infra recovery issues * fix: shorten dashmon authorized key ansible line * fix: use tracked testnet node list in poller --------- Co-authored-by: dashinfraclaw <dashinfraclaw@users.noreply.github.com>
1 parent a3e7d8e commit 43af15b

3 files changed

Lines changed: 134 additions & 3 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
[
2+
"masternode-1",
3+
"masternode-2",
4+
"masternode-3",
5+
"masternode-4",
6+
"masternode-5",
7+
"masternode-6",
8+
"masternode-7",
9+
"masternode-8",
10+
"masternode-9",
11+
"masternode-10",
12+
"masternode-11",
13+
"masternode-12",
14+
"masternode-13",
15+
"masternode-14",
16+
"masternode-15",
17+
"masternode-16",
18+
"masternode-17",
19+
"masternode-18",
20+
"masternode-19",
21+
"masternode-20",
22+
"masternode-21",
23+
"masternode-22",
24+
"masternode-23",
25+
"masternode-24",
26+
"masternode-25",
27+
"masternode-26",
28+
"masternode-27",
29+
"masternode-28",
30+
"masternode-29",
31+
"masternode-30",
32+
"masternode-31",
33+
"masternode-32",
34+
"masternode-33",
35+
"masternode-34",
36+
"masternode-35",
37+
"masternode-36",
38+
"masternode-37",
39+
"masternode-38",
40+
"masternode-39",
41+
"masternode-40",
42+
"masternode-41",
43+
"masternode-42",
44+
"masternode-43",
45+
"masternode-44",
46+
"masternode-45",
47+
"masternode-46",
48+
"masternode-47",
49+
"masternode-48",
50+
"masternode-49",
51+
"masternode-50",
52+
"masternode-51",
53+
"masternode-52",
54+
"masternode-53",
55+
"hp-masternode-1",
56+
"hp-masternode-2",
57+
"hp-masternode-3",
58+
"hp-masternode-4",
59+
"hp-masternode-5",
60+
"hp-masternode-6",
61+
"hp-masternode-7",
62+
"hp-masternode-8",
63+
"hp-masternode-9",
64+
"hp-masternode-10",
65+
"hp-masternode-11",
66+
"hp-masternode-12",
67+
"hp-masternode-13",
68+
"hp-masternode-14",
69+
"hp-masternode-15",
70+
"hp-masternode-16",
71+
"hp-masternode-17",
72+
"hp-masternode-18",
73+
"hp-masternode-19",
74+
"hp-masternode-20",
75+
"hp-masternode-21",
76+
"hp-masternode-22",
77+
"hp-masternode-23",
78+
"hp-masternode-24",
79+
"hp-masternode-25",
80+
"hp-masternode-26",
81+
"hp-masternode-27",
82+
"hp-masternode-28",
83+
"hp-masternode-29"
84+
]

lib/testnetStatus/pollTestnetStatus.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const { promisify } = require('util');
55

66
const DEFAULT_STATUS_API_URL = 'https://status.testnet.networks.dash.org/api/nodes';
77
const DEFAULT_INVENTORY_PATH = path.resolve(process.cwd(), 'networks/testnet.inventory');
8+
const DEFAULT_EXPECTED_NODE_NAMES_PATH = path.resolve(
9+
__dirname,
10+
'expectedTestnetNodes.json',
11+
);
812
const DEFAULT_REPOSITORY = 'dashpay/infra';
913
const DEFAULT_ASSIGNEE = 'dashinfraclaw';
1014
const ISSUE_TITLE_PREFIX = '[Testnet Recovery]';
@@ -104,9 +108,27 @@ function filterIncidentsWithoutOpenIssues(incidents, openIssues) {
104108
return incidents.filter((incident) => !openIssueTitles.has(buildIssueTitle(incident.nodeName)));
105109
}
106110

107-
async function readExpectedNodeNames(inventoryPath = DEFAULT_INVENTORY_PATH) {
108-
const inventoryContents = await fs.readFile(inventoryPath, 'utf8');
109-
return parseExpectedNodeNames(inventoryContents);
111+
async function readExpectedNodeNames(
112+
inventoryPath = DEFAULT_INVENTORY_PATH,
113+
expectedNodeNamesPath = DEFAULT_EXPECTED_NODE_NAMES_PATH,
114+
) {
115+
try {
116+
const inventoryContents = await fs.readFile(inventoryPath, 'utf8');
117+
return parseExpectedNodeNames(inventoryContents);
118+
} catch (error) {
119+
if (error.code !== 'ENOENT') {
120+
throw error;
121+
}
122+
123+
const expectedNodeNamesContents = await fs.readFile(expectedNodeNamesPath, 'utf8');
124+
const expectedNodeNames = JSON.parse(expectedNodeNamesContents);
125+
126+
if (!Array.isArray(expectedNodeNames)) {
127+
throw new Error('Expected node names fallback must be a JSON array');
128+
}
129+
130+
return expectedNodeNames;
131+
}
110132
}
111133

112134
async function fetchStatusNodes(statusApiUrl = DEFAULT_STATUS_API_URL, fetchImpl = fetch) {
@@ -245,6 +267,7 @@ module.exports = {
245267
createRecoveryIssue,
246268
DEFAULT_ASSIGNEE,
247269
DEFAULT_INVENTORY_PATH,
270+
DEFAULT_EXPECTED_NODE_NAMES_PATH,
248271
DEFAULT_REPOSITORY,
249272
DEFAULT_STATUS_API_URL,
250273
fetchStatusNodes,

test/pollTestnetStatus.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const fs = require('fs').promises;
2+
const os = require('os');
3+
const path = require('path');
14
const { expect } = require('chai');
25

36
const {
@@ -7,6 +10,7 @@ const {
710
filterIncidentsWithoutOpenIssues,
811
findRecoveryIncidents,
912
parseExpectedNodeNames,
13+
readExpectedNodeNames,
1014
} = require('../lib/testnetStatus/pollTestnetStatus');
1115

1216
describe('pollTestnetStatus', () => {
@@ -121,6 +125,26 @@ seed-1
121125
});
122126
});
123127

128+
describe('readExpectedNodeNames', () => {
129+
it('should fall back to the tracked expected-node list when inventory is missing', async () => {
130+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'poll-testnet-status-'));
131+
const fallbackPath = path.join(tempDir, 'expectedTestnetNodes.json');
132+
133+
await fs.writeFile(
134+
fallbackPath,
135+
JSON.stringify(['masternode-1', 'hp-masternode-1']),
136+
);
137+
138+
const expectedNodeNames = await readExpectedNodeNames(
139+
path.join(tempDir, 'missing.inventory'),
140+
fallbackPath,
141+
);
142+
143+
expect(expectedNodeNames).to.deep.equal(['masternode-1', 'hp-masternode-1']);
144+
145+
await fs.rm(tempDir, { recursive: true, force: true });
146+
});
147+
});
124148
describe('issue helpers', () => {
125149
it('should use a deterministic issue title and public body', () => {
126150
expect(buildIssueTitle('hp-masternode-7')).to.equal('[Testnet Recovery] hp-masternode-7');

0 commit comments

Comments
 (0)