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