|
| 1 | +--- |
| 2 | +suite: syntacticCodeIntelStorage |
| 3 | +templates: |
| 4 | +- syntactic-code-intel/worker.Deployment.yaml |
| 5 | +set: |
| 6 | + syntacticCodeIntel: |
| 7 | + enabled: true |
| 8 | +tests: |
| 9 | +- it: should back tmpdir with a plain emptyDir by default |
| 10 | + asserts: |
| 11 | + - contains: |
| 12 | + path: spec.template.spec.volumes |
| 13 | + content: |
| 14 | + name: tmpdir |
| 15 | + emptyDir: {} |
| 16 | + - contains: |
| 17 | + path: spec.template.spec.containers[0].volumeMounts |
| 18 | + content: |
| 19 | + mountPath: /tmp |
| 20 | + name: tmpdir |
| 21 | + |
| 22 | +- it: should set sizeLimit when storageSize is set on the emptyDir branch |
| 23 | + set: |
| 24 | + syntacticCodeIntel: |
| 25 | + storageType: emptyDir |
| 26 | + storageSize: 20Gi |
| 27 | + asserts: |
| 28 | + - contains: |
| 29 | + path: spec.template.spec.volumes |
| 30 | + content: |
| 31 | + name: tmpdir |
| 32 | + emptyDir: |
| 33 | + sizeLimit: 20Gi |
| 34 | + |
| 35 | +- it: should back tmpdir with a per-pod PVC when storageType=pvc |
| 36 | + set: |
| 37 | + syntacticCodeIntel: |
| 38 | + storageType: pvc |
| 39 | + storageSize: 50Gi |
| 40 | + asserts: |
| 41 | + - contains: |
| 42 | + path: spec.template.spec.volumes |
| 43 | + content: |
| 44 | + name: tmpdir |
| 45 | + ephemeral: |
| 46 | + volumeClaimTemplate: |
| 47 | + spec: |
| 48 | + accessModes: |
| 49 | + - ReadWriteOnce |
| 50 | + resources: |
| 51 | + requests: |
| 52 | + storage: 50Gi |
| 53 | + # /tmp mount is unchanged, so no TMPDIR redirect is needed |
| 54 | + - contains: |
| 55 | + path: spec.template.spec.containers[0].volumeMounts |
| 56 | + content: |
| 57 | + mountPath: /tmp |
| 58 | + name: tmpdir |
| 59 | + |
| 60 | +# The per-pod claim needs a Delete-policy class; storageClass is Retain. |
| 61 | +- it: should omit storageClassName by default so the cluster default class is used |
| 62 | + set: |
| 63 | + syntacticCodeIntel: |
| 64 | + storageType: pvc |
| 65 | + storageSize: 50Gi |
| 66 | + asserts: |
| 67 | + - notExists: |
| 68 | + path: spec.template.spec.volumes[0].ephemeral.volumeClaimTemplate.spec.storageClassName |
| 69 | + |
| 70 | +- it: should not inherit storageClass.name |
| 71 | + set: |
| 72 | + storageClass: |
| 73 | + name: custom-ssd |
| 74 | + syntacticCodeIntel: |
| 75 | + storageType: pvc |
| 76 | + storageSize: 50Gi |
| 77 | + asserts: |
| 78 | + - notExists: |
| 79 | + path: spec.template.spec.volumes[0].ephemeral.volumeClaimTemplate.spec.storageClassName |
| 80 | + |
| 81 | +- it: should use syntacticCodeIntel.storageClassName when set |
| 82 | + set: |
| 83 | + storageClass: |
| 84 | + name: custom-ssd |
| 85 | + syntacticCodeIntel: |
| 86 | + storageType: pvc |
| 87 | + storageSize: 50Gi |
| 88 | + storageClassName: premium-rwo |
| 89 | + asserts: |
| 90 | + - equal: |
| 91 | + path: spec.template.spec.volumes[0].ephemeral.volumeClaimTemplate.spec.storageClassName |
| 92 | + value: premium-rwo |
| 93 | + |
| 94 | +- it: should fail when storageSize is omitted on the pvc branch |
| 95 | + set: |
| 96 | + syntacticCodeIntel: |
| 97 | + storageType: pvc |
| 98 | + asserts: |
| 99 | + - failedTemplate: |
| 100 | + errorMessage: syntacticCodeIntel.storageSize is required when syntacticCodeIntel.storageType is pvc |
| 101 | + |
| 102 | +- it: should fall back to emptyDir when storageType is absent |
| 103 | + set: |
| 104 | + syntacticCodeIntel: |
| 105 | + storageType: null |
| 106 | + asserts: |
| 107 | + - contains: |
| 108 | + path: spec.template.spec.volumes |
| 109 | + content: |
| 110 | + name: tmpdir |
| 111 | + emptyDir: {} |
| 112 | + |
| 113 | +- it: should fail on an unknown storageType |
| 114 | + set: |
| 115 | + syntacticCodeIntel: |
| 116 | + storageType: PVC |
| 117 | + storageSize: 50Gi |
| 118 | + asserts: |
| 119 | + - failedTemplate: |
| 120 | + errorMessage: 'syntacticCodeIntel.storageType must be one of emptyDir, pvc; got "PVC"' |
| 121 | + |
| 122 | +- it: should leave the pod securityContext untouched on the emptyDir branch |
| 123 | + asserts: |
| 124 | + - equal: |
| 125 | + path: spec.template.spec.securityContext |
| 126 | + value: {} |
| 127 | + |
| 128 | +- it: should set fsGroup to the container runAsGroup on the pvc branch so /tmp is writable |
| 129 | + set: |
| 130 | + syntacticCodeIntel: |
| 131 | + storageType: pvc |
| 132 | + storageSize: 50Gi |
| 133 | + asserts: |
| 134 | + - equal: |
| 135 | + path: spec.template.spec.securityContext |
| 136 | + value: |
| 137 | + fsGroup: 101 |
| 138 | + fsGroupChangePolicy: OnRootMismatch |
| 139 | + |
| 140 | +- it: should keep a user-set fsGroup and other podSecurityContext fields on the pvc branch |
| 141 | + set: |
| 142 | + syntacticCodeIntel: |
| 143 | + storageType: pvc |
| 144 | + storageSize: 50Gi |
| 145 | + podSecurityContext: |
| 146 | + fsGroup: 2000 |
| 147 | + runAsNonRoot: true |
| 148 | + asserts: |
| 149 | + - equal: |
| 150 | + path: spec.template.spec.securityContext |
| 151 | + value: |
| 152 | + fsGroup: 2000 |
| 153 | + fsGroupChangePolicy: OnRootMismatch |
| 154 | + runAsNonRoot: true |
0 commit comments