@@ -890,3 +890,109 @@ func TestVolumeBinding(t *testing.T) {
890
890
})
891
891
}
892
892
}
893
+
894
+ func TestIsSchedulableAfterCSINodeChange (t * testing.T ) {
895
+ table := []struct {
896
+ name string
897
+ oldObj interface {}
898
+ newObj interface {}
899
+ err bool
900
+ expect framework.QueueingHint
901
+ }{
902
+ {
903
+ name : "unexpected objects are passed" ,
904
+ oldObj : new (struct {}),
905
+ newObj : new (struct {}),
906
+ err : true ,
907
+ expect : framework .Queue ,
908
+ },
909
+ {
910
+ name : "CSINode is newly created" ,
911
+ newObj : & storagev1.CSINode {
912
+ ObjectMeta : metav1.ObjectMeta {
913
+ Name : "csinode-a" ,
914
+ },
915
+ },
916
+ oldObj : nil ,
917
+ err : false ,
918
+ expect : framework .Queue ,
919
+ },
920
+ {
921
+ name : "CSINode's migrated-plugins annotations is added" ,
922
+ oldObj : & storagev1.CSINode {
923
+ ObjectMeta : metav1.ObjectMeta {
924
+ Name : "csinode-a" ,
925
+ Annotations : map [string ]string {
926
+ v1 .MigratedPluginsAnnotationKey : "test1" ,
927
+ },
928
+ },
929
+ },
930
+ newObj : & storagev1.CSINode {
931
+ ObjectMeta : metav1.ObjectMeta {
932
+ Name : "csinode-a" ,
933
+ Annotations : map [string ]string {
934
+ v1 .MigratedPluginsAnnotationKey : "test1, test2" ,
935
+ },
936
+ },
937
+ },
938
+ err : false ,
939
+ expect : framework .Queue ,
940
+ },
941
+ {
942
+ name : "CSINode's migrated-plugins annotation is updated" ,
943
+ oldObj : & storagev1.CSINode {
944
+ ObjectMeta : metav1.ObjectMeta {
945
+ Name : "csinode-a" ,
946
+ Annotations : map [string ]string {
947
+ v1 .MigratedPluginsAnnotationKey : "test1" ,
948
+ },
949
+ },
950
+ },
951
+ newObj : & storagev1.CSINode {
952
+ ObjectMeta : metav1.ObjectMeta {
953
+ Name : "csinode-a" ,
954
+ Annotations : map [string ]string {
955
+ v1 .MigratedPluginsAnnotationKey : "test2" ,
956
+ },
957
+ },
958
+ },
959
+ err : false ,
960
+ expect : framework .Queue ,
961
+ },
962
+ {
963
+ name : "CSINode is updated but migrated-plugins annotation gets unchanged" ,
964
+ oldObj : & storagev1.CSINode {
965
+ ObjectMeta : metav1.ObjectMeta {
966
+ Name : "csinode-a" ,
967
+ Annotations : map [string ]string {
968
+ v1 .MigratedPluginsAnnotationKey : "test1" ,
969
+ },
970
+ },
971
+ },
972
+ newObj : & storagev1.CSINode {
973
+ ObjectMeta : metav1.ObjectMeta {
974
+ Name : "csinode-a" ,
975
+ Annotations : map [string ]string {
976
+ v1 .MigratedPluginsAnnotationKey : "test1" ,
977
+ },
978
+ },
979
+ },
980
+ err : false ,
981
+ expect : framework .QueueSkip ,
982
+ },
983
+ }
984
+ for _ , item := range table {
985
+ t .Run (item .name , func (t * testing.T ) {
986
+ pl := & VolumeBinding {}
987
+ pod := makePod ("pod-a" ).Pod
988
+ logger , _ := ktesting .NewTestContext (t )
989
+ qhint , err := pl .isSchedulableAfterCSINodeChange (logger , pod , item .oldObj , item .newObj )
990
+ if (err != nil ) != item .err {
991
+ t .Errorf ("isSchedulableAfterCSINodeChange failed - got: %q" , err )
992
+ }
993
+ if qhint != item .expect {
994
+ t .Errorf ("QHint does not match: %v, want: %v" , qhint , item .expect )
995
+ }
996
+ })
997
+ }
998
+ }
0 commit comments