|
| 1 | +suite: test GPU metrics scrape job configuration |
| 2 | +templates: |
| 3 | + - agent-cm.yaml |
| 4 | +tests: |
| 5 | + # Test that GPU scrape job is included when GPU metrics are enabled |
| 6 | + |
| 7 | + - it: should include DCGM GPU scrape job when GPU metrics enabled |
| 8 | + template: agent-cm.yaml |
| 9 | + set: |
| 10 | + apiKey: "test-key" |
| 11 | + existingSecretName: null |
| 12 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 13 | + prometheusConfig.scrapeJobs.gpu.scrapeInterval: 30s |
| 14 | + asserts: |
| 15 | + - matchRegex: |
| 16 | + path: data["prometheus.yml"] |
| 17 | + pattern: "job_name: cloudzero-dcgm-exporter" |
| 18 | + |
| 19 | + # Test that GPU scrape job is NOT included when GPU metrics are disabled |
| 20 | + |
| 21 | + - it: should NOT include GPU scrape job when GPU metrics disabled |
| 22 | + template: agent-cm.yaml |
| 23 | + set: |
| 24 | + apiKey: "test-key" |
| 25 | + existingSecretName: null |
| 26 | + prometheusConfig.scrapeJobs.gpu.enabled: false |
| 27 | + asserts: |
| 28 | + - notMatchRegex: |
| 29 | + path: data["prometheus.yml"] |
| 30 | + pattern: "cloudzero-dcgm-exporter" |
| 31 | + |
| 32 | + # Test that custom scrape interval is applied correctly |
| 33 | + |
| 34 | + - it: should use custom GPU scrape interval of 45s when specified |
| 35 | + template: agent-cm.yaml |
| 36 | + set: |
| 37 | + apiKey: "test-key" |
| 38 | + existingSecretName: null |
| 39 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 40 | + prometheusConfig.scrapeJobs.gpu.scrapeInterval: 45s |
| 41 | + asserts: |
| 42 | + - matchRegex: |
| 43 | + path: data["prometheus.yml"] |
| 44 | + pattern: "job_name: cloudzero-dcgm-exporter" |
| 45 | + - matchRegex: |
| 46 | + path: data["prometheus.yml"] |
| 47 | + pattern: "scrape_interval: 45s" |
| 48 | + |
| 49 | + # Test that DCGM label selector is present |
| 50 | + |
| 51 | + - it: should include DCGM label selector for service discovery |
| 52 | + template: agent-cm.yaml |
| 53 | + set: |
| 54 | + apiKey: "test-key" |
| 55 | + existingSecretName: null |
| 56 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 57 | + asserts: |
| 58 | + - matchRegex: |
| 59 | + path: data["prometheus.yml"] |
| 60 | + pattern: "app.kubernetes.io/name=dcgm-exporter" |
| 61 | + |
| 62 | + # Test that provenance label is added |
| 63 | + |
| 64 | + - it: should add provenance=dcgm label to GPU metrics |
| 65 | + template: agent-cm.yaml |
| 66 | + set: |
| 67 | + apiKey: "test-key" |
| 68 | + existingSecretName: null |
| 69 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 70 | + asserts: |
| 71 | + - matchRegex: |
| 72 | + path: data["prometheus.yml"] |
| 73 | + pattern: "replacement: dcgm" |
| 74 | + - matchRegex: |
| 75 | + path: data["prometheus.yml"] |
| 76 | + pattern: "target_label: provenance" |
| 77 | + |
| 78 | + # Test that metric renaming is configured |
| 79 | + |
| 80 | + - it: should include metric renaming for cz_gpu_usage_percent |
| 81 | + template: agent-cm.yaml |
| 82 | + set: |
| 83 | + apiKey: "test-key" |
| 84 | + existingSecretName: null |
| 85 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 86 | + asserts: |
| 87 | + - matchRegex: |
| 88 | + path: data["prometheus.yml"] |
| 89 | + pattern: "DCGM_FI_DEV_GPU_UTIL" |
| 90 | + - matchRegex: |
| 91 | + path: data["prometheus.yml"] |
| 92 | + pattern: "cz_gpu_usage_percent" |
| 93 | + |
| 94 | + - it: should include metric renaming for cz_gpu_memory_used_bytes |
| 95 | + template: agent-cm.yaml |
| 96 | + set: |
| 97 | + apiKey: "test-key" |
| 98 | + existingSecretName: null |
| 99 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 100 | + asserts: |
| 101 | + - matchRegex: |
| 102 | + path: data["prometheus.yml"] |
| 103 | + pattern: "DCGM_FI_DEV_FB_USED" |
| 104 | + - matchRegex: |
| 105 | + path: data["prometheus.yml"] |
| 106 | + pattern: "cz_gpu_memory_used_bytes" |
| 107 | + |
| 108 | + - it: should include metric renaming for cz_gpu_memory_free_bytes |
| 109 | + template: agent-cm.yaml |
| 110 | + set: |
| 111 | + apiKey: "test-key" |
| 112 | + existingSecretName: null |
| 113 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 114 | + asserts: |
| 115 | + - matchRegex: |
| 116 | + path: data["prometheus.yml"] |
| 117 | + pattern: "DCGM_FI_DEV_FB_FREE" |
| 118 | + - matchRegex: |
| 119 | + path: data["prometheus.yml"] |
| 120 | + pattern: "cz_gpu_memory_free_bytes" |
| 121 | + |
| 122 | + # Test that GPU metrics are in remote_write allow list |
| 123 | + |
| 124 | + - it: should include GPU metrics in remote_write filter |
| 125 | + template: agent-cm.yaml |
| 126 | + set: |
| 127 | + apiKey: "test-key" |
| 128 | + existingSecretName: null |
| 129 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 130 | + asserts: |
| 131 | + - matchRegex: |
| 132 | + path: data["prometheus.yml"] |
| 133 | + pattern: "cz_gpu_usage_percent" |
| 134 | + - matchRegex: |
| 135 | + path: data["prometheus.yml"] |
| 136 | + pattern: "cz_gpu_memory_used_bytes" |
| 137 | + - matchRegex: |
| 138 | + path: data["prometheus.yml"] |
| 139 | + pattern: "cz_gpu_memory_free_bytes" |
| 140 | + |
| 141 | + # Test that unattributed metrics are dropped |
| 142 | + |
| 143 | + - it: should drop metrics without container attribution |
| 144 | + template: agent-cm.yaml |
| 145 | + set: |
| 146 | + apiKey: "test-key" |
| 147 | + existingSecretName: null |
| 148 | + prometheusConfig.scrapeJobs.gpu.enabled: true |
| 149 | + asserts: |
| 150 | + - matchRegex: |
| 151 | + path: data["prometheus.yml"] |
| 152 | + pattern: "source_labels: \\[container\\]" |
| 153 | + - matchRegex: |
| 154 | + path: data["prometheus.yml"] |
| 155 | + pattern: "action: drop" |
0 commit comments