|
8 | 8 | "google.golang.org/grpc/credentials" |
9 | 9 | appsv1 "k8s.io/api/apps/v1" |
10 | 10 | corev1 "k8s.io/api/core/v1" |
| 11 | + "k8s.io/apimachinery/pkg/types" |
11 | 12 | elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1" |
| 13 | + "sigs.k8s.io/aws-load-balancer-controller/pkg/k8s" |
12 | 14 | "sigs.k8s.io/aws-load-balancer-controller/test/e2e/gateway/grpc/echo" |
13 | 15 | "sigs.k8s.io/aws-load-balancer-controller/test/framework" |
14 | 16 | gwv1 "sigs.k8s.io/gateway-api/apis/v1" |
@@ -105,3 +107,106 @@ func generateGRPCClient(dnsName string) (echo.EchoServiceClient, error) { |
105 | 107 | } |
106 | 108 | return echo.NewEchoServiceClient(conn), nil |
107 | 109 | } |
| 110 | + |
| 111 | +func validateHTTPRouteStatusNotPermitted(tf *framework.Framework, stack ALBTestStack) { |
| 112 | + validationInfo := map[string]routeValidationInfo{ |
| 113 | + k8s.NamespacedName(stack.albResourceStack.httprs[0]).String(): { |
| 114 | + parentGatewayName: stack.albResourceStack.commonStack.gw.Name, |
| 115 | + listenerInfo: []listenerValidationInfo{ |
| 116 | + { |
| 117 | + listenerName: "test-listener", |
| 118 | + parentKind: "Gateway", |
| 119 | + resolvedRefReason: "Accepted", |
| 120 | + resolvedRefsStatus: "True", |
| 121 | + acceptedReason: "Accepted", |
| 122 | + acceptedStatus: "True", |
| 123 | + }, |
| 124 | + }, |
| 125 | + }, |
| 126 | + k8s.NamespacedName(stack.albResourceStack.httprs[1]).String(): { |
| 127 | + parentGatewayName: stack.albResourceStack.commonStack.gw.Name, |
| 128 | + listenerInfo: []listenerValidationInfo{ |
| 129 | + { |
| 130 | + listenerName: "other-ns", |
| 131 | + parentKind: "Gateway", |
| 132 | + resolvedRefReason: "RefNotPermitted", |
| 133 | + resolvedRefsStatus: "False", |
| 134 | + acceptedReason: "RefNotPermitted", |
| 135 | + acceptedStatus: "False", |
| 136 | + }, |
| 137 | + }, |
| 138 | + }, |
| 139 | + } |
| 140 | + validateRouteStatus(tf, stack.albResourceStack.httprs, httpRouteStatusConverter, validationInfo) |
| 141 | +} |
| 142 | + |
| 143 | +func validateHTTPRouteStatusPermitted(tf *framework.Framework, stack ALBTestStack) { |
| 144 | + validationInfo := map[string]routeValidationInfo{ |
| 145 | + k8s.NamespacedName(stack.albResourceStack.httprs[0]).String(): { |
| 146 | + parentGatewayName: stack.albResourceStack.commonStack.gw.Name, |
| 147 | + listenerInfo: []listenerValidationInfo{ |
| 148 | + { |
| 149 | + listenerName: "test-listener", |
| 150 | + parentKind: "Gateway", |
| 151 | + resolvedRefReason: "Accepted", |
| 152 | + resolvedRefsStatus: "True", |
| 153 | + acceptedReason: "Accepted", |
| 154 | + acceptedStatus: "True", |
| 155 | + }, |
| 156 | + }, |
| 157 | + }, |
| 158 | + k8s.NamespacedName(stack.albResourceStack.httprs[1]).String(): { |
| 159 | + parentGatewayName: stack.albResourceStack.commonStack.gw.Name, |
| 160 | + listenerInfo: []listenerValidationInfo{ |
| 161 | + { |
| 162 | + listenerName: "other-ns", |
| 163 | + parentKind: "Gateway", |
| 164 | + resolvedRefReason: "Accepted", |
| 165 | + resolvedRefsStatus: "True", |
| 166 | + acceptedReason: "Accepted", |
| 167 | + acceptedStatus: "True", |
| 168 | + }, |
| 169 | + }, |
| 170 | + }, |
| 171 | + } |
| 172 | + validateRouteStatus(tf, stack.albResourceStack.httprs, httpRouteStatusConverter, validationInfo) |
| 173 | +} |
| 174 | + |
| 175 | +func validateGRPCRouteStatus(tf *framework.Framework, stack ALBTestStack) { |
| 176 | + validationInfo := map[string]routeValidationInfo{ |
| 177 | + k8s.NamespacedName(stack.albResourceStack.grpcrs[0]).String(): { |
| 178 | + parentGatewayName: stack.albResourceStack.commonStack.gw.Name, |
| 179 | + listenerInfo: []listenerValidationInfo{ |
| 180 | + { |
| 181 | + listenerName: "test-listener", |
| 182 | + parentKind: "Gateway", |
| 183 | + resolvedRefReason: "Accepted", |
| 184 | + resolvedRefsStatus: "True", |
| 185 | + acceptedReason: "Accepted", |
| 186 | + acceptedStatus: "True", |
| 187 | + }, |
| 188 | + }, |
| 189 | + }, |
| 190 | + } |
| 191 | + validateRouteStatus(tf, stack.albResourceStack.grpcrs, grpcRouteStatusConverter, validationInfo) |
| 192 | +} |
| 193 | + |
| 194 | +func httpRouteStatusConverter(tf *framework.Framework, i interface{}) (gwv1.RouteStatus, types.NamespacedName, error) { |
| 195 | + httpR := i.(*gwv1.HTTPRoute) |
| 196 | + retrievedRoute := gwv1.HTTPRoute{} |
| 197 | + err := tf.K8sClient.Get(context.Background(), k8s.NamespacedName(httpR), &retrievedRoute) |
| 198 | + if err != nil { |
| 199 | + return gwv1.RouteStatus{}, types.NamespacedName{}, err |
| 200 | + } |
| 201 | + return retrievedRoute.Status.RouteStatus, k8s.NamespacedName(&retrievedRoute), nil |
| 202 | +} |
| 203 | + |
| 204 | +func grpcRouteStatusConverter(tf *framework.Framework, i interface{}) (gwv1.RouteStatus, types.NamespacedName, error) { |
| 205 | + grpcR := i.(*gwv1.GRPCRoute) |
| 206 | + retrievedRoute := gwv1.GRPCRoute{} |
| 207 | + err := tf.K8sClient.Get(context.Background(), k8s.NamespacedName(grpcR), &retrievedRoute) |
| 208 | + if err != nil { |
| 209 | + return gwv1.RouteStatus{}, types.NamespacedName{}, err |
| 210 | + } |
| 211 | + return retrievedRoute.Status.RouteStatus, k8s.NamespacedName(&retrievedRoute), nil |
| 212 | +} |
0 commit comments