Org default worker profile (operator-set via the admin API): when the client sends no sizing GUCs, the org default produces a concrete profile; partially set org defaults fall back per-field to the pool-global/built-in defaults; client GUCs override per-field; an org default never errors.
(t *testing.T)
| 178 | // set org defaults fall back per-field to the pool-global/built-in defaults; |
| 179 | // client GUCs override per-field; an org default never errors. |
| 180 | func TestResolveWorkerProfileOrgDefaults(t *testing.T) { |
| 181 | tests := []struct { |
| 182 | name string |
| 183 | opts map[string]string |
| 184 | org orgWorkerProfileDefaults |
| 185 | wantNil bool |
| 186 | wantKey string |
| 187 | wantTTL time.Duration |
| 188 | wantOrgApplied bool |
| 189 | wantWarn string // substring expected in a warning, "" = no warnings expected |
| 190 | }{ |
| 191 | { |
| 192 | name: "org default all three fields", |
| 193 | opts: map[string]string{}, |
| 194 | org: orgWorkerProfileDefaults{CPU: "2", Memory: "8Gi", TTL: "10m"}, |
| 195 | wantKey: "2|8Gi", |
| 196 | wantTTL: 10 * time.Minute, |
| 197 | wantOrgApplied: true, |
| 198 | }, |
| 199 | { |
| 200 | name: "org cpu only -> mem/ttl fall back to pool-global/built-in", |
| 201 | opts: map[string]string{}, |
| 202 | org: orgWorkerProfileDefaults{CPU: "2"}, |
| 203 | wantKey: "2|16Gi", |
| 204 | wantTTL: defaultWorkerTTL, |
| 205 | wantOrgApplied: true, |
| 206 | }, |
| 207 | { |
| 208 | name: "org ttl only -> size falls back to pool-global", |
| 209 | opts: map[string]string{}, |
| 210 | org: orgWorkerProfileDefaults{TTL: "45m"}, |
| 211 | wantKey: "8|16Gi", |
| 212 | wantTTL: 45 * time.Minute, |
| 213 | wantOrgApplied: true, |
| 214 | }, |
| 215 | { |
| 216 | name: "org default normalized (4000m -> 4)", |
| 217 | opts: map[string]string{}, |
| 218 | org: orgWorkerProfileDefaults{CPU: "4000m", Memory: "8192Mi"}, |
| 219 | wantKey: "4|8Gi", |
| 220 | wantTTL: defaultWorkerTTL, |
| 221 | wantOrgApplied: true, |
| 222 | }, |
| 223 | { |
| 224 | name: "org default NOT clamped to WorkerProfileMax (operator config)", |
| 225 | opts: map[string]string{}, |
| 226 | // Above the client clamp band (max cpu 16 / max mem 64Gi). |
| 227 | org: orgWorkerProfileDefaults{CPU: "46", Memory: "360Gi"}, |
| 228 | wantKey: "46|360Gi", |
| 229 | wantTTL: defaultWorkerTTL, |
| 230 | wantOrgApplied: true, |
| 231 | }, |
| 232 | { |
| 233 | name: "org ttl clamped by WorkerMaxTTL", |
| 234 | opts: map[string]string{}, |
| 235 | org: orgWorkerProfileDefaults{TTL: "24h"}, |
| 236 | wantKey: "8|16Gi", |
| 237 | wantTTL: time.Hour, // WorkerMaxTTL in newSizingTestCP |
nothing calls this directly
no test coverage detected