21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22
k8s "sigs.k8s.io/gateway-api/apis/v1beta1"
24
"istio.io/istio/pilot/pkg/features"
25
"istio.io/istio/pkg/config"
26
"istio.io/istio/pkg/config/schema/gvk"
29
func TestCreateRouteStatus(t *testing.T) {
30
lastTransitionTime := metav1.Now()
31
parentRef := httpRouteSpec.ParentRefs[0]
32
parentStatus := []k8s.RouteParentStatus{
35
ControllerName: k8s.GatewayController(features.ManagedGatewayController),
36
Conditions: []metav1.Condition{
38
Type: string(k8s.RouteReasonAccepted),
39
Status: metav1.ConditionTrue,
40
ObservedGeneration: 1,
41
LastTransitionTime: lastTransitionTime,
42
Message: "Route was valid",
45
Type: string(k8s.RouteConditionResolvedRefs),
46
Status: metav1.ConditionTrue,
47
ObservedGeneration: 1,
48
LastTransitionTime: lastTransitionTime,
49
Message: "All references resolved",
55
httpRoute := config.Config{
57
GroupVersionKind: gvk.HTTPRoute,
63
Status: &k8s.HTTPRouteStatus{
64
RouteStatus: k8s.RouteStatus{
65
Parents: parentStatus,
71
gateways []RouteParentResult
73
current []k8s.RouteParentStatus
83
gateways: []RouteParentResult{{OriginalReference: parentRef}},
85
current: parentStatus,
90
name: "route status error",
92
gateways: []RouteParentResult{{OriginalReference: parentRef, RouteError: &ConfigError{
93
Reason: ConfigErrorReason(k8s.RouteReasonRefNotPermitted),
96
current: parentStatus,
101
for _, tt := range tests {
102
t.Run(tt.name, func(t *testing.T) {
103
got := createRouteStatus(tt.args.gateways, tt.args.obj, tt.args.current)
104
equal := reflect.DeepEqual(got, tt.args.current)
105
if equal != tt.wantEqual {
106
t.Errorf("route status: old: %+v, new: %+v", tt.args.current, got)