@@ -831,6 +831,8 @@ func TestAssignRoutePriorityToSplitHTTPRoutes(t *testing.T) {
831
831
matchIndex int
832
832
}
833
833
now := time .Now ()
834
+ const maxRelativeOrderPriorityBits = (1 << 18 ) - 1
835
+
834
836
testCases := []struct {
835
837
name string
836
838
splitHTTPRoutes []* gatewayv1beta1.HTTPRoute
@@ -890,14 +892,24 @@ func TestAssignRoutePriorityToSplitHTTPRoutes(t *testing.T) {
890
892
hostname : "foo.com" ,
891
893
ruleIndex : 0 ,
892
894
matchIndex : 0 ,
893
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ),
895
+ }: HTTPRoutePriorityTraits {
896
+ PreciseHostname : true ,
897
+ HostnameLength : len ("foo.com" ),
898
+ PathType : gatewayv1beta1 .PathMatchExact ,
899
+ PathLength : len ("/foo" ),
900
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits ,
894
901
{
895
902
namespace : "default" ,
896
903
name : "httproute-2" ,
897
904
hostname : "*.bar.com" ,
898
905
ruleIndex : 0 ,
899
906
matchIndex : 0 ,
900
- }: (2 << 50 ) | (9 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ),
907
+ }: HTTPRoutePriorityTraits {
908
+ PreciseHostname : false ,
909
+ HostnameLength : len ("*.bar.com" ),
910
+ PathType : gatewayv1beta1 .PathMatchExact ,
911
+ PathLength : len ("/bar" ),
912
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits ,
901
913
},
902
914
},
903
915
{
@@ -953,14 +965,24 @@ func TestAssignRoutePriorityToSplitHTTPRoutes(t *testing.T) {
953
965
hostname : "foo.com" ,
954
966
ruleIndex : 0 ,
955
967
matchIndex : 0 ,
956
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ),
968
+ }: HTTPRoutePriorityTraits {
969
+ PreciseHostname : true ,
970
+ HostnameLength : len ("foo.com" ),
971
+ PathType : gatewayv1beta1 .PathMatchExact ,
972
+ PathLength : len ("/foo" ),
973
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits ,
957
974
{
958
975
namespace : "default" ,
959
976
name : "httproute-2" ,
960
977
hostname : "bar.com" ,
961
978
ruleIndex : 0 ,
962
979
matchIndex : 0 ,
963
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ) - 1 ,
980
+ }: HTTPRoutePriorityTraits {
981
+ PreciseHostname : true ,
982
+ HostnameLength : len ("bar.com" ),
983
+ PathType : gatewayv1beta1 .PathMatchExact ,
984
+ PathLength : len ("/foo" ),
985
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits - 1 ,
964
986
},
965
987
},
966
988
{
@@ -1016,14 +1038,24 @@ func TestAssignRoutePriorityToSplitHTTPRoutes(t *testing.T) {
1016
1038
hostname : "foo.com" ,
1017
1039
ruleIndex : 0 ,
1018
1040
matchIndex : 0 ,
1019
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ),
1041
+ }: HTTPRoutePriorityTraits {
1042
+ PreciseHostname : true ,
1043
+ HostnameLength : len ("foo.com" ),
1044
+ PathType : gatewayv1beta1 .PathMatchExact ,
1045
+ PathLength : len ("/foo" ),
1046
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits ,
1020
1047
{
1021
1048
namespace : "default" ,
1022
1049
name : "httproute-2" ,
1023
1050
hostname : "bar.com" ,
1024
1051
ruleIndex : 0 ,
1025
1052
matchIndex : 0 ,
1026
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ) - 1 ,
1053
+ }: HTTPRoutePriorityTraits {
1054
+ PreciseHostname : true ,
1055
+ HostnameLength : len ("bar.com" ),
1056
+ PathType : gatewayv1beta1 .PathMatchExact ,
1057
+ PathLength : len ("/foo" ),
1058
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits - 1 ,
1027
1059
},
1028
1060
},
1029
1061
{
@@ -1079,14 +1111,24 @@ func TestAssignRoutePriorityToSplitHTTPRoutes(t *testing.T) {
1079
1111
hostname : "foo.com" ,
1080
1112
ruleIndex : 0 ,
1081
1113
matchIndex : 0 ,
1082
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ),
1114
+ }: HTTPRoutePriorityTraits {
1115
+ PreciseHostname : true ,
1116
+ HostnameLength : len ("foo.com" ),
1117
+ PathType : gatewayv1beta1 .PathMatchExact ,
1118
+ PathLength : len ("/foo" ),
1119
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits ,
1083
1120
{
1084
1121
namespace : "default" ,
1085
1122
name : "httproute-1" ,
1086
1123
hostname : "foo.com" ,
1087
1124
ruleIndex : 0 ,
1088
1125
matchIndex : 1 ,
1089
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ) - 1 ,
1126
+ }: HTTPRoutePriorityTraits {
1127
+ PreciseHostname : true ,
1128
+ HostnameLength : len ("bar.com" ),
1129
+ PathType : gatewayv1beta1 .PathMatchExact ,
1130
+ PathLength : len ("/foo" ),
1131
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits - 1 ,
1090
1132
},
1091
1133
},
1092
1134
{
@@ -1158,7 +1200,12 @@ func TestAssignRoutePriorityToSplitHTTPRoutes(t *testing.T) {
1158
1200
hostname : "foo.com" ,
1159
1201
ruleIndex : 0 ,
1160
1202
matchIndex : 0 ,
1161
- }: (2 << 50 ) | (1 << 49 ) | (7 << 41 ) | (1 << 40 ) | (3 << 29 ) | ((1 << 18 ) - 1 ),
1203
+ }: HTTPRoutePriorityTraits {
1204
+ PreciseHostname : true ,
1205
+ HostnameLength : len ("foo.com" ),
1206
+ PathType : gatewayv1beta1 .PathMatchExact ,
1207
+ PathLength : len ("/foo" ),
1208
+ }.EncodeToPriority () + maxRelativeOrderPriorityBits ,
1162
1209
},
1163
1210
},
1164
1211
}
0 commit comments