|
| 1 | +suite: test pod disruption budget |
| 2 | +templates: |
| 3 | + - pdb.yaml |
| 4 | +tests: |
| 5 | + - it: should not render pdb by default |
| 6 | + asserts: |
| 7 | + - hasDocuments: |
| 8 | + count: 0 |
| 9 | + |
| 10 | + - it: should render default maxUnavailable of 1 when enabled with multiple replicas |
| 11 | + set: |
| 12 | + replicaCount: 2 |
| 13 | + podDisruptionBudget: |
| 14 | + enabled: true |
| 15 | + asserts: |
| 16 | + - isKind: |
| 17 | + of: PodDisruptionBudget |
| 18 | + - equal: |
| 19 | + path: metadata.name |
| 20 | + value: RELEASE-NAME |
| 21 | + - equal: |
| 22 | + path: spec.maxUnavailable |
| 23 | + value: 1 |
| 24 | + - notExists: |
| 25 | + path: spec.minAvailable |
| 26 | + - notExists: |
| 27 | + path: spec.unhealthyPodEvictionPolicy |
| 28 | + - equal: |
| 29 | + path: spec.selector.matchLabels |
| 30 | + value: |
| 31 | + app.kubernetes.io/name: RELEASE-NAME |
| 32 | + app.kubernetes.io/instance: RELEASE-NAME |
| 33 | + |
| 34 | + - it: should not render pdb with a single replica |
| 35 | + set: |
| 36 | + replicaCount: 1 |
| 37 | + podDisruptionBudget: |
| 38 | + enabled: true |
| 39 | + asserts: |
| 40 | + - hasDocuments: |
| 41 | + count: 0 |
| 42 | + |
| 43 | + - it: should still validate pdb settings with a single replica |
| 44 | + set: |
| 45 | + replicaCount: 1 |
| 46 | + podDisruptionBudget: |
| 47 | + enabled: true |
| 48 | + minAvailable: 1 |
| 49 | + asserts: |
| 50 | + - failedTemplate: |
| 51 | + errorMessage: "podDisruptionBudget: minAvailable and maxUnavailable are mutually exclusive. Set exactly one (to use minAvailable, set podDisruptionBudget.maxUnavailable=null)." |
| 52 | + |
| 53 | + - it: should render minAvailable when maxUnavailable is nulled |
| 54 | + set: |
| 55 | + replicaCount: 3 |
| 56 | + podDisruptionBudget: |
| 57 | + enabled: true |
| 58 | + minAvailable: "50%" |
| 59 | + maxUnavailable: null |
| 60 | + asserts: |
| 61 | + - equal: |
| 62 | + path: spec.minAvailable |
| 63 | + value: "50%" |
| 64 | + - notExists: |
| 65 | + path: spec.maxUnavailable |
| 66 | + |
| 67 | + - it: should render minAvailable of zero |
| 68 | + set: |
| 69 | + replicaCount: 2 |
| 70 | + podDisruptionBudget: |
| 71 | + enabled: true |
| 72 | + minAvailable: 0 |
| 73 | + maxUnavailable: null |
| 74 | + asserts: |
| 75 | + - equal: |
| 76 | + path: spec.minAvailable |
| 77 | + value: 0 |
| 78 | + - notExists: |
| 79 | + path: spec.maxUnavailable |
| 80 | + |
| 81 | + - it: should render maxUnavailable of zero |
| 82 | + set: |
| 83 | + replicaCount: 2 |
| 84 | + podDisruptionBudget: |
| 85 | + enabled: true |
| 86 | + maxUnavailable: 0 |
| 87 | + asserts: |
| 88 | + - equal: |
| 89 | + path: spec.maxUnavailable |
| 90 | + value: 0 |
| 91 | + - notExists: |
| 92 | + path: spec.minAvailable |
| 93 | + |
| 94 | + - it: should treat empty string budgets as unset |
| 95 | + set: |
| 96 | + replicaCount: 2 |
| 97 | + podDisruptionBudget: |
| 98 | + enabled: true |
| 99 | + minAvailable: "" |
| 100 | + maxUnavailable: "25%" |
| 101 | + asserts: |
| 102 | + - equal: |
| 103 | + path: spec.maxUnavailable |
| 104 | + value: "25%" |
| 105 | + - notExists: |
| 106 | + path: spec.minAvailable |
| 107 | + |
| 108 | + - it: should render eviction policy, labels and annotations |
| 109 | + set: |
| 110 | + replicaCount: 2 |
| 111 | + podDisruptionBudget: |
| 112 | + enabled: true |
| 113 | + unhealthyPodEvictionPolicy: AlwaysAllow |
| 114 | + labels: |
| 115 | + custom-label: pdb-label |
| 116 | + annotations: |
| 117 | + custom-annotation: pdb-annotation |
| 118 | + asserts: |
| 119 | + - equal: |
| 120 | + path: spec.unhealthyPodEvictionPolicy |
| 121 | + value: AlwaysAllow |
| 122 | + - equal: |
| 123 | + path: metadata.labels["custom-label"] |
| 124 | + value: pdb-label |
| 125 | + - equal: |
| 126 | + path: metadata.labels["app.kubernetes.io/name"] |
| 127 | + value: RELEASE-NAME |
| 128 | + - equal: |
| 129 | + path: metadata.annotations["custom-annotation"] |
| 130 | + value: pdb-annotation |
| 131 | + |
| 132 | + - it: should fail when both minAvailable and maxUnavailable are set |
| 133 | + set: |
| 134 | + replicaCount: 2 |
| 135 | + podDisruptionBudget: |
| 136 | + enabled: true |
| 137 | + minAvailable: 1 |
| 138 | + maxUnavailable: 1 |
| 139 | + asserts: |
| 140 | + - failedTemplate: |
| 141 | + errorMessage: "podDisruptionBudget: minAvailable and maxUnavailable are mutually exclusive. Set exactly one (to use minAvailable, set podDisruptionBudget.maxUnavailable=null)." |
| 142 | + |
| 143 | + - it: should fail when neither minAvailable nor maxUnavailable is set |
| 144 | + set: |
| 145 | + replicaCount: 2 |
| 146 | + podDisruptionBudget: |
| 147 | + enabled: true |
| 148 | + maxUnavailable: null |
| 149 | + asserts: |
| 150 | + - failedTemplate: |
| 151 | + errorMessage: "podDisruptionBudget is enabled but neither minAvailable nor maxUnavailable is set. Set exactly one." |
0 commit comments