|
| 1 | +apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this |
| 2 | +name: "ContainerRuntimeConfig" |
| 3 | +crdName: containerruntimeconfigs.machineconfiguration.openshift.io |
| 4 | +featureGates: |
| 5 | +- AdditionalStorageConfig |
| 6 | +tests: |
| 7 | + onCreate: |
| 8 | + # AdditionalLayerStores - comprehensive validation tests |
| 9 | + - name: Should be able to create ContainerRuntimeConfig with multiple additionalLayerStores |
| 10 | + initial: | |
| 11 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 12 | + kind: ContainerRuntimeConfig |
| 13 | + spec: |
| 14 | + containerRuntimeConfig: |
| 15 | + additionalLayerStores: |
| 16 | + - path: /var/lib/stargz-store |
| 17 | + - path: /mnt/nydus-store |
| 18 | + - path: /opt/layer_store-v1.0 |
| 19 | + expected: | |
| 20 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 21 | + kind: ContainerRuntimeConfig |
| 22 | + spec: |
| 23 | + containerRuntimeConfig: |
| 24 | + additionalLayerStores: |
| 25 | + - path: /var/lib/stargz-store |
| 26 | + - path: /mnt/nydus-store |
| 27 | + - path: /opt/layer_store-v1.0 |
| 28 | +
|
| 29 | + - name: Should fail if additionalLayerStores path is empty |
| 30 | + initial: | |
| 31 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 32 | + kind: ContainerRuntimeConfig |
| 33 | + spec: |
| 34 | + containerRuntimeConfig: |
| 35 | + additionalLayerStores: |
| 36 | + - path: "" |
| 37 | + expectedError: "path in body should be at least 1 chars long" |
| 38 | + |
| 39 | + - name: Should fail if additionalLayerStores path is not absolute |
| 40 | + initial: | |
| 41 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 42 | + kind: ContainerRuntimeConfig |
| 43 | + spec: |
| 44 | + containerRuntimeConfig: |
| 45 | + additionalLayerStores: |
| 46 | + - path: var/lib/stargz-store |
| 47 | + expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', and '-'" |
| 48 | + |
| 49 | + - name: Should fail if additionalLayerStores path contains spaces |
| 50 | + initial: | |
| 51 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 52 | + kind: ContainerRuntimeConfig |
| 53 | + spec: |
| 54 | + containerRuntimeConfig: |
| 55 | + additionalLayerStores: |
| 56 | + - path: /var/lib/stargz store |
| 57 | + expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', and '-'" |
| 58 | + |
| 59 | + - name: Should fail if additionalLayerStores path contains invalid characters |
| 60 | + initial: | |
| 61 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 62 | + kind: ContainerRuntimeConfig |
| 63 | + spec: |
| 64 | + containerRuntimeConfig: |
| 65 | + additionalLayerStores: |
| 66 | + - path: /var/lib/stargz@store |
| 67 | + expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', and '-'" |
| 68 | + |
| 69 | + - name: Should fail if additionalLayerStores path is too long |
| 70 | + initial: | |
| 71 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 72 | + kind: ContainerRuntimeConfig |
| 73 | + spec: |
| 74 | + containerRuntimeConfig: |
| 75 | + additionalLayerStores: |
| 76 | + - path: /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| 77 | + expectedError: "Too long: may not be more than 256 bytes" |
| 78 | + |
| 79 | + - name: Should fail if additionalLayerStores exceeds maximum of 5 items |
| 80 | + initial: | |
| 81 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 82 | + kind: ContainerRuntimeConfig |
| 83 | + spec: |
| 84 | + containerRuntimeConfig: |
| 85 | + additionalLayerStores: |
| 86 | + - path: /var/lib/store1 |
| 87 | + - path: /var/lib/store2 |
| 88 | + - path: /var/lib/store3 |
| 89 | + - path: /var/lib/store4 |
| 90 | + - path: /var/lib/store5 |
| 91 | + - path: /var/lib/store6 |
| 92 | + expectedError: "Too many: 6: must have at most 5 items" |
| 93 | + |
| 94 | + - name: Should fail if additionalLayerStores item has no path field |
| 95 | + initial: | |
| 96 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 97 | + kind: ContainerRuntimeConfig |
| 98 | + spec: |
| 99 | + containerRuntimeConfig: |
| 100 | + additionalLayerStores: |
| 101 | + - {} |
| 102 | + expectedError: "path: Required value" |
| 103 | + |
| 104 | + - name: Should fail if additionalLayerStores contains duplicate paths |
| 105 | + initial: | |
| 106 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 107 | + kind: ContainerRuntimeConfig |
| 108 | + spec: |
| 109 | + containerRuntimeConfig: |
| 110 | + additionalLayerStores: |
| 111 | + - path: /var/lib/stargz-store |
| 112 | + - path: /var/lib/stargz-store |
| 113 | + expectedError: "additionalLayerStores must not contain duplicate paths" |
| 114 | + |
| 115 | + # AdditionalImageStores - test max items validation (different from layer stores) |
| 116 | + - name: Should fail if additionalImageStores exceeds maximum of 10 items |
| 117 | + initial: | |
| 118 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 119 | + kind: ContainerRuntimeConfig |
| 120 | + spec: |
| 121 | + containerRuntimeConfig: |
| 122 | + additionalImageStores: |
| 123 | + - path: /var/lib/store1 |
| 124 | + - path: /var/lib/store2 |
| 125 | + - path: /var/lib/store3 |
| 126 | + - path: /var/lib/store4 |
| 127 | + - path: /var/lib/store5 |
| 128 | + - path: /var/lib/store6 |
| 129 | + - path: /var/lib/store7 |
| 130 | + - path: /var/lib/store8 |
| 131 | + - path: /var/lib/store9 |
| 132 | + - path: /var/lib/store10 |
| 133 | + - path: /var/lib/store11 |
| 134 | + expectedError: "Too many: 11: must have at most 10 items" |
| 135 | + |
| 136 | + - name: Should fail if additionalImageStores path is not absolute |
| 137 | + initial: | |
| 138 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 139 | + kind: ContainerRuntimeConfig |
| 140 | + spec: |
| 141 | + containerRuntimeConfig: |
| 142 | + additionalImageStores: |
| 143 | + - path: var/lib/images |
| 144 | + expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', and '-'" |
| 145 | + |
| 146 | + - name: Should fail if additionalImageStores item has no path field |
| 147 | + initial: | |
| 148 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 149 | + kind: ContainerRuntimeConfig |
| 150 | + spec: |
| 151 | + containerRuntimeConfig: |
| 152 | + additionalImageStores: |
| 153 | + - {} |
| 154 | + expectedError: "path: Required value" |
| 155 | + |
| 156 | + - name: Should fail if additionalImageStores contains duplicate paths |
| 157 | + initial: | |
| 158 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 159 | + kind: ContainerRuntimeConfig |
| 160 | + spec: |
| 161 | + containerRuntimeConfig: |
| 162 | + additionalImageStores: |
| 163 | + - path: /mnt/nfs-images |
| 164 | + - path: /mnt/nfs-images |
| 165 | + expectedError: "additionalImageStores must not contain duplicate paths" |
| 166 | + |
| 167 | + # AdditionalArtifactStores - test max items validation (different from layer stores) |
| 168 | + - name: Should fail if additionalArtifactStores exceeds maximum of 10 items |
| 169 | + initial: | |
| 170 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 171 | + kind: ContainerRuntimeConfig |
| 172 | + spec: |
| 173 | + containerRuntimeConfig: |
| 174 | + additionalArtifactStores: |
| 175 | + - path: /var/lib/store1 |
| 176 | + - path: /var/lib/store2 |
| 177 | + - path: /var/lib/store3 |
| 178 | + - path: /var/lib/store4 |
| 179 | + - path: /var/lib/store5 |
| 180 | + - path: /var/lib/store6 |
| 181 | + - path: /var/lib/store7 |
| 182 | + - path: /var/lib/store8 |
| 183 | + - path: /var/lib/store9 |
| 184 | + - path: /var/lib/store10 |
| 185 | + - path: /var/lib/store11 |
| 186 | + expectedError: "Too many: 11: must have at most 10 items" |
| 187 | + |
| 188 | + - name: Should fail if additionalArtifactStores path is not absolute |
| 189 | + initial: | |
| 190 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 191 | + kind: ContainerRuntimeConfig |
| 192 | + spec: |
| 193 | + containerRuntimeConfig: |
| 194 | + additionalArtifactStores: |
| 195 | + - path: var/lib/artifacts |
| 196 | + expectedError: "path must be absolute and contain only alphanumeric characters, '/', '.', '_', and '-'" |
| 197 | + |
| 198 | + - name: Should fail if additionalArtifactStores item has no path field |
| 199 | + initial: | |
| 200 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 201 | + kind: ContainerRuntimeConfig |
| 202 | + spec: |
| 203 | + containerRuntimeConfig: |
| 204 | + additionalArtifactStores: |
| 205 | + - {} |
| 206 | + expectedError: "path: Required value" |
| 207 | + |
| 208 | + - name: Should fail if additionalArtifactStores contains duplicate paths |
| 209 | + initial: | |
| 210 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 211 | + kind: ContainerRuntimeConfig |
| 212 | + spec: |
| 213 | + containerRuntimeConfig: |
| 214 | + additionalArtifactStores: |
| 215 | + - path: /mnt/ssd-artifacts |
| 216 | + - path: /mnt/ssd-artifacts |
| 217 | + expectedError: "additionalArtifactStores must not contain duplicate paths" |
| 218 | + |
| 219 | + # Combined test - all storage types together with other fields |
| 220 | + - name: Should be able to create ContainerRuntimeConfig with all storage types and existing fields |
| 221 | + initial: | |
| 222 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 223 | + kind: ContainerRuntimeConfig |
| 224 | + spec: |
| 225 | + containerRuntimeConfig: |
| 226 | + defaultRuntime: crun |
| 227 | + logLevel: info |
| 228 | + additionalLayerStores: |
| 229 | + - path: /var/lib/stargz-store |
| 230 | + additionalImageStores: |
| 231 | + - path: /mnt/nfs-images |
| 232 | + - path: /mnt/ssd-images |
| 233 | + additionalArtifactStores: |
| 234 | + - path: /mnt/ssd-artifacts |
| 235 | + expected: | |
| 236 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 237 | + kind: ContainerRuntimeConfig |
| 238 | + spec: |
| 239 | + containerRuntimeConfig: |
| 240 | + defaultRuntime: crun |
| 241 | + logLevel: info |
| 242 | + additionalLayerStores: |
| 243 | + - path: /var/lib/stargz-store |
| 244 | + additionalImageStores: |
| 245 | + - path: /mnt/nfs-images |
| 246 | + - path: /mnt/ssd-images |
| 247 | + additionalArtifactStores: |
| 248 | + - path: /mnt/ssd-artifacts |
0 commit comments