update TestIsMachineConfigPoolConfigurationValid() to check release version annotation
Related-to: BZ
@@ -32,6 +32,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
type config struct {
name string
version string
+ releaseVersion string
}
tests := []struct {
@@ -73,9 +74,11 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
knownConfigs: []config{{
name: "g",
version: "v2",
+ releaseVersion: "rv2",
}, {
name: "c-0",
version: "v1",
+ releaseVersion: "rv2",
}, {
name: "u-0",
}},
@@ -87,9 +90,11 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
knownConfigs: []config{{
name: "g",
version: "v2",
+ releaseVersion: "rv2",
}, {
name: "c-0",
version: "v2",
+ releaseVersion: "rv2",
}, {
name: "u-0",
}},
@@ -101,9 +106,11 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
knownConfigs: []config{{
name: "g",
version: "v2",
+ releaseVersion: "rv2",
}, {
name: "c-0",
version: "v2",
+ releaseVersion: "rv2",
}, {
name: "u-0",
}},
@@ -111,6 +118,22 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
testurl: "wrongurl",
generated: "g",
err: errors.New("osImageURL mismatch for dummy-pool in g expected: myurl got: wrongurl"),
+ }, {
+ knownConfigs: []config{{
+ name: "g",
+ version: "v2",
+ releaseVersion: "rv1",
+ }, {
+ name: "c-0",
+ version: "v2",
+ releaseVersion: "rv1",
+ }, {
+ name: "u-0",
+ }},
+ source: []string{"c-0", "u-0"},
+ testurl: "myurl",
+ generated: "g",
+ err: errors.New("release image version mismatch for dummy-pool in g expected: rv2 got: rv1"),
}}
for idx, test := range tests {
@@ -122,6 +145,9 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
if c.version != "" {
annos[ctrlcommon.GeneratedByControllerVersionAnnotationKey] = c.version
}
+ if c.releaseVersion != "" {
+ annos[ctrlcommon.ReleaseImageVersionAnnotationKey] = c.releaseVersion
+ }
return &mcfgv1.MachineConfig{
ObjectMeta: metav1.ObjectMeta{
Name: c.name,
@@ -149,7 +175,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
Status: mcfgv1.MachineConfigPoolStatus{
Configuration: mcfgv1.MachineConfigPoolStatusConfiguration{ObjectReference: corev1.ObjectReference{Name: test.generated}, Source: source},
},
- }, "v2", "myurl", getter)
+ }, "v2", "rv2", "myurl", getter)
if !reflect.DeepEqual(err, test.err) {
t.Fatalf("expected %v got %v", test.err, err)
}
