@@ -721,238 +721,6 @@ func TestPodFitsHostPorts(t *testing.T) {
721
721
}
722
722
}
723
723
724
- func TestGCEDiskConflicts (t * testing.T ) {
725
- volState := v1.PodSpec {
726
- Volumes : []v1.Volume {
727
- {
728
- VolumeSource : v1.VolumeSource {
729
- GCEPersistentDisk : & v1.GCEPersistentDiskVolumeSource {
730
- PDName : "foo" ,
731
- },
732
- },
733
- },
734
- },
735
- }
736
- volState2 := v1.PodSpec {
737
- Volumes : []v1.Volume {
738
- {
739
- VolumeSource : v1.VolumeSource {
740
- GCEPersistentDisk : & v1.GCEPersistentDiskVolumeSource {
741
- PDName : "bar" ,
742
- },
743
- },
744
- },
745
- },
746
- }
747
- tests := []struct {
748
- pod * v1.Pod
749
- nodeInfo * schedulernodeinfo.NodeInfo
750
- isOk bool
751
- name string
752
- }{
753
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (), true , "nothing" },
754
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "one state" },
755
- {& v1.Pod {Spec : volState }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), false , "same state" },
756
- {& v1.Pod {Spec : volState2 }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "different state" },
757
- }
758
- expectedFailureReasons := []PredicateFailureReason {ErrDiskConflict }
759
-
760
- for _ , test := range tests {
761
- t .Run (test .name , func (t * testing.T ) {
762
- ok , reasons , err := NoDiskConflict (test .pod , nil , test .nodeInfo )
763
- if err != nil {
764
- t .Errorf ("unexpected error: %v" , err )
765
- }
766
- if ! ok && ! reflect .DeepEqual (reasons , expectedFailureReasons ) {
767
- t .Errorf ("unexpected failure reasons: %v, want: %v" , reasons , expectedFailureReasons )
768
- }
769
- if test .isOk && ! ok {
770
- t .Errorf ("expected ok, got none. %v %s" , test .pod , test .nodeInfo )
771
- }
772
- if ! test .isOk && ok {
773
- t .Errorf ("expected no ok, got one. %v %s" , test .pod , test .nodeInfo )
774
- }
775
- })
776
- }
777
- }
778
-
779
- func TestAWSDiskConflicts (t * testing.T ) {
780
- volState := v1.PodSpec {
781
- Volumes : []v1.Volume {
782
- {
783
- VolumeSource : v1.VolumeSource {
784
- AWSElasticBlockStore : & v1.AWSElasticBlockStoreVolumeSource {
785
- VolumeID : "foo" ,
786
- },
787
- },
788
- },
789
- },
790
- }
791
- volState2 := v1.PodSpec {
792
- Volumes : []v1.Volume {
793
- {
794
- VolumeSource : v1.VolumeSource {
795
- AWSElasticBlockStore : & v1.AWSElasticBlockStoreVolumeSource {
796
- VolumeID : "bar" ,
797
- },
798
- },
799
- },
800
- },
801
- }
802
- tests := []struct {
803
- pod * v1.Pod
804
- nodeInfo * schedulernodeinfo.NodeInfo
805
- isOk bool
806
- name string
807
- }{
808
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (), true , "nothing" },
809
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "one state" },
810
- {& v1.Pod {Spec : volState }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), false , "same state" },
811
- {& v1.Pod {Spec : volState2 }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "different state" },
812
- }
813
- expectedFailureReasons := []PredicateFailureReason {ErrDiskConflict }
814
-
815
- for _ , test := range tests {
816
- t .Run (test .name , func (t * testing.T ) {
817
- ok , reasons , err := NoDiskConflict (test .pod , nil , test .nodeInfo )
818
- if err != nil {
819
- t .Errorf ("unexpected error: %v" , err )
820
- }
821
- if ! ok && ! reflect .DeepEqual (reasons , expectedFailureReasons ) {
822
- t .Errorf ("unexpected failure reasons: %v, want: %v" , reasons , expectedFailureReasons )
823
- }
824
- if test .isOk && ! ok {
825
- t .Errorf ("expected ok, got none. %v %s" , test .pod , test .nodeInfo )
826
- }
827
- if ! test .isOk && ok {
828
- t .Errorf ("expected no ok, got one. %v %s" , test .pod , test .nodeInfo )
829
- }
830
- })
831
- }
832
- }
833
-
834
- func TestRBDDiskConflicts (t * testing.T ) {
835
- volState := v1.PodSpec {
836
- Volumes : []v1.Volume {
837
- {
838
- VolumeSource : v1.VolumeSource {
839
- RBD : & v1.RBDVolumeSource {
840
- CephMonitors : []string {"a" , "b" },
841
- RBDPool : "foo" ,
842
- RBDImage : "bar" ,
843
- FSType : "ext4" ,
844
- },
845
- },
846
- },
847
- },
848
- }
849
- volState2 := v1.PodSpec {
850
- Volumes : []v1.Volume {
851
- {
852
- VolumeSource : v1.VolumeSource {
853
- RBD : & v1.RBDVolumeSource {
854
- CephMonitors : []string {"c" , "d" },
855
- RBDPool : "foo" ,
856
- RBDImage : "bar" ,
857
- FSType : "ext4" ,
858
- },
859
- },
860
- },
861
- },
862
- }
863
- tests := []struct {
864
- pod * v1.Pod
865
- nodeInfo * schedulernodeinfo.NodeInfo
866
- isOk bool
867
- name string
868
- }{
869
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (), true , "nothing" },
870
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "one state" },
871
- {& v1.Pod {Spec : volState }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), false , "same state" },
872
- {& v1.Pod {Spec : volState2 }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "different state" },
873
- }
874
- expectedFailureReasons := []PredicateFailureReason {ErrDiskConflict }
875
-
876
- for _ , test := range tests {
877
- t .Run (test .name , func (t * testing.T ) {
878
- ok , reasons , err := NoDiskConflict (test .pod , nil , test .nodeInfo )
879
- if err != nil {
880
- t .Errorf ("unexpected error: %v" , err )
881
- }
882
- if ! ok && ! reflect .DeepEqual (reasons , expectedFailureReasons ) {
883
- t .Errorf ("unexpected failure reasons: %v, want: %v" , reasons , expectedFailureReasons )
884
- }
885
- if test .isOk && ! ok {
886
- t .Errorf ("expected ok, got none. %v %s" , test .pod , test .nodeInfo )
887
- }
888
- if ! test .isOk && ok {
889
- t .Errorf ("expected no ok, got one. %v %s" , test .pod , test .nodeInfo )
890
- }
891
- })
892
- }
893
- }
894
-
895
- func TestISCSIDiskConflicts (t * testing.T ) {
896
- volState := v1.PodSpec {
897
- Volumes : []v1.Volume {
898
- {
899
- VolumeSource : v1.VolumeSource {
900
- ISCSI : & v1.ISCSIVolumeSource {
901
- TargetPortal : "127.0.0.1:3260" ,
902
- IQN : "iqn.2016-12.server:storage.target01" ,
903
- FSType : "ext4" ,
904
- Lun : 0 ,
905
- },
906
- },
907
- },
908
- },
909
- }
910
- volState2 := v1.PodSpec {
911
- Volumes : []v1.Volume {
912
- {
913
- VolumeSource : v1.VolumeSource {
914
- ISCSI : & v1.ISCSIVolumeSource {
915
- TargetPortal : "127.0.0.1:3260" ,
916
- IQN : "iqn.2017-12.server:storage.target01" ,
917
- FSType : "ext4" ,
918
- Lun : 0 ,
919
- },
920
- },
921
- },
922
- },
923
- }
924
- tests := []struct {
925
- pod * v1.Pod
926
- nodeInfo * schedulernodeinfo.NodeInfo
927
- isOk bool
928
- name string
929
- }{
930
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (), true , "nothing" },
931
- {& v1.Pod {}, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "one state" },
932
- {& v1.Pod {Spec : volState }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), false , "same state" },
933
- {& v1.Pod {Spec : volState2 }, schedulernodeinfo .NewNodeInfo (& v1.Pod {Spec : volState }), true , "different state" },
934
- }
935
- expectedFailureReasons := []PredicateFailureReason {ErrDiskConflict }
936
-
937
- for _ , test := range tests {
938
- t .Run (test .name , func (t * testing.T ) {
939
- ok , reasons , err := NoDiskConflict (test .pod , nil , test .nodeInfo )
940
- if err != nil {
941
- t .Errorf ("unexpected error: %v" , err )
942
- }
943
- if ! ok && ! reflect .DeepEqual (reasons , expectedFailureReasons ) {
944
- t .Errorf ("unexpected failure reasons: %v, want: %v" , reasons , expectedFailureReasons )
945
- }
946
- if test .isOk && ! ok {
947
- t .Errorf ("expected ok, got none. %v %s" , test .pod , test .nodeInfo )
948
- }
949
- if ! test .isOk && ok {
950
- t .Errorf ("expected no ok, got one. %v %s" , test .pod , test .nodeInfo )
951
- }
952
- })
953
- }
954
- }
955
-
956
724
// TODO: Add test case for RequiredDuringSchedulingRequiredDuringExecution after it's implemented.
957
725
func TestPodFitsSelector (t * testing.T ) {
958
726
tests := []struct {
0 commit comments