@@ -148,6 +148,58 @@ func TestCheckpointGetOrCreate(t *testing.T) {
148
148
checkpointContent : `{` ,
149
149
expectedError : "unexpected end of JSON input" ,
150
150
},
151
+ {
152
+ // Emulate upgrade scenario by pretending that `Device.RequestNames` is a new field.
153
+ // The checkpoint content doesn't have it and that shouldn't prevent the checkpoint from being loaded.
154
+ description : "upgraded-structure" ,
155
+ checkpointContent : `{"Data":"{\"kind\":\"DRACheckpoint\",\"apiVersion\":\"checkpoint.dra.kubelet.k8s.io/v1\",\"ClaimInfoStateList\":[{\"ClaimUID\":\"067798be-454e-4be4-9047-1aa06aea63f7\",\"ClaimName\":\"example\",\"Namespace\":\"default\",\"PodUIDs\":{\"139cdb46-f989-4f17-9561-ca10cfb509a6\":{}},\"DriverState\":{\"test-driver.cdi.k8s.io\":{\"Devices\":[{\"PoolName\":\"worker-1\",\"DeviceName\":\"dev-1\",\"CDIDeviceIDs\":[\"example.com/example=cdi-example\"]}]}}}]}","Checksum":1137250765}` ,
156
+ expectedClaimInfoStateList : ClaimInfoStateList {
157
+ {
158
+ DriverState : map [string ]DriverState {
159
+ "test-driver.cdi.k8s.io" : {
160
+ Devices : []Device {
161
+ {
162
+ PoolName : "worker-1" ,
163
+ DeviceName : "dev-1" ,
164
+ RequestNames : nil ,
165
+ CDIDeviceIDs : []string {"example.com/example=cdi-example" },
166
+ },
167
+ },
168
+ },
169
+ },
170
+ ClaimUID : "067798be-454e-4be4-9047-1aa06aea63f7" ,
171
+ ClaimName : "example" ,
172
+ Namespace : "default" ,
173
+ PodUIDs : sets .New ("139cdb46-f989-4f17-9561-ca10cfb509a6" ),
174
+ },
175
+ },
176
+ },
177
+ {
178
+ // Emulate upgrade scenario by pretending that `Device.RequestNames` is a new field and API version has changed from v0 to v1.
179
+ // These changes shouldn't prevent the checkpoint from being loaded.
180
+ description : "upgraded-structure-and-version" ,
181
+ checkpointContent : `{"Data":"{\"kind\":\"DRACheckpoint\",\"apiVersion\":\"checkpoint.dra.kubelet.k8s.io/v0\",\"ClaimInfoStateList\":[{\"ClaimUID\":\"067798be-454e-4be4-9047-1aa06aea63f7\",\"ClaimName\":\"example\",\"Namespace\":\"default\",\"PodUIDs\":{\"139cdb46-f989-4f17-9561-ca10cfb509a6\":{}},\"DriverState\":{\"test-driver.cdi.k8s.io\":{\"Devices\":[{\"PoolName\":\"worker-1\",\"DeviceName\":\"dev-1\",\"CDIDeviceIDs\":[\"example.com/example=cdi-example\"]}]}}}]}","Checksum":1284376732}` ,
182
+ expectedClaimInfoStateList : ClaimInfoStateList {
183
+ {
184
+ DriverState : map [string ]DriverState {
185
+ "test-driver.cdi.k8s.io" : {
186
+ Devices : []Device {
187
+ {
188
+ PoolName : "worker-1" ,
189
+ DeviceName : "dev-1" ,
190
+ RequestNames : nil ,
191
+ CDIDeviceIDs : []string {"example.com/example=cdi-example" },
192
+ },
193
+ },
194
+ },
195
+ },
196
+ ClaimUID : "067798be-454e-4be4-9047-1aa06aea63f7" ,
197
+ ClaimName : "example" ,
198
+ Namespace : "default" ,
199
+ PodUIDs : sets .New ("139cdb46-f989-4f17-9561-ca10cfb509a6" ),
200
+ },
201
+ },
202
+ },
151
203
}
152
204
153
205
// create temp dir
0 commit comments