|
| 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 | + - name: Should fail if set to empty string |
| 7 | + initial: | |
| 8 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 9 | + kind: ContainerRuntimeConfig |
| 10 | + spec: |
| 11 | + containerRuntimeConfig: |
| 12 | + defaultRuntime: "" |
| 13 | + expectedError: "spec.containerRuntimeConfig.defaultRuntime: Unsupported value: \"\": supported values: \"crun\", \"runc\"" |
| 14 | + - name: Should not fail if not set and other fields set |
| 15 | + initial: | |
| 16 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 17 | + kind: ContainerRuntimeConfig |
| 18 | + spec: |
| 19 | + containerRuntimeConfig: |
| 20 | + logLevel: info |
| 21 | + expected: | |
| 22 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 23 | + kind: ContainerRuntimeConfig |
| 24 | + spec: |
| 25 | + containerRuntimeConfig: |
| 26 | + logLevel: info |
| 27 | + - name: Should fail if set to a number |
| 28 | + initial: | |
| 29 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 30 | + kind: ContainerRuntimeConfig |
| 31 | + spec: |
| 32 | + containerRuntimeConfig: |
| 33 | + defaultRuntime: 1234 |
| 34 | + expectedError: "spec.containerRuntimeConfig.defaultRuntime: Invalid value: \"integer\": spec.containerRuntimeConfig.defaultRuntime in body must be of type string: \"integer\", spec.containerRuntimeConfig.defaultRuntime: Unsupported value: 1234: supported values: \"crun\", \"runc\"" |
| 35 | + - name: Should fail if set to a blank string |
| 36 | + initial: | |
| 37 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 38 | + kind: ContainerRuntimeConfig |
| 39 | + spec: |
| 40 | + containerRuntimeConfig: |
| 41 | + defaultRuntime: " " |
| 42 | + expectedError: "Unsupported value: \" \": supported values: \"crun\", \"runc\"" |
| 43 | + - name: Should fail if invalid ContainerRuntimeConfig is provided |
| 44 | + initial: | |
| 45 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 46 | + kind: ContainerRuntimeConfig |
| 47 | + spec: |
| 48 | + containerRuntimeConfig: |
| 49 | + defaultRuntime: docker |
| 50 | + expectedError: "Unsupported value: \"docker\": supported values: \"crun\", \"runc\"" |
| 51 | + - name: Should be able to set crun in ContainerRuntimeConfig |
| 52 | + initial: | |
| 53 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 54 | + kind: ContainerRuntimeConfig |
| 55 | + spec: |
| 56 | + containerRuntimeConfig: |
| 57 | + defaultRuntime: crun |
| 58 | + expected: | |
| 59 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 60 | + kind: ContainerRuntimeConfig |
| 61 | + spec: |
| 62 | + containerRuntimeConfig: |
| 63 | + defaultRuntime: crun |
| 64 | + - name: Should be able to set runc in ContainerRuntimeConfig with other params |
| 65 | + initial: | |
| 66 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 67 | + kind: ContainerRuntimeConfig |
| 68 | + spec: |
| 69 | + containerRuntimeConfig: |
| 70 | + defaultRuntime: runc |
| 71 | + logLevel: info |
| 72 | + expected: | |
| 73 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 74 | + kind: ContainerRuntimeConfig |
| 75 | + spec: |
| 76 | + containerRuntimeConfig: |
| 77 | + defaultRuntime: runc |
| 78 | + logLevel: info |
| 79 | + onUpdate: |
| 80 | + - name: Case 1 - Change another field - Should be able to update other parameters with invalid defaultRuntime |
| 81 | + initialCRDPatches: |
| 82 | + - op: remove |
| 83 | + path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum |
| 84 | + initial: | |
| 85 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 86 | + kind: ContainerRuntimeConfig |
| 87 | + spec: |
| 88 | + containerRuntimeConfig: |
| 89 | + defaultRuntime: docker |
| 90 | + logLevel: fatal |
| 91 | + updated: | |
| 92 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 93 | + kind: ContainerRuntimeConfig |
| 94 | + spec: |
| 95 | + containerRuntimeConfig: |
| 96 | + defaultRuntime: docker |
| 97 | + logLevel: info |
| 98 | + expected: | |
| 99 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 100 | + kind: ContainerRuntimeConfig |
| 101 | + spec: |
| 102 | + containerRuntimeConfig: |
| 103 | + defaultRuntime: docker |
| 104 | + logLevel: info |
| 105 | + - name: Case 2 - Remove the field - Should be able to update from invalid to removed |
| 106 | + initialCRDPatches: |
| 107 | + - op: remove |
| 108 | + path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum |
| 109 | + initial: | |
| 110 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 111 | + kind: ContainerRuntimeConfig |
| 112 | + spec: |
| 113 | + containerRuntimeConfig: |
| 114 | + defaultRuntime: docker |
| 115 | + updated: | |
| 116 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 117 | + kind: ContainerRuntimeConfig |
| 118 | + spec: |
| 119 | + containerRuntimeConfig: {} |
| 120 | + expected: | |
| 121 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 122 | + kind: ContainerRuntimeConfig |
| 123 | + spec: |
| 124 | + containerRuntimeConfig: {} |
| 125 | + - name: Case 3 - Update the field - Should be able to update from invalid to correct value |
| 126 | + initialCRDPatches: |
| 127 | + - op: remove |
| 128 | + path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum |
| 129 | + initial: | |
| 130 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 131 | + kind: ContainerRuntimeConfig |
| 132 | + spec: |
| 133 | + containerRuntimeConfig: |
| 134 | + defaultRuntime: docker |
| 135 | + updated: | |
| 136 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 137 | + kind: ContainerRuntimeConfig |
| 138 | + spec: |
| 139 | + containerRuntimeConfig: |
| 140 | + defaultRuntime: runc |
| 141 | + expected: | |
| 142 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 143 | + kind: ContainerRuntimeConfig |
| 144 | + spec: |
| 145 | + containerRuntimeConfig: |
| 146 | + defaultRuntime: runc |
0 commit comments