@sonde/packs 0.1.0 → 0.1.1
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/.turbo/turbo-build.log +6 -0
- package/.turbo/turbo-test.log +814 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +10 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/citrix.d.ts +13 -0
- package/dist/integrations/citrix.d.ts.map +1 -0
- package/dist/integrations/citrix.js +420 -0
- package/dist/integrations/citrix.js.map +1 -0
- package/dist/integrations/citrix.test.d.ts +2 -0
- package/dist/integrations/citrix.test.d.ts.map +1 -0
- package/dist/integrations/citrix.test.js +464 -0
- package/dist/integrations/citrix.test.js.map +1 -0
- package/dist/integrations/graph.d.ts +9 -0
- package/dist/integrations/graph.d.ts.map +1 -0
- package/dist/integrations/graph.js +290 -0
- package/dist/integrations/graph.js.map +1 -0
- package/dist/integrations/graph.test.d.ts +2 -0
- package/dist/integrations/graph.test.d.ts.map +1 -0
- package/dist/integrations/graph.test.js +356 -0
- package/dist/integrations/graph.test.js.map +1 -0
- package/dist/integrations/httpbin.d.ts +3 -0
- package/dist/integrations/httpbin.d.ts.map +1 -0
- package/dist/integrations/httpbin.js +70 -0
- package/dist/integrations/httpbin.js.map +1 -0
- package/dist/integrations/nutanix.d.ts +18 -0
- package/dist/integrations/nutanix.d.ts.map +1 -0
- package/dist/integrations/nutanix.js +1121 -0
- package/dist/integrations/nutanix.js.map +1 -0
- package/dist/integrations/nutanix.test.d.ts +2 -0
- package/dist/integrations/nutanix.test.d.ts.map +1 -0
- package/dist/integrations/nutanix.test.js +978 -0
- package/dist/integrations/nutanix.test.js.map +1 -0
- package/dist/integrations/proxmox.d.ts +12 -0
- package/dist/integrations/proxmox.d.ts.map +1 -0
- package/dist/integrations/proxmox.js +733 -0
- package/dist/integrations/proxmox.js.map +1 -0
- package/dist/integrations/proxmox.test.d.ts +2 -0
- package/dist/integrations/proxmox.test.d.ts.map +1 -0
- package/dist/integrations/proxmox.test.js +697 -0
- package/dist/integrations/proxmox.test.js.map +1 -0
- package/dist/integrations/servicenow.d.ts +3 -0
- package/dist/integrations/servicenow.d.ts.map +1 -0
- package/dist/integrations/servicenow.js +257 -0
- package/dist/integrations/servicenow.js.map +1 -0
- package/dist/integrations/servicenow.test.d.ts +2 -0
- package/dist/integrations/servicenow.test.d.ts.map +1 -0
- package/dist/integrations/servicenow.test.js +217 -0
- package/dist/integrations/servicenow.test.js.map +1 -0
- package/dist/integrations/splunk.d.ts +9 -0
- package/dist/integrations/splunk.d.ts.map +1 -0
- package/dist/integrations/splunk.js +242 -0
- package/dist/integrations/splunk.js.map +1 -0
- package/dist/integrations/splunk.test.d.ts +2 -0
- package/dist/integrations/splunk.test.d.ts.map +1 -0
- package/dist/integrations/splunk.test.js +323 -0
- package/dist/integrations/splunk.test.js.map +1 -0
- package/dist/mysql/index.d.ts +3 -0
- package/dist/mysql/index.d.ts.map +1 -0
- package/dist/mysql/index.js +13 -0
- package/dist/mysql/index.js.map +1 -0
- package/dist/mysql/manifest.d.ts +3 -0
- package/dist/mysql/manifest.d.ts.map +1 -0
- package/dist/mysql/manifest.js +69 -0
- package/dist/mysql/manifest.js.map +1 -0
- package/dist/mysql/probes/databases-list.d.ts +13 -0
- package/dist/mysql/probes/databases-list.d.ts.map +1 -0
- package/dist/mysql/probes/databases-list.js +31 -0
- package/dist/mysql/probes/databases-list.js.map +1 -0
- package/dist/mysql/probes/databases-list.test.d.ts +2 -0
- package/dist/mysql/probes/databases-list.test.d.ts.map +1 -0
- package/dist/mysql/probes/databases-list.test.js +54 -0
- package/dist/mysql/probes/databases-list.test.js.map +1 -0
- package/dist/mysql/probes/processlist.d.ts +18 -0
- package/dist/mysql/probes/processlist.d.ts.map +1 -0
- package/dist/mysql/probes/processlist.js +36 -0
- package/dist/mysql/probes/processlist.js.map +1 -0
- package/dist/mysql/probes/processlist.test.d.ts +2 -0
- package/dist/mysql/probes/processlist.test.d.ts.map +1 -0
- package/dist/mysql/probes/processlist.test.js +41 -0
- package/dist/mysql/probes/processlist.test.js.map +1 -0
- package/dist/mysql/probes/status.d.ts +14 -0
- package/dist/mysql/probes/status.d.ts.map +1 -0
- package/dist/mysql/probes/status.js +40 -0
- package/dist/mysql/probes/status.js.map +1 -0
- package/dist/mysql/probes/status.test.d.ts +2 -0
- package/dist/mysql/probes/status.test.d.ts.map +1 -0
- package/dist/mysql/probes/status.test.js +43 -0
- package/dist/mysql/probes/status.test.js.map +1 -0
- package/dist/nginx/index.d.ts +3 -0
- package/dist/nginx/index.d.ts.map +1 -0
- package/dist/nginx/index.js +13 -0
- package/dist/nginx/index.js.map +1 -0
- package/dist/nginx/manifest.d.ts +3 -0
- package/dist/nginx/manifest.d.ts.map +1 -0
- package/dist/nginx/manifest.js +68 -0
- package/dist/nginx/manifest.js.map +1 -0
- package/dist/nginx/probes/access-log-tail.d.ts +9 -0
- package/dist/nginx/probes/access-log-tail.d.ts.map +1 -0
- package/dist/nginx/probes/access-log-tail.js +14 -0
- package/dist/nginx/probes/access-log-tail.js.map +1 -0
- package/dist/nginx/probes/access-log-tail.test.d.ts +2 -0
- package/dist/nginx/probes/access-log-tail.test.d.ts.map +1 -0
- package/dist/nginx/probes/access-log-tail.test.js +40 -0
- package/dist/nginx/probes/access-log-tail.test.js.map +1 -0
- package/dist/nginx/probes/config-test.d.ts +8 -0
- package/dist/nginx/probes/config-test.d.ts.map +1 -0
- package/dist/nginx/probes/config-test.js +18 -0
- package/dist/nginx/probes/config-test.js.map +1 -0
- package/dist/nginx/probes/config-test.test.d.ts +2 -0
- package/dist/nginx/probes/config-test.test.d.ts.map +1 -0
- package/dist/nginx/probes/config-test.test.js +35 -0
- package/dist/nginx/probes/config-test.test.js.map +1 -0
- package/dist/nginx/probes/error-log-tail.d.ts +9 -0
- package/dist/nginx/probes/error-log-tail.d.ts.map +1 -0
- package/dist/nginx/probes/error-log-tail.js +14 -0
- package/dist/nginx/probes/error-log-tail.js.map +1 -0
- package/dist/nginx/probes/error-log-tail.test.d.ts +2 -0
- package/dist/nginx/probes/error-log-tail.test.d.ts.map +1 -0
- package/dist/nginx/probes/error-log-tail.test.js +34 -0
- package/dist/nginx/probes/error-log-tail.test.js.map +1 -0
- package/dist/postgres/index.d.ts +3 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +13 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/postgres/manifest.d.ts +3 -0
- package/dist/postgres/manifest.d.ts.map +1 -0
- package/dist/postgres/manifest.js +90 -0
- package/dist/postgres/manifest.js.map +1 -0
- package/dist/postgres/probes/connections-active.d.ts +17 -0
- package/dist/postgres/probes/connections-active.d.ts.map +1 -0
- package/dist/postgres/probes/connections-active.js +37 -0
- package/dist/postgres/probes/connections-active.js.map +1 -0
- package/dist/postgres/probes/connections-active.test.d.ts +2 -0
- package/dist/postgres/probes/connections-active.test.d.ts.map +1 -0
- package/dist/postgres/probes/connections-active.test.js +36 -0
- package/dist/postgres/probes/connections-active.test.js.map +1 -0
- package/dist/postgres/probes/databases-list.d.ts +14 -0
- package/dist/postgres/probes/databases-list.d.ts.map +1 -0
- package/dist/postgres/probes/databases-list.js +34 -0
- package/dist/postgres/probes/databases-list.js.map +1 -0
- package/dist/postgres/probes/databases-list.test.d.ts +2 -0
- package/dist/postgres/probes/databases-list.test.d.ts.map +1 -0
- package/dist/postgres/probes/databases-list.test.js +49 -0
- package/dist/postgres/probes/databases-list.test.js.map +1 -0
- package/dist/postgres/probes/query-slow.d.ts +17 -0
- package/dist/postgres/probes/query-slow.d.ts.map +1 -0
- package/dist/postgres/probes/query-slow.js +37 -0
- package/dist/postgres/probes/query-slow.js.map +1 -0
- package/dist/postgres/probes/query-slow.test.d.ts +2 -0
- package/dist/postgres/probes/query-slow.test.d.ts.map +1 -0
- package/dist/postgres/probes/query-slow.test.js +30 -0
- package/dist/postgres/probes/query-slow.test.js.map +1 -0
- package/dist/proxmox/index.d.ts +3 -0
- package/dist/proxmox/index.d.ts.map +1 -0
- package/dist/proxmox/index.js +23 -0
- package/dist/proxmox/index.js.map +1 -0
- package/dist/proxmox/manifest.d.ts +3 -0
- package/dist/proxmox/manifest.d.ts.map +1 -0
- package/dist/proxmox/manifest.js +75 -0
- package/dist/proxmox/manifest.js.map +1 -0
- package/dist/proxmox/probes/ceph-status.d.ts +36 -0
- package/dist/proxmox/probes/ceph-status.d.ts.map +1 -0
- package/dist/proxmox/probes/ceph-status.js +71 -0
- package/dist/proxmox/probes/ceph-status.js.map +1 -0
- package/dist/proxmox/probes/ceph-status.test.d.ts +2 -0
- package/dist/proxmox/probes/ceph-status.test.d.ts.map +1 -0
- package/dist/proxmox/probes/ceph-status.test.js +115 -0
- package/dist/proxmox/probes/ceph-status.test.js.map +1 -0
- package/dist/proxmox/probes/cluster-config.d.ts +31 -0
- package/dist/proxmox/probes/cluster-config.d.ts.map +1 -0
- package/dist/proxmox/probes/cluster-config.js +72 -0
- package/dist/proxmox/probes/cluster-config.js.map +1 -0
- package/dist/proxmox/probes/cluster-config.test.d.ts +2 -0
- package/dist/proxmox/probes/cluster-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/cluster-config.test.js +107 -0
- package/dist/proxmox/probes/cluster-config.test.js.map +1 -0
- package/dist/proxmox/probes/ha-status.d.ts +18 -0
- package/dist/proxmox/probes/ha-status.d.ts.map +1 -0
- package/dist/proxmox/probes/ha-status.js +38 -0
- package/dist/proxmox/probes/ha-status.js.map +1 -0
- package/dist/proxmox/probes/ha-status.test.d.ts +2 -0
- package/dist/proxmox/probes/ha-status.test.d.ts.map +1 -0
- package/dist/proxmox/probes/ha-status.test.js +66 -0
- package/dist/proxmox/probes/ha-status.test.js.map +1 -0
- package/dist/proxmox/probes/lvm.d.ts +35 -0
- package/dist/proxmox/probes/lvm.d.ts.map +1 -0
- package/dist/proxmox/probes/lvm.js +75 -0
- package/dist/proxmox/probes/lvm.js.map +1 -0
- package/dist/proxmox/probes/lvm.test.d.ts +2 -0
- package/dist/proxmox/probes/lvm.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lvm.test.js +128 -0
- package/dist/proxmox/probes/lvm.test.js.map +1 -0
- package/dist/proxmox/probes/lxc-config.d.ts +29 -0
- package/dist/proxmox/probes/lxc-config.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-config.js +67 -0
- package/dist/proxmox/probes/lxc-config.js.map +1 -0
- package/dist/proxmox/probes/lxc-config.test.d.ts +2 -0
- package/dist/proxmox/probes/lxc-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-config.test.js +77 -0
- package/dist/proxmox/probes/lxc-config.test.js.map +1 -0
- package/dist/proxmox/probes/lxc-list.d.ts +20 -0
- package/dist/proxmox/probes/lxc-list.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-list.js +49 -0
- package/dist/proxmox/probes/lxc-list.js.map +1 -0
- package/dist/proxmox/probes/lxc-list.test.d.ts +2 -0
- package/dist/proxmox/probes/lxc-list.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-list.test.js +51 -0
- package/dist/proxmox/probes/lxc-list.test.js.map +1 -0
- package/dist/proxmox/probes/vm-config.d.ts +21 -0
- package/dist/proxmox/probes/vm-config.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-config.js +58 -0
- package/dist/proxmox/probes/vm-config.js.map +1 -0
- package/dist/proxmox/probes/vm-config.test.d.ts +2 -0
- package/dist/proxmox/probes/vm-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-config.test.js +80 -0
- package/dist/proxmox/probes/vm-config.test.js.map +1 -0
- package/dist/proxmox/probes/vm-locks.d.ts +16 -0
- package/dist/proxmox/probes/vm-locks.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-locks.js +35 -0
- package/dist/proxmox/probes/vm-locks.js.map +1 -0
- package/dist/proxmox/probes/vm-locks.test.d.ts +2 -0
- package/dist/proxmox/probes/vm-locks.test.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-locks.test.js +54 -0
- package/dist/proxmox/probes/vm-locks.test.js.map +1 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +13 -0
- package/dist/redis/index.js.map +1 -0
- package/dist/redis/manifest.d.ts +3 -0
- package/dist/redis/manifest.d.ts.map +1 -0
- package/dist/redis/manifest.js +51 -0
- package/dist/redis/manifest.js.map +1 -0
- package/dist/redis/probes/info.d.ts +15 -0
- package/dist/redis/probes/info.d.ts.map +1 -0
- package/dist/redis/probes/info.js +32 -0
- package/dist/redis/probes/info.js.map +1 -0
- package/dist/redis/probes/info.test.d.ts +2 -0
- package/dist/redis/probes/info.test.d.ts.map +1 -0
- package/dist/redis/probes/info.test.js +64 -0
- package/dist/redis/probes/info.test.js.map +1 -0
- package/dist/redis/probes/keys-count.d.ts +13 -0
- package/dist/redis/probes/keys-count.d.ts.map +1 -0
- package/dist/redis/probes/keys-count.js +24 -0
- package/dist/redis/probes/keys-count.js.map +1 -0
- package/dist/redis/probes/keys-count.test.d.ts +2 -0
- package/dist/redis/probes/keys-count.test.d.ts.map +1 -0
- package/dist/redis/probes/keys-count.test.js +37 -0
- package/dist/redis/probes/keys-count.test.js.map +1 -0
- package/dist/redis/probes/memory-usage.d.ts +16 -0
- package/dist/redis/probes/memory-usage.d.ts.map +1 -0
- package/dist/redis/probes/memory-usage.js +31 -0
- package/dist/redis/probes/memory-usage.js.map +1 -0
- package/dist/redis/probes/memory-usage.test.d.ts +2 -0
- package/dist/redis/probes/memory-usage.test.d.ts.map +1 -0
- package/dist/redis/probes/memory-usage.test.js +48 -0
- package/dist/redis/probes/memory-usage.test.js.map +1 -0
- package/dist/runbooks/nutanix.d.ts +3 -0
- package/dist/runbooks/nutanix.d.ts.map +1 -0
- package/dist/runbooks/nutanix.js +619 -0
- package/dist/runbooks/nutanix.js.map +1 -0
- package/dist/runbooks/nutanix.test.d.ts +2 -0
- package/dist/runbooks/nutanix.test.d.ts.map +1 -0
- package/dist/runbooks/nutanix.test.js +971 -0
- package/dist/runbooks/nutanix.test.js.map +1 -0
- package/dist/runbooks/proxmox.d.ts +3 -0
- package/dist/runbooks/proxmox.d.ts.map +1 -0
- package/dist/runbooks/proxmox.js +451 -0
- package/dist/runbooks/proxmox.js.map +1 -0
- package/dist/runbooks/proxmox.test.d.ts +2 -0
- package/dist/runbooks/proxmox.test.d.ts.map +1 -0
- package/dist/runbooks/proxmox.test.js +700 -0
- package/dist/runbooks/proxmox.test.js.map +1 -0
- package/dist/signatures.d.ts +2 -0
- package/dist/signatures.d.ts.map +1 -0
- package/dist/signatures.js +2 -0
- package/dist/signatures.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +6 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +10 -1
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +60 -6
- package/src/integrations/citrix.test.ts +592 -0
- package/src/integrations/citrix.ts +557 -0
- package/src/integrations/graph.test.ts +478 -0
- package/src/integrations/graph.ts +413 -0
- package/src/integrations/httpbin.ts +72 -0
- package/src/integrations/nutanix.test.ts +1508 -0
- package/src/integrations/nutanix.ts +1460 -0
- package/src/integrations/proxmox.test.ts +1020 -0
- package/src/integrations/proxmox.ts +989 -0
- package/src/integrations/servicenow.test.ts +314 -0
- package/src/integrations/servicenow.ts +285 -0
- package/src/integrations/splunk.test.ts +440 -0
- package/src/integrations/splunk.ts +356 -0
- package/src/mysql/index.ts +14 -0
- package/src/mysql/manifest.ts +70 -0
- package/src/mysql/probes/databases-list.test.ts +62 -0
- package/src/mysql/probes/databases-list.ts +45 -0
- package/src/mysql/probes/processlist.test.ts +47 -0
- package/src/mysql/probes/processlist.ts +55 -0
- package/src/mysql/probes/status.test.ts +50 -0
- package/src/mysql/probes/status.ts +56 -0
- package/src/nginx/index.ts +14 -0
- package/src/nginx/manifest.ts +69 -0
- package/src/nginx/probes/access-log-tail.test.ts +51 -0
- package/src/nginx/probes/access-log-tail.ts +23 -0
- package/src/nginx/probes/config-test.test.ts +47 -0
- package/src/nginx/probes/config-test.ts +24 -0
- package/src/nginx/probes/error-log-tail.test.ts +44 -0
- package/src/nginx/probes/error-log-tail.ts +23 -0
- package/src/postgres/index.ts +14 -0
- package/src/postgres/manifest.ts +91 -0
- package/src/postgres/probes/connections-active.test.ts +42 -0
- package/src/postgres/probes/connections-active.ts +55 -0
- package/src/postgres/probes/databases-list.test.ts +57 -0
- package/src/postgres/probes/databases-list.ts +49 -0
- package/src/postgres/probes/query-slow.test.ts +37 -0
- package/src/postgres/probes/query-slow.ts +55 -0
- package/src/proxmox/index.ts +24 -0
- package/src/proxmox/manifest.ts +76 -0
- package/src/proxmox/probes/ceph-status.test.ts +126 -0
- package/src/proxmox/probes/ceph-status.ts +116 -0
- package/src/proxmox/probes/cluster-config.test.ts +118 -0
- package/src/proxmox/probes/cluster-config.ts +97 -0
- package/src/proxmox/probes/ha-status.test.ts +76 -0
- package/src/proxmox/probes/ha-status.ts +56 -0
- package/src/proxmox/probes/lvm.test.ts +140 -0
- package/src/proxmox/probes/lvm.ts +121 -0
- package/src/proxmox/probes/lxc-config.test.ts +89 -0
- package/src/proxmox/probes/lxc-config.ts +90 -0
- package/src/proxmox/probes/lxc-list.test.ts +60 -0
- package/src/proxmox/probes/lxc-list.ts +67 -0
- package/src/proxmox/probes/vm-config.test.ts +93 -0
- package/src/proxmox/probes/vm-config.ts +77 -0
- package/src/proxmox/probes/vm-locks.test.ts +63 -0
- package/src/proxmox/probes/vm-locks.ts +49 -0
- package/src/redis/index.ts +14 -0
- package/src/redis/manifest.ts +52 -0
- package/src/redis/probes/info.test.ts +73 -0
- package/src/redis/probes/info.ts +46 -0
- package/src/redis/probes/keys-count.test.ts +44 -0
- package/src/redis/probes/keys-count.ts +38 -0
- package/src/redis/probes/memory-usage.test.ts +54 -0
- package/src/redis/probes/memory-usage.ts +46 -0
- package/src/runbooks/nutanix.test.ts +1138 -0
- package/src/runbooks/nutanix.ts +941 -0
- package/src/runbooks/proxmox.test.ts +838 -0
- package/src/runbooks/proxmox.ts +626 -0
- package/src/signatures.ts +1 -0
- package/src/types.ts +62 -0
- package/src/validation.ts +21 -1
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,971 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { nutanixDiagnosticRunbooks } from './nutanix.js';
|
|
3
|
+
// --- Test helpers ---
|
|
4
|
+
function getHandler(category) {
|
|
5
|
+
const def = nutanixDiagnosticRunbooks.find((r) => r.category === category);
|
|
6
|
+
if (!def)
|
|
7
|
+
throw new Error(`No runbook for category "${category}"`);
|
|
8
|
+
return def.handler;
|
|
9
|
+
}
|
|
10
|
+
function mockResult(probe, data, status = 'success', error) {
|
|
11
|
+
return { probe, status, data, durationMs: 10, error };
|
|
12
|
+
}
|
|
13
|
+
function createMockRunProbe(responses) {
|
|
14
|
+
return async (probe, _params, _agent) => {
|
|
15
|
+
const response = responses[probe];
|
|
16
|
+
if (!response) {
|
|
17
|
+
return mockResult(probe, undefined, 'error', `No mock for probe ${probe}`);
|
|
18
|
+
}
|
|
19
|
+
return mockResult(probe, response.data, response.status ?? 'success', response.error);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const defaultContext = { connectedAgents: [] };
|
|
23
|
+
// --- Fixtures ---
|
|
24
|
+
const healthyClusters = {
|
|
25
|
+
clusters: [
|
|
26
|
+
{ name: 'prod-01', extId: 'c-001', operationMode: 'NORMAL', isDegraded: false, numNodes: 4 },
|
|
27
|
+
{ name: 'prod-02', extId: 'c-002', operationMode: 'NORMAL', isDegraded: false, numNodes: 3 },
|
|
28
|
+
],
|
|
29
|
+
totalCount: 2,
|
|
30
|
+
};
|
|
31
|
+
const healthyHosts = {
|
|
32
|
+
hosts: [
|
|
33
|
+
{ name: 'host-01', extId: 'h-001', maintenanceMode: false },
|
|
34
|
+
{ name: 'host-02', extId: 'h-002', maintenanceMode: false },
|
|
35
|
+
{ name: 'host-03', extId: 'h-003', maintenanceMode: false },
|
|
36
|
+
],
|
|
37
|
+
totalCount: 3,
|
|
38
|
+
};
|
|
39
|
+
const healthyAlertsSummary = {
|
|
40
|
+
bySeverity: { CRITICAL: 0, WARNING: 2, INFO: 5 },
|
|
41
|
+
byEntityType: { vm: 5, host: 2 },
|
|
42
|
+
unresolvedCritical: [],
|
|
43
|
+
totalCount: 7,
|
|
44
|
+
};
|
|
45
|
+
const healthyStorage = {
|
|
46
|
+
containers: [
|
|
47
|
+
{
|
|
48
|
+
name: 'default-container',
|
|
49
|
+
usedPct: 45,
|
|
50
|
+
highUsage: false,
|
|
51
|
+
maxCapacityBytes: 1e12,
|
|
52
|
+
usedBytes: 4.5e11,
|
|
53
|
+
availableBytes: 5.5e11,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'ssd-tier',
|
|
57
|
+
usedPct: 60,
|
|
58
|
+
highUsage: false,
|
|
59
|
+
maxCapacityBytes: 5e11,
|
|
60
|
+
usedBytes: 3e11,
|
|
61
|
+
availableBytes: 2e11,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
totalCount: 2,
|
|
65
|
+
};
|
|
66
|
+
const healthyTasks = {
|
|
67
|
+
tasks: [
|
|
68
|
+
{
|
|
69
|
+
type: 'VmCreate',
|
|
70
|
+
status: 'SUCCEEDED',
|
|
71
|
+
isFailed: false,
|
|
72
|
+
isLongRunning: false,
|
|
73
|
+
startTime: '2026-02-17T10:00:00Z',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
totalCount: 1,
|
|
77
|
+
};
|
|
78
|
+
const healthyLifecycle = {
|
|
79
|
+
entities: [],
|
|
80
|
+
updatableCount: 0,
|
|
81
|
+
totalCount: 0,
|
|
82
|
+
warnings: [],
|
|
83
|
+
};
|
|
84
|
+
const healthyVmDetail = {
|
|
85
|
+
name: 'web-01',
|
|
86
|
+
extId: 'vm-001',
|
|
87
|
+
powerState: 'ON',
|
|
88
|
+
numSockets: 4,
|
|
89
|
+
numCoresPerSocket: 2,
|
|
90
|
+
memorySizeMb: 8192,
|
|
91
|
+
clusterExtId: 'c-001',
|
|
92
|
+
hostExtId: 'h-001',
|
|
93
|
+
guestTools: { isEnabled: true },
|
|
94
|
+
categories: null,
|
|
95
|
+
};
|
|
96
|
+
const healthyVmStats = {
|
|
97
|
+
cpuUsagePct: 35,
|
|
98
|
+
memoryUsagePct: 55,
|
|
99
|
+
iops: 200,
|
|
100
|
+
avgIoLatencyMs: 5,
|
|
101
|
+
ioBandwidthKbps: 50000,
|
|
102
|
+
networkRxBytes: 1000000,
|
|
103
|
+
networkTxBytes: 500000,
|
|
104
|
+
};
|
|
105
|
+
const healthySnapshots = {
|
|
106
|
+
snapshots: [{ name: 'daily-snap', ageDays: 1, isOld: false, isExpired: false }],
|
|
107
|
+
totalCount: 1,
|
|
108
|
+
usedV3: false,
|
|
109
|
+
warnings: [],
|
|
110
|
+
};
|
|
111
|
+
const healthyProtection = {
|
|
112
|
+
policies: [{ name: 'gold-policy', extId: 'pp-001' }],
|
|
113
|
+
totalCount: 1,
|
|
114
|
+
vmCovered: true,
|
|
115
|
+
allPoliciesCount: 3,
|
|
116
|
+
};
|
|
117
|
+
const emptyAlerts = { alerts: [], totalCount: 0 };
|
|
118
|
+
// =============================================================================
|
|
119
|
+
// nutanix-cluster-health tests
|
|
120
|
+
// =============================================================================
|
|
121
|
+
describe('nutanix-cluster-health', () => {
|
|
122
|
+
const handler = getHandler('nutanix-cluster-health');
|
|
123
|
+
it('healthy environment — no issues', async () => {
|
|
124
|
+
const runProbe = createMockRunProbe({
|
|
125
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
126
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
127
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
128
|
+
'nutanix.tasks.recent': { data: healthyTasks },
|
|
129
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
130
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
131
|
+
});
|
|
132
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
133
|
+
expect(result.category).toBe('nutanix-cluster-health');
|
|
134
|
+
expect(result.findings).toHaveLength(1);
|
|
135
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
136
|
+
expect(result.findings[0]?.title).toContain('healthy');
|
|
137
|
+
expect(result.summary.probesRun).toBe(6);
|
|
138
|
+
});
|
|
139
|
+
it('degraded cluster — critical finding', async () => {
|
|
140
|
+
const degraded = {
|
|
141
|
+
clusters: [
|
|
142
|
+
{
|
|
143
|
+
name: 'prod-01',
|
|
144
|
+
extId: 'c-001',
|
|
145
|
+
operationMode: 'READ_ONLY',
|
|
146
|
+
isDegraded: true,
|
|
147
|
+
numNodes: 4,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
totalCount: 1,
|
|
151
|
+
};
|
|
152
|
+
const runProbe = createMockRunProbe({
|
|
153
|
+
'nutanix.clusters.list': { data: degraded },
|
|
154
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
155
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
156
|
+
'nutanix.tasks.recent': { data: healthyTasks },
|
|
157
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
158
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
159
|
+
});
|
|
160
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
161
|
+
const critical = result.findings.find((f) => f.title.includes('degraded'));
|
|
162
|
+
expect(critical).toBeDefined();
|
|
163
|
+
expect(critical?.severity).toBe('critical');
|
|
164
|
+
expect(critical?.detail).toContain('READ_ONLY');
|
|
165
|
+
});
|
|
166
|
+
it('hosts in maintenance — warning', async () => {
|
|
167
|
+
const maintenanceHosts = {
|
|
168
|
+
hosts: [
|
|
169
|
+
{ name: 'host-01', extId: 'h-001', maintenanceMode: true },
|
|
170
|
+
{ name: 'host-02', extId: 'h-002', maintenanceMode: false },
|
|
171
|
+
],
|
|
172
|
+
totalCount: 2,
|
|
173
|
+
};
|
|
174
|
+
const runProbe = createMockRunProbe({
|
|
175
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
176
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
177
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
178
|
+
'nutanix.tasks.recent': { data: healthyTasks },
|
|
179
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
180
|
+
'nutanix.hosts.list': { data: maintenanceHosts },
|
|
181
|
+
});
|
|
182
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
183
|
+
const warning = result.findings.find((f) => f.title.includes('maintenance'));
|
|
184
|
+
expect(warning).toBeDefined();
|
|
185
|
+
expect(warning?.severity).toBe('warning');
|
|
186
|
+
expect(warning?.detail).toContain('host-01');
|
|
187
|
+
});
|
|
188
|
+
it('unresolved critical alerts — critical findings', async () => {
|
|
189
|
+
const criticalAlerts = {
|
|
190
|
+
bySeverity: { CRITICAL: 2, WARNING: 0, INFO: 0 },
|
|
191
|
+
byEntityType: { vm: 2 },
|
|
192
|
+
unresolvedCritical: [
|
|
193
|
+
{
|
|
194
|
+
title: 'Disk failure on host-01',
|
|
195
|
+
sourceEntity: { type: 'host', name: 'host-01' },
|
|
196
|
+
creationTime: '2026-02-17T08:00:00Z',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
title: 'Memory threshold exceeded',
|
|
200
|
+
sourceEntity: { type: 'vm', name: 'web-01' },
|
|
201
|
+
creationTime: '2026-02-17T09:00:00Z',
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
totalCount: 2,
|
|
205
|
+
};
|
|
206
|
+
const runProbe = createMockRunProbe({
|
|
207
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
208
|
+
'nutanix.alerts.summary': { data: criticalAlerts },
|
|
209
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
210
|
+
'nutanix.tasks.recent': { data: healthyTasks },
|
|
211
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
212
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
213
|
+
});
|
|
214
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
215
|
+
const criticals = result.findings.filter((f) => f.severity === 'critical');
|
|
216
|
+
expect(criticals.length).toBe(2);
|
|
217
|
+
expect(criticals[0]?.title).toContain('Disk failure');
|
|
218
|
+
});
|
|
219
|
+
it('storage >85% — warning', async () => {
|
|
220
|
+
const fullStorage = {
|
|
221
|
+
containers: [
|
|
222
|
+
{
|
|
223
|
+
name: 'full-container',
|
|
224
|
+
usedPct: 92,
|
|
225
|
+
highUsage: true,
|
|
226
|
+
maxCapacityBytes: 1e12,
|
|
227
|
+
usedBytes: 9.2e11,
|
|
228
|
+
availableBytes: 8e10,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
totalCount: 1,
|
|
232
|
+
};
|
|
233
|
+
const runProbe = createMockRunProbe({
|
|
234
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
235
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
236
|
+
'nutanix.storage.containers': { data: fullStorage },
|
|
237
|
+
'nutanix.tasks.recent': { data: healthyTasks },
|
|
238
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
239
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
240
|
+
});
|
|
241
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
242
|
+
const warning = result.findings.find((f) => f.title.includes('full-container'));
|
|
243
|
+
expect(warning).toBeDefined();
|
|
244
|
+
expect(warning?.severity).toBe('warning');
|
|
245
|
+
expect(warning?.title).toContain('92%');
|
|
246
|
+
});
|
|
247
|
+
it('failed tasks — warning', async () => {
|
|
248
|
+
const failedTasks = {
|
|
249
|
+
tasks: [
|
|
250
|
+
{
|
|
251
|
+
type: 'VmMigrate',
|
|
252
|
+
status: 'FAILED',
|
|
253
|
+
isFailed: true,
|
|
254
|
+
isLongRunning: false,
|
|
255
|
+
errorMessage: 'Insufficient resources',
|
|
256
|
+
startTime: '2026-02-17T10:00:00Z',
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
totalCount: 1,
|
|
260
|
+
};
|
|
261
|
+
const runProbe = createMockRunProbe({
|
|
262
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
263
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
264
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
265
|
+
'nutanix.tasks.recent': { data: failedTasks },
|
|
266
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
267
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
268
|
+
});
|
|
269
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
270
|
+
const warning = result.findings.find((f) => f.title.includes('failed task'));
|
|
271
|
+
expect(warning).toBeDefined();
|
|
272
|
+
expect(warning?.severity).toBe('warning');
|
|
273
|
+
});
|
|
274
|
+
it('long-running tasks — warning', async () => {
|
|
275
|
+
const longRunningTasks = {
|
|
276
|
+
tasks: [
|
|
277
|
+
{
|
|
278
|
+
type: 'ClusterUpgrade',
|
|
279
|
+
status: 'RUNNING',
|
|
280
|
+
isFailed: false,
|
|
281
|
+
isLongRunning: true,
|
|
282
|
+
startTime: '2026-02-17T06:00:00Z',
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
totalCount: 1,
|
|
286
|
+
};
|
|
287
|
+
const runProbe = createMockRunProbe({
|
|
288
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
289
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
290
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
291
|
+
'nutanix.tasks.recent': { data: longRunningTasks },
|
|
292
|
+
'nutanix.lifecycle.status': { data: healthyLifecycle },
|
|
293
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
294
|
+
});
|
|
295
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
296
|
+
const warning = result.findings.find((f) => f.title.includes('long-running'));
|
|
297
|
+
expect(warning).toBeDefined();
|
|
298
|
+
expect(warning?.severity).toBe('warning');
|
|
299
|
+
});
|
|
300
|
+
it('LCM updates available — info finding', async () => {
|
|
301
|
+
const updatesAvailable = {
|
|
302
|
+
entities: [
|
|
303
|
+
{ entityType: 'AOS', currentVersion: '6.5.1', availableVersion: '6.6.0', hasUpdate: true },
|
|
304
|
+
],
|
|
305
|
+
updatableCount: 1,
|
|
306
|
+
totalCount: 1,
|
|
307
|
+
warnings: ['1 component(s) have available updates', 'AOS: 6.5.1 \u2192 6.6.0'],
|
|
308
|
+
};
|
|
309
|
+
const runProbe = createMockRunProbe({
|
|
310
|
+
'nutanix.clusters.list': { data: healthyClusters },
|
|
311
|
+
'nutanix.alerts.summary': { data: healthyAlertsSummary },
|
|
312
|
+
'nutanix.storage.containers': { data: healthyStorage },
|
|
313
|
+
'nutanix.tasks.recent': { data: healthyTasks },
|
|
314
|
+
'nutanix.lifecycle.status': { data: updatesAvailable },
|
|
315
|
+
'nutanix.hosts.list': { data: healthyHosts },
|
|
316
|
+
});
|
|
317
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
318
|
+
const info = result.findings.find((f) => f.title.includes('update'));
|
|
319
|
+
expect(info).toBeDefined();
|
|
320
|
+
expect(info?.severity).toBe('info');
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
// =============================================================================
|
|
324
|
+
// nutanix-vm-health tests
|
|
325
|
+
// =============================================================================
|
|
326
|
+
describe('nutanix-vm-health', () => {
|
|
327
|
+
const handler = getHandler('nutanix-vm-health');
|
|
328
|
+
it('healthy VM by ID — all probes good', async () => {
|
|
329
|
+
const runProbe = createMockRunProbe({
|
|
330
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
331
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
332
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
333
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
334
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
335
|
+
});
|
|
336
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
337
|
+
expect(result.category).toBe('nutanix-vm-health');
|
|
338
|
+
expect(result.findings).toHaveLength(1);
|
|
339
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
340
|
+
expect(result.findings[0]?.title).toContain('healthy');
|
|
341
|
+
expect(result.summary.probesRun).toBe(5);
|
|
342
|
+
});
|
|
343
|
+
it('resolve vm_name to vm_id', async () => {
|
|
344
|
+
const calls = [];
|
|
345
|
+
const runProbe = async (probe, params) => {
|
|
346
|
+
calls.push({ probe, params });
|
|
347
|
+
const responses = {
|
|
348
|
+
'nutanix.vms.list': { vms: [{ name: 'web-01', extId: 'vm-001' }] },
|
|
349
|
+
'nutanix.vm.detail': healthyVmDetail,
|
|
350
|
+
'nutanix.vm.stats': healthyVmStats,
|
|
351
|
+
'nutanix.vm.snapshots': healthySnapshots,
|
|
352
|
+
'nutanix.alerts.list': emptyAlerts,
|
|
353
|
+
'nutanix.protection.policies': healthyProtection,
|
|
354
|
+
};
|
|
355
|
+
return mockResult(probe, responses[probe]);
|
|
356
|
+
};
|
|
357
|
+
const result = await handler({ vm_name: 'web-01' }, runProbe, defaultContext);
|
|
358
|
+
expect(calls[0]?.probe).toBe('nutanix.vms.list');
|
|
359
|
+
expect(calls[0]?.params?.name).toBe('web-01');
|
|
360
|
+
expect(result.findings.some((f) => f.severity === 'info')).toBe(true);
|
|
361
|
+
});
|
|
362
|
+
it('VM not found by name — critical', async () => {
|
|
363
|
+
const runProbe = createMockRunProbe({
|
|
364
|
+
'nutanix.vms.list': { data: { vms: [], totalCount: 0 } },
|
|
365
|
+
});
|
|
366
|
+
const result = await handler({ vm_name: 'nonexistent' }, runProbe, defaultContext);
|
|
367
|
+
expect(result.findings).toHaveLength(1);
|
|
368
|
+
expect(result.findings[0]?.severity).toBe('critical');
|
|
369
|
+
expect(result.findings[0]?.title).toContain('not found');
|
|
370
|
+
});
|
|
371
|
+
it('no VM specified — critical', async () => {
|
|
372
|
+
const runProbe = createMockRunProbe({});
|
|
373
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
374
|
+
expect(result.findings).toHaveLength(1);
|
|
375
|
+
expect(result.findings[0]?.severity).toBe('critical');
|
|
376
|
+
expect(result.findings[0]?.title).toContain('No VM specified');
|
|
377
|
+
});
|
|
378
|
+
it('VM powered off — warning', async () => {
|
|
379
|
+
const offVm = { ...healthyVmDetail, powerState: 'OFF' };
|
|
380
|
+
const runProbe = createMockRunProbe({
|
|
381
|
+
'nutanix.vm.detail': { data: offVm },
|
|
382
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
383
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
384
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
385
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
386
|
+
});
|
|
387
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
388
|
+
const warning = result.findings.find((f) => f.title.includes('powered off'));
|
|
389
|
+
expect(warning).toBeDefined();
|
|
390
|
+
expect(warning?.severity).toBe('warning');
|
|
391
|
+
});
|
|
392
|
+
it('high CPU — warning', async () => {
|
|
393
|
+
const highCpu = { ...healthyVmStats, cpuUsagePct: 92 };
|
|
394
|
+
const runProbe = createMockRunProbe({
|
|
395
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
396
|
+
'nutanix.vm.stats': { data: highCpu },
|
|
397
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
398
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
399
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
400
|
+
});
|
|
401
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
402
|
+
const warning = result.findings.find((f) => f.title.includes('CPU'));
|
|
403
|
+
expect(warning).toBeDefined();
|
|
404
|
+
expect(warning?.severity).toBe('warning');
|
|
405
|
+
expect(warning?.title).toContain('92%');
|
|
406
|
+
});
|
|
407
|
+
it('high memory — warning', async () => {
|
|
408
|
+
const highMem = { ...healthyVmStats, memoryUsagePct: 95 };
|
|
409
|
+
const runProbe = createMockRunProbe({
|
|
410
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
411
|
+
'nutanix.vm.stats': { data: highMem },
|
|
412
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
413
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
414
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
415
|
+
});
|
|
416
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
417
|
+
const warning = result.findings.find((f) => f.title.includes('memory'));
|
|
418
|
+
expect(warning).toBeDefined();
|
|
419
|
+
expect(warning?.severity).toBe('warning');
|
|
420
|
+
});
|
|
421
|
+
it('high I/O latency — warning', async () => {
|
|
422
|
+
const highLatency = { ...healthyVmStats, avgIoLatencyMs: 45 };
|
|
423
|
+
const runProbe = createMockRunProbe({
|
|
424
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
425
|
+
'nutanix.vm.stats': { data: highLatency },
|
|
426
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
427
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
428
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
429
|
+
});
|
|
430
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
431
|
+
const warning = result.findings.find((f) => f.title.includes('I/O latency'));
|
|
432
|
+
expect(warning).toBeDefined();
|
|
433
|
+
expect(warning?.severity).toBe('warning');
|
|
434
|
+
expect(warning?.title).toContain('45ms');
|
|
435
|
+
});
|
|
436
|
+
it('no data protection — warning with remediation', async () => {
|
|
437
|
+
const noProtection = { policies: [], totalCount: 0, vmCovered: false, allPoliciesCount: 3 };
|
|
438
|
+
const runProbe = createMockRunProbe({
|
|
439
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
440
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
441
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
442
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
443
|
+
'nutanix.protection.policies': { data: noProtection },
|
|
444
|
+
});
|
|
445
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
446
|
+
const warning = result.findings.find((f) => f.title.includes('no data protection'));
|
|
447
|
+
expect(warning).toBeDefined();
|
|
448
|
+
expect(warning?.severity).toBe('warning');
|
|
449
|
+
expect(warning?.remediation).toContain('protection policy');
|
|
450
|
+
});
|
|
451
|
+
it('old snapshots — info finding', async () => {
|
|
452
|
+
const oldSnaps = {
|
|
453
|
+
snapshots: [
|
|
454
|
+
{ name: 'old-snap', ageDays: 14, isOld: true, isExpired: false },
|
|
455
|
+
{ name: 'very-old-snap', ageDays: 30, isOld: true, isExpired: false },
|
|
456
|
+
],
|
|
457
|
+
totalCount: 2,
|
|
458
|
+
warnings: ['2 snapshot(s) older than 7 days'],
|
|
459
|
+
};
|
|
460
|
+
const runProbe = createMockRunProbe({
|
|
461
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
462
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
463
|
+
'nutanix.vm.snapshots': { data: oldSnaps },
|
|
464
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
465
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
466
|
+
});
|
|
467
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
468
|
+
const info = result.findings.find((f) => f.title.includes('older than 7 days'));
|
|
469
|
+
expect(info).toBeDefined();
|
|
470
|
+
expect(info?.severity).toBe('info');
|
|
471
|
+
});
|
|
472
|
+
it('expired snapshots — warning', async () => {
|
|
473
|
+
const expiredSnaps = {
|
|
474
|
+
snapshots: [{ name: 'expired-snap', ageDays: 10, isOld: true, isExpired: true }],
|
|
475
|
+
totalCount: 1,
|
|
476
|
+
warnings: [],
|
|
477
|
+
};
|
|
478
|
+
const runProbe = createMockRunProbe({
|
|
479
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
480
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
481
|
+
'nutanix.vm.snapshots': { data: expiredSnaps },
|
|
482
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
483
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
484
|
+
});
|
|
485
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
486
|
+
const warning = result.findings.find((f) => f.title.includes('expired'));
|
|
487
|
+
expect(warning).toBeDefined();
|
|
488
|
+
expect(warning?.severity).toBe('warning');
|
|
489
|
+
});
|
|
490
|
+
it('guest tools not installed — info', async () => {
|
|
491
|
+
const noGt = { ...healthyVmDetail, guestTools: { isEnabled: false } };
|
|
492
|
+
const runProbe = createMockRunProbe({
|
|
493
|
+
'nutanix.vm.detail': { data: noGt },
|
|
494
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
495
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
496
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
497
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
498
|
+
});
|
|
499
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
500
|
+
const info = result.findings.find((f) => f.title.includes('Guest tools'));
|
|
501
|
+
expect(info).toBeDefined();
|
|
502
|
+
expect(info?.severity).toBe('info');
|
|
503
|
+
});
|
|
504
|
+
it('VM-related alerts — reported as findings', async () => {
|
|
505
|
+
const vmAlerts = {
|
|
506
|
+
alerts: [
|
|
507
|
+
{
|
|
508
|
+
title: 'VM memory pressure',
|
|
509
|
+
severity: 'CRITICAL',
|
|
510
|
+
sourceEntity: { type: 'vm', name: 'web-01', extId: 'vm-001' },
|
|
511
|
+
creationTime: '2026-02-17T10:00:00Z',
|
|
512
|
+
},
|
|
513
|
+
],
|
|
514
|
+
totalCount: 1,
|
|
515
|
+
};
|
|
516
|
+
const runProbe = createMockRunProbe({
|
|
517
|
+
'nutanix.vm.detail': { data: healthyVmDetail },
|
|
518
|
+
'nutanix.vm.stats': { data: healthyVmStats },
|
|
519
|
+
'nutanix.vm.snapshots': { data: healthySnapshots },
|
|
520
|
+
'nutanix.alerts.list': { data: vmAlerts },
|
|
521
|
+
'nutanix.protection.policies': { data: healthyProtection },
|
|
522
|
+
});
|
|
523
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
524
|
+
const alert = result.findings.find((f) => f.title.includes('VM memory pressure'));
|
|
525
|
+
expect(alert).toBeDefined();
|
|
526
|
+
expect(alert?.severity).toBe('critical');
|
|
527
|
+
});
|
|
528
|
+
it('VM unreachable — critical with early return', async () => {
|
|
529
|
+
const runProbe = createMockRunProbe({
|
|
530
|
+
'nutanix.vm.detail': { status: 'error', error: 'Connection refused' },
|
|
531
|
+
'nutanix.vm.stats': { data: null },
|
|
532
|
+
'nutanix.vm.snapshots': { data: null },
|
|
533
|
+
'nutanix.alerts.list': { data: emptyAlerts },
|
|
534
|
+
'nutanix.protection.policies': { data: null },
|
|
535
|
+
});
|
|
536
|
+
const result = await handler({ vm_id: 'vm-001' }, runProbe, defaultContext);
|
|
537
|
+
expect(result.findings).toHaveLength(1);
|
|
538
|
+
expect(result.findings[0]?.severity).toBe('critical');
|
|
539
|
+
expect(result.findings[0]?.title).toContain('unreachable');
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
// =============================================================================
|
|
543
|
+
// nutanix-capacity-planning tests
|
|
544
|
+
// =============================================================================
|
|
545
|
+
describe('nutanix-capacity-planning', () => {
|
|
546
|
+
const handler = getHandler('nutanix-capacity-planning');
|
|
547
|
+
const healthyClusterStats = {
|
|
548
|
+
cpuCapacityHz: 1e12,
|
|
549
|
+
cpuUsedHz: 3e11,
|
|
550
|
+
cpuUsagePct: 30,
|
|
551
|
+
memoryCapacityBytes: 1e12,
|
|
552
|
+
memoryUsedBytes: 4e11,
|
|
553
|
+
memoryUsagePct: 40,
|
|
554
|
+
storageCapacityBytes: 5e12,
|
|
555
|
+
storageUsedBytes: 1.5e12,
|
|
556
|
+
storageUsagePct: 30,
|
|
557
|
+
iops: 5000,
|
|
558
|
+
avgIoLatencyMs: 3,
|
|
559
|
+
};
|
|
560
|
+
const healthyVmsList = {
|
|
561
|
+
vms: Array.from({ length: 10 }, (_, i) => ({
|
|
562
|
+
name: `vm-${i}`,
|
|
563
|
+
extId: `vm-${i}`,
|
|
564
|
+
powerState: 'ON',
|
|
565
|
+
})),
|
|
566
|
+
totalCount: 10,
|
|
567
|
+
};
|
|
568
|
+
it('healthy capacity — no issues', async () => {
|
|
569
|
+
const runProbe = async (probe, params) => {
|
|
570
|
+
if (probe === 'nutanix.clusters.list')
|
|
571
|
+
return mockResult(probe, {
|
|
572
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
573
|
+
});
|
|
574
|
+
if (probe === 'nutanix.cluster.stats')
|
|
575
|
+
return mockResult(probe, healthyClusterStats);
|
|
576
|
+
if (probe === 'nutanix.storage.containers')
|
|
577
|
+
return mockResult(probe, healthyStorage);
|
|
578
|
+
if (probe === 'nutanix.hosts.list')
|
|
579
|
+
return mockResult(probe, healthyHosts);
|
|
580
|
+
if (probe === 'nutanix.vms.list')
|
|
581
|
+
return mockResult(probe, healthyVmsList);
|
|
582
|
+
return mockResult(probe, undefined, 'error');
|
|
583
|
+
};
|
|
584
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
585
|
+
expect(result.category).toBe('nutanix-capacity-planning');
|
|
586
|
+
expect(result.findings).toHaveLength(1);
|
|
587
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
588
|
+
expect(result.findings[0]?.title).toContain('healthy thresholds');
|
|
589
|
+
});
|
|
590
|
+
it('high CPU utilization >80% — warning', async () => {
|
|
591
|
+
const highCpuStats = { ...healthyClusterStats, cpuUsagePct: 85 };
|
|
592
|
+
const runProbe = async (probe) => {
|
|
593
|
+
if (probe === 'nutanix.clusters.list')
|
|
594
|
+
return mockResult(probe, {
|
|
595
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
596
|
+
});
|
|
597
|
+
if (probe === 'nutanix.cluster.stats')
|
|
598
|
+
return mockResult(probe, highCpuStats);
|
|
599
|
+
if (probe === 'nutanix.storage.containers')
|
|
600
|
+
return mockResult(probe, healthyStorage);
|
|
601
|
+
if (probe === 'nutanix.hosts.list')
|
|
602
|
+
return mockResult(probe, healthyHosts);
|
|
603
|
+
if (probe === 'nutanix.vms.list')
|
|
604
|
+
return mockResult(probe, healthyVmsList);
|
|
605
|
+
return mockResult(probe, undefined, 'error');
|
|
606
|
+
};
|
|
607
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
608
|
+
const warning = result.findings.find((f) => f.title.includes('CPU'));
|
|
609
|
+
expect(warning).toBeDefined();
|
|
610
|
+
expect(warning?.severity).toBe('warning');
|
|
611
|
+
expect(warning?.title).toContain('85%');
|
|
612
|
+
});
|
|
613
|
+
it('critical CPU >90% — critical', async () => {
|
|
614
|
+
const criticalCpuStats = { ...healthyClusterStats, cpuUsagePct: 95 };
|
|
615
|
+
const runProbe = async (probe) => {
|
|
616
|
+
if (probe === 'nutanix.clusters.list')
|
|
617
|
+
return mockResult(probe, {
|
|
618
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
619
|
+
});
|
|
620
|
+
if (probe === 'nutanix.cluster.stats')
|
|
621
|
+
return mockResult(probe, criticalCpuStats);
|
|
622
|
+
if (probe === 'nutanix.storage.containers')
|
|
623
|
+
return mockResult(probe, healthyStorage);
|
|
624
|
+
if (probe === 'nutanix.hosts.list')
|
|
625
|
+
return mockResult(probe, healthyHosts);
|
|
626
|
+
if (probe === 'nutanix.vms.list')
|
|
627
|
+
return mockResult(probe, healthyVmsList);
|
|
628
|
+
return mockResult(probe, undefined, 'error');
|
|
629
|
+
};
|
|
630
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
631
|
+
const critical = result.findings.find((f) => f.title.includes('CPU'));
|
|
632
|
+
expect(critical).toBeDefined();
|
|
633
|
+
expect(critical?.severity).toBe('critical');
|
|
634
|
+
});
|
|
635
|
+
it('high memory >80% — warning', async () => {
|
|
636
|
+
const highMemStats = { ...healthyClusterStats, memoryUsagePct: 88 };
|
|
637
|
+
const runProbe = async (probe) => {
|
|
638
|
+
if (probe === 'nutanix.clusters.list')
|
|
639
|
+
return mockResult(probe, {
|
|
640
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
641
|
+
});
|
|
642
|
+
if (probe === 'nutanix.cluster.stats')
|
|
643
|
+
return mockResult(probe, highMemStats);
|
|
644
|
+
if (probe === 'nutanix.storage.containers')
|
|
645
|
+
return mockResult(probe, healthyStorage);
|
|
646
|
+
if (probe === 'nutanix.hosts.list')
|
|
647
|
+
return mockResult(probe, healthyHosts);
|
|
648
|
+
if (probe === 'nutanix.vms.list')
|
|
649
|
+
return mockResult(probe, healthyVmsList);
|
|
650
|
+
return mockResult(probe, undefined, 'error');
|
|
651
|
+
};
|
|
652
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
653
|
+
const warning = result.findings.find((f) => f.title.includes('memory'));
|
|
654
|
+
expect(warning).toBeDefined();
|
|
655
|
+
expect(warning?.severity).toBe('warning');
|
|
656
|
+
});
|
|
657
|
+
it('high storage >80% — warning', async () => {
|
|
658
|
+
const highStorageStats = { ...healthyClusterStats, storageUsagePct: 87 };
|
|
659
|
+
const runProbe = async (probe) => {
|
|
660
|
+
if (probe === 'nutanix.clusters.list')
|
|
661
|
+
return mockResult(probe, {
|
|
662
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
663
|
+
});
|
|
664
|
+
if (probe === 'nutanix.cluster.stats')
|
|
665
|
+
return mockResult(probe, highStorageStats);
|
|
666
|
+
if (probe === 'nutanix.storage.containers')
|
|
667
|
+
return mockResult(probe, healthyStorage);
|
|
668
|
+
if (probe === 'nutanix.hosts.list')
|
|
669
|
+
return mockResult(probe, healthyHosts);
|
|
670
|
+
if (probe === 'nutanix.vms.list')
|
|
671
|
+
return mockResult(probe, healthyVmsList);
|
|
672
|
+
return mockResult(probe, undefined, 'error');
|
|
673
|
+
};
|
|
674
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
675
|
+
const warning = result.findings.find((f) => f.title.includes('storage'));
|
|
676
|
+
expect(warning).toBeDefined();
|
|
677
|
+
expect(warning?.severity).toBe('warning');
|
|
678
|
+
});
|
|
679
|
+
it('high VM density >30/host — warning', async () => {
|
|
680
|
+
const singleHost = { hosts: [{ name: 'host-01', extId: 'h-001' }], totalCount: 1 };
|
|
681
|
+
const manyVms = {
|
|
682
|
+
vms: Array.from({ length: 35 }, (_, i) => ({ name: `vm-${i}` })),
|
|
683
|
+
totalCount: 35,
|
|
684
|
+
};
|
|
685
|
+
const runProbe = async (probe) => {
|
|
686
|
+
if (probe === 'nutanix.clusters.list')
|
|
687
|
+
return mockResult(probe, {
|
|
688
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
689
|
+
});
|
|
690
|
+
if (probe === 'nutanix.cluster.stats')
|
|
691
|
+
return mockResult(probe, healthyClusterStats);
|
|
692
|
+
if (probe === 'nutanix.storage.containers')
|
|
693
|
+
return mockResult(probe, healthyStorage);
|
|
694
|
+
if (probe === 'nutanix.hosts.list')
|
|
695
|
+
return mockResult(probe, singleHost);
|
|
696
|
+
if (probe === 'nutanix.vms.list')
|
|
697
|
+
return mockResult(probe, manyVms);
|
|
698
|
+
return mockResult(probe, undefined, 'error');
|
|
699
|
+
};
|
|
700
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
701
|
+
const warning = result.findings.find((f) => f.title.includes('VM density'));
|
|
702
|
+
expect(warning).toBeDefined();
|
|
703
|
+
expect(warning?.severity).toBe('warning');
|
|
704
|
+
expect(warning?.detail).toContain('35');
|
|
705
|
+
});
|
|
706
|
+
it('no clusters — critical with early return', async () => {
|
|
707
|
+
const runProbe = createMockRunProbe({
|
|
708
|
+
'nutanix.clusters.list': { status: 'error', error: 'Connection refused' },
|
|
709
|
+
});
|
|
710
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
711
|
+
expect(result.findings).toHaveLength(1);
|
|
712
|
+
expect(result.findings[0]?.severity).toBe('critical');
|
|
713
|
+
expect(result.findings[0]?.title).toContain('No clusters');
|
|
714
|
+
});
|
|
715
|
+
it('per-container >85% — warning', async () => {
|
|
716
|
+
const fullContainers = {
|
|
717
|
+
containers: [{ name: 'hot-container', usedPct: 91, highUsage: true }],
|
|
718
|
+
totalCount: 1,
|
|
719
|
+
};
|
|
720
|
+
const runProbe = async (probe) => {
|
|
721
|
+
if (probe === 'nutanix.clusters.list')
|
|
722
|
+
return mockResult(probe, {
|
|
723
|
+
clusters: [{ name: 'prod', extId: 'c-001', isDegraded: false }],
|
|
724
|
+
});
|
|
725
|
+
if (probe === 'nutanix.cluster.stats')
|
|
726
|
+
return mockResult(probe, healthyClusterStats);
|
|
727
|
+
if (probe === 'nutanix.storage.containers')
|
|
728
|
+
return mockResult(probe, fullContainers);
|
|
729
|
+
if (probe === 'nutanix.hosts.list')
|
|
730
|
+
return mockResult(probe, healthyHosts);
|
|
731
|
+
if (probe === 'nutanix.vms.list')
|
|
732
|
+
return mockResult(probe, healthyVmsList);
|
|
733
|
+
return mockResult(probe, undefined, 'error');
|
|
734
|
+
};
|
|
735
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
736
|
+
const warning = result.findings.find((f) => f.title.includes('hot-container'));
|
|
737
|
+
expect(warning).toBeDefined();
|
|
738
|
+
expect(warning?.severity).toBe('warning');
|
|
739
|
+
});
|
|
740
|
+
it('multi-cluster — probes run per cluster', async () => {
|
|
741
|
+
const calls = [];
|
|
742
|
+
const runProbe = async (probe, params) => {
|
|
743
|
+
calls.push(probe);
|
|
744
|
+
if (probe === 'nutanix.clusters.list') {
|
|
745
|
+
return mockResult(probe, {
|
|
746
|
+
clusters: [
|
|
747
|
+
{ name: 'dc1', extId: 'c-001', isDegraded: false },
|
|
748
|
+
{ name: 'dc2', extId: 'c-002', isDegraded: false },
|
|
749
|
+
],
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
if (probe === 'nutanix.cluster.stats')
|
|
753
|
+
return mockResult(probe, healthyClusterStats);
|
|
754
|
+
if (probe === 'nutanix.storage.containers')
|
|
755
|
+
return mockResult(probe, healthyStorage);
|
|
756
|
+
if (probe === 'nutanix.hosts.list')
|
|
757
|
+
return mockResult(probe, healthyHosts);
|
|
758
|
+
if (probe === 'nutanix.vms.list')
|
|
759
|
+
return mockResult(probe, healthyVmsList);
|
|
760
|
+
return mockResult(probe, undefined, 'error');
|
|
761
|
+
};
|
|
762
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
763
|
+
// Should have 2x cluster.stats calls (one per cluster)
|
|
764
|
+
expect(calls.filter((c) => c === 'nutanix.cluster.stats')).toHaveLength(2);
|
|
765
|
+
expect(result.summary.summaryText).toContain('2 cluster(s)');
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
// =============================================================================
|
|
769
|
+
// nutanix-storefront-investigate tests
|
|
770
|
+
// =============================================================================
|
|
771
|
+
describe('nutanix-storefront-investigate', () => {
|
|
772
|
+
const handler = getHandler('nutanix-storefront-investigate');
|
|
773
|
+
it('healthy tagged VMs — no issues', async () => {
|
|
774
|
+
const entities = {
|
|
775
|
+
entities: [
|
|
776
|
+
{ entityType: 'vm', entityId: 'vm-001', entityName: 'storefront-01' },
|
|
777
|
+
{ entityType: 'vm', entityId: 'vm-002', entityName: 'storefront-02' },
|
|
778
|
+
],
|
|
779
|
+
totalCount: 2,
|
|
780
|
+
};
|
|
781
|
+
const runProbe = async (probe, params) => {
|
|
782
|
+
if (probe === 'nutanix.categories.entities')
|
|
783
|
+
return mockResult(probe, entities);
|
|
784
|
+
if (probe === 'nutanix.vm.detail')
|
|
785
|
+
return mockResult(probe, {
|
|
786
|
+
...healthyVmDetail,
|
|
787
|
+
name: params?.vm_id === 'vm-001' ? 'storefront-01' : 'storefront-02',
|
|
788
|
+
});
|
|
789
|
+
if (probe === 'nutanix.vm.stats')
|
|
790
|
+
return mockResult(probe, healthyVmStats);
|
|
791
|
+
if (probe === 'nutanix.alerts.list')
|
|
792
|
+
return mockResult(probe, emptyAlerts);
|
|
793
|
+
return mockResult(probe, undefined, 'error');
|
|
794
|
+
};
|
|
795
|
+
const result = await handler({ category_key: 'Environment', category_value: 'Storefront' }, runProbe, defaultContext);
|
|
796
|
+
expect(result.category).toBe('nutanix-storefront-investigate');
|
|
797
|
+
expect(result.findings).toHaveLength(1);
|
|
798
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
799
|
+
expect(result.findings[0]?.title).toContain('healthy');
|
|
800
|
+
});
|
|
801
|
+
it('missing category params — critical', async () => {
|
|
802
|
+
const runProbe = createMockRunProbe({});
|
|
803
|
+
const result = await handler({}, runProbe, defaultContext);
|
|
804
|
+
expect(result.findings).toHaveLength(1);
|
|
805
|
+
expect(result.findings[0]?.severity).toBe('critical');
|
|
806
|
+
expect(result.findings[0]?.title).toContain('Missing category');
|
|
807
|
+
});
|
|
808
|
+
it('no entities found — info', async () => {
|
|
809
|
+
const runProbe = createMockRunProbe({
|
|
810
|
+
'nutanix.categories.entities': { data: { entities: [], totalCount: 0 } },
|
|
811
|
+
});
|
|
812
|
+
const result = await handler({ category_key: 'App', category_value: 'None' }, runProbe, defaultContext);
|
|
813
|
+
expect(result.findings).toHaveLength(1);
|
|
814
|
+
expect(result.findings[0]?.severity).toBe('info');
|
|
815
|
+
expect(result.findings[0]?.title).toContain('No entities');
|
|
816
|
+
});
|
|
817
|
+
it('non-VM entities only — info', async () => {
|
|
818
|
+
const entities = {
|
|
819
|
+
entities: [{ entityType: 'host', entityId: 'h-001', entityName: 'host-01' }],
|
|
820
|
+
totalCount: 1,
|
|
821
|
+
};
|
|
822
|
+
const runProbe = createMockRunProbe({
|
|
823
|
+
'nutanix.categories.entities': { data: entities },
|
|
824
|
+
});
|
|
825
|
+
const result = await handler({ category_key: 'Tier', category_value: 'Gold' }, runProbe, defaultContext);
|
|
826
|
+
expect(result.findings).toHaveLength(1);
|
|
827
|
+
expect(result.findings[0]?.title).toContain('no VMs');
|
|
828
|
+
});
|
|
829
|
+
it('powered off VMs — warning per VM', async () => {
|
|
830
|
+
const entities = {
|
|
831
|
+
entities: [
|
|
832
|
+
{ entityType: 'vm', entityId: 'vm-001', entityName: 'store-01' },
|
|
833
|
+
{ entityType: 'vm', entityId: 'vm-002', entityName: 'store-02' },
|
|
834
|
+
],
|
|
835
|
+
totalCount: 2,
|
|
836
|
+
};
|
|
837
|
+
const offVm = { ...healthyVmDetail, powerState: 'OFF' };
|
|
838
|
+
const runProbe = async (probe) => {
|
|
839
|
+
if (probe === 'nutanix.categories.entities')
|
|
840
|
+
return mockResult(probe, entities);
|
|
841
|
+
if (probe === 'nutanix.vm.detail')
|
|
842
|
+
return mockResult(probe, offVm);
|
|
843
|
+
if (probe === 'nutanix.vm.stats')
|
|
844
|
+
return mockResult(probe, healthyVmStats);
|
|
845
|
+
if (probe === 'nutanix.alerts.list')
|
|
846
|
+
return mockResult(probe, emptyAlerts);
|
|
847
|
+
return mockResult(probe, undefined, 'error');
|
|
848
|
+
};
|
|
849
|
+
const result = await handler({ category_key: 'App', category_value: 'Store' }, runProbe, defaultContext);
|
|
850
|
+
const perVmOff = result.findings.filter((f) => f.severity === 'warning' && f.title.includes('powered off'));
|
|
851
|
+
expect(perVmOff).toHaveLength(2);
|
|
852
|
+
// Also should have "all VMs powered off" critical finding
|
|
853
|
+
const allOff = result.findings.find((f) => f.severity === 'critical' && f.title.includes('powered off'));
|
|
854
|
+
expect(allOff).toBeDefined();
|
|
855
|
+
});
|
|
856
|
+
it('high CPU on tagged VMs — warning', async () => {
|
|
857
|
+
const entities = {
|
|
858
|
+
entities: [{ entityType: 'vm', entityId: 'vm-001', entityName: 'store-01' }],
|
|
859
|
+
totalCount: 1,
|
|
860
|
+
};
|
|
861
|
+
const highCpuStats = { ...healthyVmStats, cpuUsagePct: 92 };
|
|
862
|
+
const runProbe = async (probe) => {
|
|
863
|
+
if (probe === 'nutanix.categories.entities')
|
|
864
|
+
return mockResult(probe, entities);
|
|
865
|
+
if (probe === 'nutanix.vm.detail')
|
|
866
|
+
return mockResult(probe, healthyVmDetail);
|
|
867
|
+
if (probe === 'nutanix.vm.stats')
|
|
868
|
+
return mockResult(probe, highCpuStats);
|
|
869
|
+
if (probe === 'nutanix.alerts.list')
|
|
870
|
+
return mockResult(probe, emptyAlerts);
|
|
871
|
+
return mockResult(probe, undefined, 'error');
|
|
872
|
+
};
|
|
873
|
+
const result = await handler({ category_key: 'App', category_value: 'Store' }, runProbe, defaultContext);
|
|
874
|
+
const warning = result.findings.find((f) => f.title.includes('CPU'));
|
|
875
|
+
expect(warning).toBeDefined();
|
|
876
|
+
expect(warning?.severity).toBe('warning');
|
|
877
|
+
});
|
|
878
|
+
it('critical alerts on tagged VMs — critical', async () => {
|
|
879
|
+
const entities = {
|
|
880
|
+
entities: [{ entityType: 'vm', entityId: 'vm-001', entityName: 'web-01' }],
|
|
881
|
+
totalCount: 1,
|
|
882
|
+
};
|
|
883
|
+
const vmAlerts = {
|
|
884
|
+
alerts: [
|
|
885
|
+
{
|
|
886
|
+
title: 'Disk failure',
|
|
887
|
+
severity: 'CRITICAL',
|
|
888
|
+
sourceEntity: { type: 'vm', name: 'web-01', extId: 'vm-001' },
|
|
889
|
+
creationTime: '2026-02-17T10:00:00Z',
|
|
890
|
+
},
|
|
891
|
+
],
|
|
892
|
+
totalCount: 1,
|
|
893
|
+
};
|
|
894
|
+
const runProbe = async (probe) => {
|
|
895
|
+
if (probe === 'nutanix.categories.entities')
|
|
896
|
+
return mockResult(probe, entities);
|
|
897
|
+
if (probe === 'nutanix.vm.detail')
|
|
898
|
+
return mockResult(probe, healthyVmDetail);
|
|
899
|
+
if (probe === 'nutanix.vm.stats')
|
|
900
|
+
return mockResult(probe, healthyVmStats);
|
|
901
|
+
if (probe === 'nutanix.alerts.list')
|
|
902
|
+
return mockResult(probe, vmAlerts);
|
|
903
|
+
return mockResult(probe, undefined, 'error');
|
|
904
|
+
};
|
|
905
|
+
const result = await handler({ category_key: 'Environment', category_value: 'Storefront' }, runProbe, defaultContext);
|
|
906
|
+
const critical = result.findings.find((f) => f.title.includes('Disk failure'));
|
|
907
|
+
expect(critical).toBeDefined();
|
|
908
|
+
expect(critical?.severity).toBe('critical');
|
|
909
|
+
});
|
|
910
|
+
it('limits VM checks to 10', async () => {
|
|
911
|
+
const entities = {
|
|
912
|
+
entities: Array.from({ length: 15 }, (_, i) => ({
|
|
913
|
+
entityType: 'vm',
|
|
914
|
+
entityId: `vm-${i}`,
|
|
915
|
+
entityName: `store-${i}`,
|
|
916
|
+
})),
|
|
917
|
+
totalCount: 15,
|
|
918
|
+
};
|
|
919
|
+
const vmDetailCalls = [];
|
|
920
|
+
const runProbe = async (probe, params) => {
|
|
921
|
+
if (probe === 'nutanix.categories.entities')
|
|
922
|
+
return mockResult(probe, entities);
|
|
923
|
+
if (probe === 'nutanix.vm.detail') {
|
|
924
|
+
vmDetailCalls.push(params?.vm_id);
|
|
925
|
+
return mockResult(probe, healthyVmDetail);
|
|
926
|
+
}
|
|
927
|
+
if (probe === 'nutanix.vm.stats')
|
|
928
|
+
return mockResult(probe, healthyVmStats);
|
|
929
|
+
if (probe === 'nutanix.alerts.list')
|
|
930
|
+
return mockResult(probe, emptyAlerts);
|
|
931
|
+
return mockResult(probe, undefined, 'error');
|
|
932
|
+
};
|
|
933
|
+
await handler({ category_key: 'App', category_value: 'Store' }, runProbe, defaultContext);
|
|
934
|
+
// Should only check first 10 VMs
|
|
935
|
+
expect(vmDetailCalls).toHaveLength(10);
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
// =============================================================================
|
|
939
|
+
// Definitions
|
|
940
|
+
// =============================================================================
|
|
941
|
+
describe('nutanixDiagnosticRunbooks definitions', () => {
|
|
942
|
+
it('exports 4 runbook definitions', () => {
|
|
943
|
+
expect(nutanixDiagnosticRunbooks).toHaveLength(4);
|
|
944
|
+
});
|
|
945
|
+
it('has correct categories', () => {
|
|
946
|
+
const categories = nutanixDiagnosticRunbooks.map((r) => r.category);
|
|
947
|
+
expect(categories).toContain('nutanix-cluster-health');
|
|
948
|
+
expect(categories).toContain('nutanix-vm-health');
|
|
949
|
+
expect(categories).toContain('nutanix-capacity-planning');
|
|
950
|
+
expect(categories).toContain('nutanix-storefront-investigate');
|
|
951
|
+
});
|
|
952
|
+
it('nutanix-vm-health has vm_id and vm_name params', () => {
|
|
953
|
+
const def = nutanixDiagnosticRunbooks.find((r) => r.category === 'nutanix-vm-health');
|
|
954
|
+
expect(def?.params?.vm_id).toBeDefined();
|
|
955
|
+
expect(def?.params?.vm_name).toBeDefined();
|
|
956
|
+
});
|
|
957
|
+
it('nutanix-storefront-investigate requires category_key and category_value', () => {
|
|
958
|
+
const def = nutanixDiagnosticRunbooks.find((r) => r.category === 'nutanix-storefront-investigate');
|
|
959
|
+
expect(def?.params?.category_key?.required).toBe(true);
|
|
960
|
+
expect(def?.params?.category_value?.required).toBe(true);
|
|
961
|
+
});
|
|
962
|
+
it('nutanix-cluster-health has no required params', () => {
|
|
963
|
+
const def = nutanixDiagnosticRunbooks.find((r) => r.category === 'nutanix-cluster-health');
|
|
964
|
+
expect(def?.params).toBeUndefined();
|
|
965
|
+
});
|
|
966
|
+
it('nutanix-capacity-planning has no required params', () => {
|
|
967
|
+
const def = nutanixDiagnosticRunbooks.find((r) => r.category === 'nutanix-capacity-planning');
|
|
968
|
+
expect(def?.params).toBeUndefined();
|
|
969
|
+
});
|
|
970
|
+
});
|
|
971
|
+
//# sourceMappingURL=nutanix.test.js.map
|