|
| 1 | +# Test: per-app and per-volume metrics detail |
| 2 | +# |
| 3 | +# Deploys an app with an attached volume, waits for it to run, then verifies |
| 4 | +# that zedagent publishes non-trivial per-app and per-volume metrics. |
| 5 | +# |
| 6 | +# Covers: handleDiskMetricCreate/Modify/Impl/Delete (DiskMetric from volumemgr), |
| 7 | +# handleAppDiskMetricCreate/lookupAppDiskMetric (AppDiskMetric), |
| 8 | +# createVolumeInstanceMetrics, getVolumeResourcesMetrics, |
| 9 | +# fillStorageDiskMetrics, fillStorageChildrenMetrics, |
| 10 | +# PublishAppInfoToZedCloud, addUserSwInfo, |
| 11 | +# PublishVolumeToZedCloud, PublishContentInfoToZedCloud. |
| 12 | + |
| 13 | +{{$info := "test eden.zedagent.test -test.v -test.run TestInfo"}} |
| 14 | +{{$metric := "test eden.zedagent.test -test.v -test.run TestMetric"}} |
| 15 | +{{$app := "test eden.app.test -test.v"}} |
| 16 | + |
| 17 | +! test eden.reboot.test -test.v -timewait=45m -reboot=0 -count=1 & |
| 18 | + |
| 19 | +# Pre-cleanup: remove stale pod from a previous failed run and wait for EVE to confirm gone. |
| 20 | +exec sh -c 'EDEN_HOME=$EDEN_HOME eden pod delete zagent-vm-t1 2>/dev/null || true' |
| 21 | +test eden.app.test -test.v -timewait 5m - zagent-vm-t1 |
| 22 | + |
| 23 | +# Deploy an app with a volume so disk metrics are generated. |
| 24 | +# --volume-size causes volumemgr to create a persistent volume and publish DiskMetric. |
| 25 | +eden -t 1m pod deploy --memory 256MB --volume-size=100MB -n zagent-vm-t1 docker://nginx |
| 26 | +stdout 'deploy pod zagent-vm-t1' |
| 27 | +{{$app}} -timewait 20m RUNNING zagent-vm-t1 |
| 28 | + |
| 29 | +# --- app info (PublishAppInfoToZedCloud / addUserSwInfo) --- |
| 30 | +# ZInfoApp for our app must be present with a non-empty appID. |
| 31 | +eden eve epoch & |
| 32 | +{{$info}} -timewait 5m 'InfoContent.ainfo.appID:.+' |
| 33 | +stdout 'AppID' |
| 34 | + |
| 35 | +# --- per-app metrics (DiskMetric -> handleDiskMetricImpl -> publishMetrics) --- |
| 36 | +# ZMetricMsg.am contains per-app-instance metrics; cpu.total should be > 0. |
| 37 | +{{$metric}} -timewait 5m 'am.AppID:.+' |
| 38 | +stdout 'cpu' |
| 39 | + |
| 40 | +# --- disk metrics (handleDiskMetricImpl) --- |
| 41 | +# Global disk metric must show at least one disk path. |
| 42 | +{{$metric}} -timewait 5m 'MetricContent.dm.disk.mountPath:.+' |
| 43 | +stdout 'disk' |
| 44 | + |
| 45 | +# --- cleanup --- |
| 46 | +eden -t 1m pod delete zagent-vm-t1 |
| 47 | +stdout 'app zagent-vm-t1 delete done' |
| 48 | +{{$app}} -timewait 10m - zagent-vm-t1 |
| 49 | +stdout 'no app with zagent-vm-t1 found' |
| 50 | + |
| 51 | +exec sh kill_watchdog.sh |
| 52 | +wait |
| 53 | + |
| 54 | +# Test's config. file |
| 55 | +-- eden-config.yml -- |
| 56 | +test: |
| 57 | + controller: adam://{{EdenConfig "adam.ip"}}:{{EdenConfig "adam.port"}} |
| 58 | + eve: |
| 59 | + {{EdenConfig "eve.name"}}: |
| 60 | + onboard-cert: {{EdenConfigPath "eve.cert"}} |
| 61 | + serial: "{{EdenConfig "eve.serial"}}" |
| 62 | + model: {{EdenConfig "eve.devmodel"}} |
| 63 | + |
| 64 | +-- kill_watchdog.sh -- |
| 65 | +pkill -f "eden.reboot.test" || true |
0 commit comments