postgresai 0.14.0-dev.85 → 0.14.0-dev.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/postgres-ai.ts +171 -12
- package/dist/bin/postgres-ai.js +386 -23
- package/dist/sql/03.permissions.sql +41 -2
- package/dist/sql/sql/03.permissions.sql +41 -2
- package/lib/checkup-api.ts +47 -1
- package/lib/checkup-summary.ts +283 -0
- package/lib/init.ts +31 -10
- package/package.json +1 -1
- package/sql/03.permissions.sql +41 -2
- package/test/checkup.integration.test.ts +27 -0
- package/test/checkup.test.ts +580 -1
- package/test/init.test.ts +338 -1
package/test/checkup.test.ts
CHANGED
|
@@ -1009,6 +1009,55 @@ describe("CLI tests", () => {
|
|
|
1009
1009
|
expect(r.stderr).not.toMatch(/API key is required/i);
|
|
1010
1010
|
});
|
|
1011
1011
|
|
|
1012
|
+
test("checkup --help shows --markdown option", () => {
|
|
1013
|
+
const r = runCli(["checkup", "--help"]);
|
|
1014
|
+
expect(r.status).toBe(0);
|
|
1015
|
+
expect(r.stdout).toMatch(/--markdown/);
|
|
1016
|
+
expect(r.stdout).toMatch(/output markdown to stdout/i);
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
test("checkup --markdown is recognized as valid option", () => {
|
|
1020
|
+
// Should not produce "unknown option" error for --markdown
|
|
1021
|
+
const r = runCli(["checkup", "postgresql://test:test@localhost:5432/test", "--markdown", "--no-upload"]);
|
|
1022
|
+
// Connection will fail, but option parsing should succeed
|
|
1023
|
+
expect(r.stderr).not.toMatch(/unknown option/i);
|
|
1024
|
+
expect(r.stderr).not.toMatch(/did you mean/i);
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
test("checkup --markdown works without API key", () => {
|
|
1028
|
+
// Use empty config dir to ensure no API key is configured
|
|
1029
|
+
const env = { XDG_CONFIG_HOME: "/tmp/postgresai-test-empty-config" };
|
|
1030
|
+
// --markdown should work even without API key
|
|
1031
|
+
const r = runCli(["checkup", "postgresql://test:test@localhost:5432/test", "--markdown", "--no-upload"], env);
|
|
1032
|
+
// Connection will fail, but --markdown flag should be recognized
|
|
1033
|
+
expect(r.status).not.toBe(0);
|
|
1034
|
+
expect(r.stderr).not.toMatch(/unknown option/i);
|
|
1035
|
+
expect(r.stderr).not.toMatch(/API key is required/i);
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
test("checkup with --no-upload and no output flags shows summary", () => {
|
|
1039
|
+
// This test verifies that when running with --no-upload and no output flags,
|
|
1040
|
+
// the user gets a summary of checks.
|
|
1041
|
+
// Note: This will fail to connect, but we can still verify behavior.
|
|
1042
|
+
const env = { XDG_CONFIG_HOME: "/tmp/postgresai-test-empty-config" };
|
|
1043
|
+
const r = runCli(["checkup", "postgresql://test:test@localhost:5432/test", "--no-upload"], env);
|
|
1044
|
+
|
|
1045
|
+
// The command will fail due to connection error, but if it succeeded,
|
|
1046
|
+
// it should show the summary. We can't test the success case without a real DB,
|
|
1047
|
+
// but we verify the option parsing is correct (tested above in other tests).
|
|
1048
|
+
// The actual summary output is tested in integration tests.
|
|
1049
|
+
expect(r.status).not.toBe(0); // Will fail due to connection
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
test("checkup rejects --json and --markdown together", () => {
|
|
1053
|
+
const env = { XDG_CONFIG_HOME: "/tmp/postgresai-test-empty-config" };
|
|
1054
|
+
const r = runCli(["checkup", "postgresql://test:test@localhost:5432/test", "--json", "--markdown", "--no-upload"], env);
|
|
1055
|
+
|
|
1056
|
+
// Should fail with mutual exclusivity error
|
|
1057
|
+
expect(r.status).not.toBe(0);
|
|
1058
|
+
expect(r.stderr).toMatch(/mutually exclusive/i);
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1012
1061
|
// Argument parsing tests for check ID / connection string recognition
|
|
1013
1062
|
test("checkup with check ID but no connection shows specific error", () => {
|
|
1014
1063
|
const r = runCli(["checkup", "H002"]);
|
|
@@ -1111,7 +1160,7 @@ describe("checkup-api", () => {
|
|
|
1111
1160
|
return "ok";
|
|
1112
1161
|
},
|
|
1113
1162
|
{ maxAttempts: 3, initialDelayMs: 10 },
|
|
1114
|
-
(attempt,
|
|
1163
|
+
(attempt, _err, delayMs) => {
|
|
1115
1164
|
retryLogs.push(`attempt ${attempt}, delay ${delayMs}ms`);
|
|
1116
1165
|
}
|
|
1117
1166
|
);
|
|
@@ -1215,4 +1264,534 @@ describe("checkup-api", () => {
|
|
|
1215
1264
|
});
|
|
1216
1265
|
});
|
|
1217
1266
|
|
|
1267
|
+
// Tests for checkup-summary module
|
|
1268
|
+
describe("checkup-summary", () => {
|
|
1269
|
+
const summary = require("../lib/checkup-summary");
|
|
1270
|
+
|
|
1271
|
+
test("generateCheckSummary for H001 with no issues", () => {
|
|
1272
|
+
const report = {
|
|
1273
|
+
results: {
|
|
1274
|
+
"node1": {
|
|
1275
|
+
data: {
|
|
1276
|
+
"db1": {
|
|
1277
|
+
invalid_indexes: [],
|
|
1278
|
+
total_count: 0,
|
|
1279
|
+
total_size_bytes: 0,
|
|
1280
|
+
total_size_pretty: "0 bytes",
|
|
1281
|
+
database_size_bytes: 1000000,
|
|
1282
|
+
database_size_pretty: "1 MB"
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
const result = summary.generateCheckSummary("H001", report);
|
|
1289
|
+
expect(result.status).toBe("ok");
|
|
1290
|
+
expect(result.message).toMatch(/no invalid/i);
|
|
1291
|
+
});
|
|
1292
|
+
|
|
1293
|
+
test("generateCheckSummary for H001 with invalid indexes", () => {
|
|
1294
|
+
const report = {
|
|
1295
|
+
results: {
|
|
1296
|
+
"node1": {
|
|
1297
|
+
data: {
|
|
1298
|
+
"db1": {
|
|
1299
|
+
invalid_indexes: [{}, {}, {}],
|
|
1300
|
+
total_count: 3,
|
|
1301
|
+
total_size_bytes: 1024 * 1024 * 245,
|
|
1302
|
+
total_size_pretty: "245 MiB",
|
|
1303
|
+
database_size_bytes: 1000000000,
|
|
1304
|
+
database_size_pretty: "1 GB"
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
const result = summary.generateCheckSummary("H001", report);
|
|
1311
|
+
expect(result.status).toBe("warning");
|
|
1312
|
+
expect(result.message).toMatch(/3 invalid indexes/i);
|
|
1313
|
+
expect(result.message).toMatch(/245 MiB/i);
|
|
1314
|
+
});
|
|
1315
|
+
|
|
1316
|
+
test("generateCheckSummary for H002 with no issues", () => {
|
|
1317
|
+
const report = {
|
|
1318
|
+
results: {
|
|
1319
|
+
"node1": {
|
|
1320
|
+
data: {
|
|
1321
|
+
"db1": {
|
|
1322
|
+
unused_indexes: [],
|
|
1323
|
+
total_count: 0,
|
|
1324
|
+
total_size_bytes: 0,
|
|
1325
|
+
total_size_pretty: "0 bytes",
|
|
1326
|
+
database_size_bytes: 1000000,
|
|
1327
|
+
database_size_pretty: "1 MB",
|
|
1328
|
+
stats_reset: {}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
const result = summary.generateCheckSummary("H002", report);
|
|
1335
|
+
expect(result.status).toBe("ok");
|
|
1336
|
+
expect(result.message).toMatch(/all indexes utilized/i);
|
|
1337
|
+
});
|
|
1338
|
+
|
|
1339
|
+
test("generateCheckSummary for H002 with unused indexes", () => {
|
|
1340
|
+
const report = {
|
|
1341
|
+
results: {
|
|
1342
|
+
"node1": {
|
|
1343
|
+
data: {
|
|
1344
|
+
"db1": {
|
|
1345
|
+
unused_indexes: [{}, {}],
|
|
1346
|
+
total_count: 2,
|
|
1347
|
+
total_size_bytes: 1024 * 1024 * 150,
|
|
1348
|
+
total_size_pretty: "150 MiB",
|
|
1349
|
+
database_size_bytes: 1000000000,
|
|
1350
|
+
database_size_pretty: "1 GB",
|
|
1351
|
+
stats_reset: {}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
const result = summary.generateCheckSummary("H002", report);
|
|
1358
|
+
expect(result.status).toBe("warning");
|
|
1359
|
+
expect(result.message).toMatch(/2 unused indexes/i);
|
|
1360
|
+
expect(result.message).toMatch(/150 MiB/i);
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
test("generateCheckSummary for H004 with redundant indexes", () => {
|
|
1364
|
+
const report = {
|
|
1365
|
+
results: {
|
|
1366
|
+
"node1": {
|
|
1367
|
+
data: {
|
|
1368
|
+
"db1": {
|
|
1369
|
+
redundant_indexes: [{}, {}, {}, {}],
|
|
1370
|
+
total_count: 4,
|
|
1371
|
+
total_size_bytes: 1024 * 1024 * 1024 * 1.2,
|
|
1372
|
+
total_size_pretty: "1.2 GiB",
|
|
1373
|
+
database_size_bytes: 10000000000,
|
|
1374
|
+
database_size_pretty: "10 GB"
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
const result = summary.generateCheckSummary("H004", report);
|
|
1381
|
+
expect(result.status).toBe("warning");
|
|
1382
|
+
expect(result.message).toMatch(/4 redundant indexes/i);
|
|
1383
|
+
expect(result.message).toMatch(/1\.2 GiB/i);
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
test("generateCheckSummary for A003 (settings)", () => {
|
|
1387
|
+
const report = {
|
|
1388
|
+
results: {
|
|
1389
|
+
"node1": {
|
|
1390
|
+
data: {
|
|
1391
|
+
"setting1": "value1",
|
|
1392
|
+
"setting2": "value2"
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
const result = summary.generateCheckSummary("A003", report);
|
|
1398
|
+
expect(result.status).toBe("info");
|
|
1399
|
+
expect(result.message).toBe("2 settings collected");
|
|
1400
|
+
});
|
|
1401
|
+
|
|
1402
|
+
test("generateCheckSummary for A002 with PostgreSQL 17", () => {
|
|
1403
|
+
const report = {
|
|
1404
|
+
results: {
|
|
1405
|
+
"node1": {
|
|
1406
|
+
data: {
|
|
1407
|
+
version: {
|
|
1408
|
+
version: "17.2",
|
|
1409
|
+
server_version_num: "170002",
|
|
1410
|
+
server_major_ver: "17",
|
|
1411
|
+
server_minor_ver: "2"
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
const result = summary.generateCheckSummary("A002", report);
|
|
1418
|
+
expect(result.status).toBe("ok");
|
|
1419
|
+
expect(result.message).toBe("PostgreSQL 17");
|
|
1420
|
+
});
|
|
1421
|
+
|
|
1422
|
+
test("generateCheckSummary for A002 with PostgreSQL 15", () => {
|
|
1423
|
+
const report = {
|
|
1424
|
+
results: {
|
|
1425
|
+
"node1": {
|
|
1426
|
+
data: {
|
|
1427
|
+
version: {
|
|
1428
|
+
version: "15.4",
|
|
1429
|
+
server_version_num: "150004",
|
|
1430
|
+
server_major_ver: "15",
|
|
1431
|
+
server_minor_ver: "4"
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
const result = summary.generateCheckSummary("A002", report);
|
|
1438
|
+
expect(result.status).toBe("info");
|
|
1439
|
+
expect(result.message).toBe("PostgreSQL 15");
|
|
1440
|
+
});
|
|
1441
|
+
|
|
1442
|
+
test("generateCheckSummary for A002 with old PostgreSQL 11", () => {
|
|
1443
|
+
const report = {
|
|
1444
|
+
results: {
|
|
1445
|
+
"node1": {
|
|
1446
|
+
data: {
|
|
1447
|
+
version: {
|
|
1448
|
+
version: "11.8",
|
|
1449
|
+
server_version_num: "110008",
|
|
1450
|
+
server_major_ver: "11",
|
|
1451
|
+
server_minor_ver: "8"
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
const result = summary.generateCheckSummary("A002", report);
|
|
1458
|
+
expect(result.status).toBe("warning");
|
|
1459
|
+
expect(result.message).toMatch(/PostgreSQL 11.*consider upgrading/i);
|
|
1460
|
+
});
|
|
1461
|
+
|
|
1462
|
+
test("generateCheckSummary for A013 with version", () => {
|
|
1463
|
+
const report = {
|
|
1464
|
+
results: {
|
|
1465
|
+
"node1": {
|
|
1466
|
+
data: {
|
|
1467
|
+
version: {
|
|
1468
|
+
version: "17.2",
|
|
1469
|
+
server_version_num: "170002",
|
|
1470
|
+
server_major_ver: "17",
|
|
1471
|
+
server_minor_ver: "2"
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
const result = summary.generateCheckSummary("A013", report);
|
|
1478
|
+
expect(result.status).toBe("info");
|
|
1479
|
+
expect(result.message).toBe("Version 17.2");
|
|
1480
|
+
});
|
|
1481
|
+
|
|
1482
|
+
test("generateCheckSummary handles empty results", () => {
|
|
1483
|
+
const report = { results: {} };
|
|
1484
|
+
const result = summary.generateCheckSummary("H001", report);
|
|
1485
|
+
expect(result.status).toBe("info");
|
|
1486
|
+
expect(result.message).toBe("No data");
|
|
1487
|
+
});
|
|
1488
|
+
|
|
1489
|
+
test("generateCheckSummary handles unknown check ID", () => {
|
|
1490
|
+
const report = {
|
|
1491
|
+
results: {
|
|
1492
|
+
"node1": { data: {} }
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
const result = summary.generateCheckSummary("UNKNOWN", report);
|
|
1496
|
+
expect(result.status).toBe("info");
|
|
1497
|
+
expect(result.message).toBe("Check completed");
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
test("generateCheckSummary for D001 (logging settings)", () => {
|
|
1501
|
+
const report = {
|
|
1502
|
+
results: {
|
|
1503
|
+
"node1": {
|
|
1504
|
+
data: {
|
|
1505
|
+
"log_destination": { value: "stderr" },
|
|
1506
|
+
"log_line_prefix": { value: "%m [%p] " }
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
const result = summary.generateCheckSummary("D001", report);
|
|
1512
|
+
expect(result.status).toBe("info");
|
|
1513
|
+
expect(result.message).toBe("2 logging settings collected");
|
|
1514
|
+
});
|
|
1515
|
+
|
|
1516
|
+
test("generateCheckSummary for D004 (pg_stat_statements)", () => {
|
|
1517
|
+
const report = {
|
|
1518
|
+
results: {
|
|
1519
|
+
"node1": {
|
|
1520
|
+
data: {
|
|
1521
|
+
"pg_stat_statements.max": { value: "5000" },
|
|
1522
|
+
"pg_stat_statements.track": { value: "all" }
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
const result = summary.generateCheckSummary("D004", report);
|
|
1528
|
+
expect(result.status).toBe("info");
|
|
1529
|
+
expect(result.message).toBe("2 pg_stat_statements settings collected");
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1532
|
+
test("generateCheckSummary for F001 (autovacuum)", () => {
|
|
1533
|
+
const report = {
|
|
1534
|
+
results: {
|
|
1535
|
+
"node1": {
|
|
1536
|
+
data: {
|
|
1537
|
+
"autovacuum": { value: "on" },
|
|
1538
|
+
"autovacuum_max_workers": { value: "3" }
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
const result = summary.generateCheckSummary("F001", report);
|
|
1544
|
+
expect(result.status).toBe("info");
|
|
1545
|
+
expect(result.message).toBe("2 autovacuum settings collected");
|
|
1546
|
+
});
|
|
1547
|
+
|
|
1548
|
+
test("generateCheckSummary for G001 (memory settings)", () => {
|
|
1549
|
+
const report = {
|
|
1550
|
+
results: {
|
|
1551
|
+
"node1": {
|
|
1552
|
+
data: {
|
|
1553
|
+
"shared_buffers": { value: "128MB" },
|
|
1554
|
+
"work_mem": { value: "4MB" }
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
const result = summary.generateCheckSummary("G001", report);
|
|
1560
|
+
expect(result.status).toBe("info");
|
|
1561
|
+
expect(result.message).toBe("2 memory settings collected");
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
test("generateCheckSummary for G003 with deadlocks", () => {
|
|
1565
|
+
const report = {
|
|
1566
|
+
results: {
|
|
1567
|
+
"node1": {
|
|
1568
|
+
data: {
|
|
1569
|
+
settings: {
|
|
1570
|
+
"lock_timeout": { value: "0" }
|
|
1571
|
+
},
|
|
1572
|
+
deadlock_stats: {
|
|
1573
|
+
deadlocks: 5,
|
|
1574
|
+
conflicts: 0,
|
|
1575
|
+
stats_reset: "2025-01-01"
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
const result = summary.generateCheckSummary("G003", report);
|
|
1582
|
+
expect(result.status).toBe("warning");
|
|
1583
|
+
expect(result.message).toBe("5 deadlocks detected");
|
|
1584
|
+
});
|
|
1585
|
+
|
|
1586
|
+
test("generateCheckSummary for G003 without deadlocks", () => {
|
|
1587
|
+
const report = {
|
|
1588
|
+
results: {
|
|
1589
|
+
"node1": {
|
|
1590
|
+
data: {
|
|
1591
|
+
settings: {
|
|
1592
|
+
"lock_timeout": { value: "0" },
|
|
1593
|
+
"statement_timeout": { value: "0" }
|
|
1594
|
+
},
|
|
1595
|
+
deadlock_stats: {
|
|
1596
|
+
deadlocks: 0,
|
|
1597
|
+
conflicts: 0
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
const result = summary.generateCheckSummary("G003", report);
|
|
1604
|
+
expect(result.status).toBe("info");
|
|
1605
|
+
expect(result.message).toBe("2 timeout/lock settings collected");
|
|
1606
|
+
});
|
|
1607
|
+
|
|
1608
|
+
// Edge cases: empty data
|
|
1609
|
+
test("generateCheckSummary for A003 with no settings", () => {
|
|
1610
|
+
const report = {
|
|
1611
|
+
results: {
|
|
1612
|
+
"node1": {
|
|
1613
|
+
data: {}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
const result = summary.generateCheckSummary("A003", report);
|
|
1618
|
+
expect(result.status).toBe("info");
|
|
1619
|
+
expect(result.message).toBe("No settings found");
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
test("generateCheckSummary for A004 with no data", () => {
|
|
1623
|
+
const report = {
|
|
1624
|
+
results: {
|
|
1625
|
+
"node1": {}
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
const result = summary.generateCheckSummary("A004", report);
|
|
1629
|
+
expect(result.status).toBe("info");
|
|
1630
|
+
expect(result.message).toBe("Cluster information collected");
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
test("generateCheckSummary for A004 with no database_sizes", () => {
|
|
1634
|
+
const report = {
|
|
1635
|
+
results: {
|
|
1636
|
+
"node1": {
|
|
1637
|
+
data: {
|
|
1638
|
+
general_info: {}
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
const result = summary.generateCheckSummary("A004", report);
|
|
1644
|
+
expect(result.status).toBe("info");
|
|
1645
|
+
expect(result.message).toBe("Cluster information collected");
|
|
1646
|
+
});
|
|
1647
|
+
|
|
1648
|
+
test("generateCheckSummary for A007 with no altered settings", () => {
|
|
1649
|
+
const report = {
|
|
1650
|
+
results: {
|
|
1651
|
+
"node1": {
|
|
1652
|
+
data: {}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
const result = summary.generateCheckSummary("A007", report);
|
|
1657
|
+
expect(result.status).toBe("ok");
|
|
1658
|
+
expect(result.message).toBe("No altered settings");
|
|
1659
|
+
});
|
|
1660
|
+
|
|
1661
|
+
test("generateCheckSummary for A002 with no version data", () => {
|
|
1662
|
+
const report = {
|
|
1663
|
+
results: {
|
|
1664
|
+
"node1": {
|
|
1665
|
+
data: {}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
const result = summary.generateCheckSummary("A002", report);
|
|
1670
|
+
expect(result.status).toBe("info");
|
|
1671
|
+
expect(result.message).toBe("Version checked");
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1674
|
+
test("generateCheckSummary for D001 with no settings", () => {
|
|
1675
|
+
const report = {
|
|
1676
|
+
results: {
|
|
1677
|
+
"node1": {
|
|
1678
|
+
data: {}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
const result = summary.generateCheckSummary("D001", report);
|
|
1683
|
+
expect(result.status).toBe("info");
|
|
1684
|
+
expect(result.message).toBe("No logging settings found");
|
|
1685
|
+
});
|
|
1686
|
+
|
|
1687
|
+
test("generateCheckSummary for D004 with no settings", () => {
|
|
1688
|
+
const report = {
|
|
1689
|
+
results: {
|
|
1690
|
+
"node1": {
|
|
1691
|
+
data: {}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
const result = summary.generateCheckSummary("D004", report);
|
|
1696
|
+
expect(result.status).toBe("info");
|
|
1697
|
+
expect(result.message).toBe("No pg_stat_statements settings found");
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
test("generateCheckSummary for F001 with no settings", () => {
|
|
1701
|
+
const report = {
|
|
1702
|
+
results: {
|
|
1703
|
+
"node1": {
|
|
1704
|
+
data: {}
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
const result = summary.generateCheckSummary("F001", report);
|
|
1709
|
+
expect(result.status).toBe("info");
|
|
1710
|
+
expect(result.message).toBe("No autovacuum settings found");
|
|
1711
|
+
});
|
|
1712
|
+
|
|
1713
|
+
test("generateCheckSummary for G001 with no settings", () => {
|
|
1714
|
+
const report = {
|
|
1715
|
+
results: {
|
|
1716
|
+
"node1": {
|
|
1717
|
+
data: {}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
const result = summary.generateCheckSummary("G001", report);
|
|
1722
|
+
expect(result.status).toBe("info");
|
|
1723
|
+
expect(result.message).toBe("No memory settings found");
|
|
1724
|
+
});
|
|
1725
|
+
|
|
1726
|
+
test("generateCheckSummary for G003 with no settings or deadlock_stats", () => {
|
|
1727
|
+
const report = {
|
|
1728
|
+
results: {
|
|
1729
|
+
"node1": {
|
|
1730
|
+
data: {}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
const result = summary.generateCheckSummary("G003", report);
|
|
1735
|
+
expect(result.status).toBe("info");
|
|
1736
|
+
expect(result.message).toBe("No timeout/lock settings found");
|
|
1737
|
+
});
|
|
1738
|
+
|
|
1739
|
+
test("generateCheckSummary for H001 with no invalid indexes", () => {
|
|
1740
|
+
const report = {
|
|
1741
|
+
results: {
|
|
1742
|
+
"node1": {
|
|
1743
|
+
data: {
|
|
1744
|
+
"db1": {
|
|
1745
|
+
invalid_indexes: [],
|
|
1746
|
+
total_count: 0,
|
|
1747
|
+
total_size_bytes: 0
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
const result = summary.generateCheckSummary("H001", report);
|
|
1754
|
+
expect(result.status).toBe("ok");
|
|
1755
|
+
expect(result.message).toBe("No invalid indexes");
|
|
1756
|
+
});
|
|
1757
|
+
|
|
1758
|
+
test("generateCheckSummary for H002 with all indexes utilized", () => {
|
|
1759
|
+
const report = {
|
|
1760
|
+
results: {
|
|
1761
|
+
"node1": {
|
|
1762
|
+
data: {
|
|
1763
|
+
"db1": {
|
|
1764
|
+
unused_indexes: [],
|
|
1765
|
+
total_count: 0,
|
|
1766
|
+
total_size_bytes: 0
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
const result = summary.generateCheckSummary("H002", report);
|
|
1773
|
+
expect(result.status).toBe("ok");
|
|
1774
|
+
expect(result.message).toBe("All indexes utilized");
|
|
1775
|
+
});
|
|
1776
|
+
|
|
1777
|
+
test("generateCheckSummary for H004 with no redundant indexes", () => {
|
|
1778
|
+
const report = {
|
|
1779
|
+
results: {
|
|
1780
|
+
"node1": {
|
|
1781
|
+
data: {
|
|
1782
|
+
"db1": {
|
|
1783
|
+
redundant_indexes: [],
|
|
1784
|
+
total_count: 0,
|
|
1785
|
+
total_size_bytes: 0
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
const result = summary.generateCheckSummary("H004", report);
|
|
1792
|
+
expect(result.status).toBe("ok");
|
|
1793
|
+
expect(result.message).toBe("No redundant indexes");
|
|
1794
|
+
});
|
|
1795
|
+
});
|
|
1796
|
+
|
|
1218
1797
|
|