|
| 1 | +suite: deployment |
| 2 | +templates: |
| 3 | + - templates/deployment.yaml |
| 4 | +tests: |
| 5 | + - it: should be a Deployment |
| 6 | + asserts: |
| 7 | + - isKind: |
| 8 | + of: Deployment |
| 9 | + |
| 10 | + - it: should set the correct name |
| 11 | + asserts: |
| 12 | + - equal: |
| 13 | + path: metadata.name |
| 14 | + value: splunk-operator-controller-manager |
| 15 | + |
| 16 | + - it: should use Recreate strategy |
| 17 | + asserts: |
| 18 | + - equal: |
| 19 | + path: spec.strategy.type |
| 20 | + value: Recreate |
| 21 | + |
| 22 | + - it: should include default args without feature-gates |
| 23 | + asserts: |
| 24 | + - equal: |
| 25 | + path: spec.template.spec.containers[0].args |
| 26 | + value: |
| 27 | + - --leader-elect |
| 28 | + - --pprof |
| 29 | + |
| 30 | + - it: should include feature-gates arg with a single gate |
| 31 | + set: |
| 32 | + splunkOperator.featureGates: |
| 33 | + ValidationWebhook: true |
| 34 | + asserts: |
| 35 | + - contains: |
| 36 | + path: spec.template.spec.containers[0].args |
| 37 | + content: --feature-gates=ValidationWebhook=true |
| 38 | + |
| 39 | + - it: should include feature-gates arg with multiple gates |
| 40 | + set: |
| 41 | + splunkOperator.featureGates: |
| 42 | + ValidationWebhook: true |
| 43 | + MyNewFeature: false |
| 44 | + asserts: |
| 45 | + - matchRegex: |
| 46 | + path: spec.template.spec.containers[0].args[2] |
| 47 | + pattern: "^--feature-gates=" |
| 48 | + - matchRegex: |
| 49 | + path: spec.template.spec.containers[0].args[2] |
| 50 | + pattern: "ValidationWebhook=true" |
| 51 | + - matchRegex: |
| 52 | + path: spec.template.spec.containers[0].args[2] |
| 53 | + pattern: "MyNewFeature=false" |
| 54 | + |
| 55 | + - it: should not include feature-gates arg when featureGates is empty |
| 56 | + set: |
| 57 | + splunkOperator.featureGates: {} |
| 58 | + asserts: |
| 59 | + - equal: |
| 60 | + path: spec.template.spec.containers[0].args |
| 61 | + value: |
| 62 | + - --leader-elect |
| 63 | + - --pprof |
| 64 | + |
| 65 | + - it: should always include --leader-elect and --pprof even with feature gates |
| 66 | + set: |
| 67 | + splunkOperator.featureGates: |
| 68 | + ValidationWebhook: true |
| 69 | + asserts: |
| 70 | + - contains: |
| 71 | + path: spec.template.spec.containers[0].args |
| 72 | + content: --leader-elect |
| 73 | + - contains: |
| 74 | + path: spec.template.spec.containers[0].args |
| 75 | + content: --pprof |
| 76 | + |
| 77 | + - it: should set the command to /manager |
| 78 | + asserts: |
| 79 | + - equal: |
| 80 | + path: spec.template.spec.containers[0].command |
| 81 | + value: |
| 82 | + - /manager |
| 83 | + |
| 84 | + - it: should use the configured image |
| 85 | + set: |
| 86 | + splunkOperator.image.repository: my-registry/splunk-operator:test |
| 87 | + asserts: |
| 88 | + - equal: |
| 89 | + path: spec.template.spec.containers[0].image |
| 90 | + value: my-registry/splunk-operator:test |
| 91 | + |
| 92 | + - it: should set WATCH_NAMESPACE to watchNamespaces when clusterWideAccess is true |
| 93 | + set: |
| 94 | + splunkOperator.clusterWideAccess: true |
| 95 | + splunkOperator.watchNamespaces: "ns1,ns2" |
| 96 | + asserts: |
| 97 | + - contains: |
| 98 | + path: spec.template.spec.containers[0].env |
| 99 | + content: |
| 100 | + name: WATCH_NAMESPACE |
| 101 | + value: "ns1,ns2" |
| 102 | + |
| 103 | + - it: should set WATCH_NAMESPACE to release namespace when clusterWideAccess is false |
| 104 | + release: |
| 105 | + namespace: my-namespace |
| 106 | + set: |
| 107 | + splunkOperator.clusterWideAccess: false |
| 108 | + asserts: |
| 109 | + - contains: |
| 110 | + path: spec.template.spec.containers[0].env |
| 111 | + content: |
| 112 | + name: WATCH_NAMESPACE |
| 113 | + value: my-namespace |
| 114 | + |
| 115 | + - it: should add custom labels to deployment |
| 116 | + set: |
| 117 | + splunkOperator.labels: |
| 118 | + custom-label: custom-value |
| 119 | + asserts: |
| 120 | + - equal: |
| 121 | + path: metadata.labels.custom-label |
| 122 | + value: custom-value |
| 123 | + |
| 124 | + - it: should add custom annotations to deployment |
| 125 | + set: |
| 126 | + splunkOperator.annotations: |
| 127 | + custom-annotation: custom-value |
| 128 | + asserts: |
| 129 | + - equal: |
| 130 | + path: metadata.annotations.custom-annotation |
| 131 | + value: custom-value |
| 132 | + |
| 133 | + - it: should add pod labels |
| 134 | + set: |
| 135 | + splunkOperator.podLabels: |
| 136 | + pod-label: pod-value |
| 137 | + asserts: |
| 138 | + - equal: |
| 139 | + path: spec.template.metadata.labels.pod-label |
| 140 | + value: pod-value |
| 141 | + |
| 142 | + - it: should add pod annotations |
| 143 | + set: |
| 144 | + splunkOperator.podAnnotations: |
| 145 | + pod-annotation: pod-value |
| 146 | + asserts: |
| 147 | + - equal: |
| 148 | + path: spec.template.metadata.annotations.pod-annotation |
| 149 | + value: pod-value |
| 150 | + |
| 151 | + - it: should set security context defaults |
| 152 | + asserts: |
| 153 | + - equal: |
| 154 | + path: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation |
| 155 | + value: false |
| 156 | + - equal: |
| 157 | + path: spec.template.spec.containers[0].securityContext.readOnlyRootFilesystem |
| 158 | + value: true |
| 159 | + - equal: |
| 160 | + path: spec.template.spec.containers[0].securityContext.runAsNonRoot |
| 161 | + value: true |
| 162 | + |
| 163 | + - it: should disable host namespaces by default |
| 164 | + asserts: |
| 165 | + - equal: |
| 166 | + path: spec.template.spec.hostNetwork |
| 167 | + value: false |
| 168 | + - equal: |
| 169 | + path: spec.template.spec.hostPID |
| 170 | + value: false |
| 171 | + - equal: |
| 172 | + path: spec.template.spec.hostIPC |
| 173 | + value: false |
| 174 | + |
| 175 | + - it: should set extra environment variables |
| 176 | + set: |
| 177 | + extraEnvs: |
| 178 | + - name: MY_VAR |
| 179 | + value: my-value |
| 180 | + asserts: |
| 181 | + - contains: |
| 182 | + path: spec.template.spec.containers[0].env |
| 183 | + content: |
| 184 | + name: MY_VAR |
| 185 | + value: my-value |
0 commit comments