@@ -460,7 +460,67 @@ func TestHTTPProxyReconcile(t *testing.T) {
460460 },
461461 },
462462 postCreateGatewayStatus : func (g * gatewayv1.Gateway ) {
463- // EnvoyPatchPolicy is only created after Gateway is Programmed
463+ setGatewayProgrammedWithDefaultHTTPSListener (g )
464+ },
465+ expectedError : false ,
466+ expectedConditions : []metav1.Condition {
467+ {
468+ Type : networkingv1alpha .HTTPProxyConditionAccepted ,
469+ Status : metav1 .ConditionTrue ,
470+ Reason : networkingv1alpha .HTTPProxyReasonAccepted ,
471+ },
472+ {
473+ Type : networkingv1alpha .HTTPProxyConditionProgrammed ,
474+ Status : metav1 .ConditionFalse ,
475+ Reason : networkingv1alpha .HTTPProxyReasonPending ,
476+ },
477+ },
478+ assert : func (t * testContext , cl client.Client , httpProxy * networkingv1alpha.HTTPProxy ) {
479+ var patchList envoygatewayv1alpha1.EnvoyPatchPolicyList
480+ err := t .downstreamClient .List (context .Background (), & patchList )
481+ assert .NoError (t , err )
482+ assert .Len (t , patchList .Items , 1 )
483+ assert .Equal (t , fmt .Sprintf ("connector-%s" , httpProxy .Name ), patchList .Items [0 ].Name )
484+ },
485+ },
486+ {
487+ name : "connector backend waits for default-https listener programmed" ,
488+ httpProxy : connectorHTTPProxy ,
489+ downstreamObjects : connectorDownstreamObjects (connectorHTTPProxy ),
490+ namespaceUID : string (connectorNamespaceUID ),
491+ existingObjects : []client.Object {
492+ & networkingv1alpha1.Connector {
493+ ObjectMeta : metav1.ObjectMeta {
494+ Name : "connector-1" ,
495+ Namespace : "test" ,
496+ },
497+ Status : networkingv1alpha1.ConnectorStatus {
498+ Conditions : []metav1.Condition {
499+ {
500+ Type : networkingv1alpha1 .ConnectorConditionReady ,
501+ Status : metav1 .ConditionTrue ,
502+ Reason : networkingv1alpha1 .ConnectorReasonReady ,
503+ },
504+ },
505+ ConnectionDetails : & networkingv1alpha1.ConnectorConnectionDetails {
506+ Type : networkingv1alpha1 .PublicKeyConnectorConnectionType ,
507+ PublicKey : & networkingv1alpha1.ConnectorConnectionDetailsPublicKey {
508+ Id : "node-123" ,
509+ DiscoveryMode : networkingv1alpha1 .DNSPublicKeyDiscoveryMode ,
510+ HomeRelay : "https://relay.example.test" ,
511+ Addresses : []networkingv1alpha1.PublicKeyConnectorAddress {
512+ {
513+ Address : "127.0.0.1" ,
514+ Port : 80 ,
515+ },
516+ },
517+ },
518+ },
519+ },
520+ },
521+ },
522+ postCreateGatewayStatus : func (g * gatewayv1.Gateway ) {
523+ // Gateway-level Programmed is not enough without default-https listener Programmed.
464524 apimeta .SetStatusCondition (& g .Status .Conditions , metav1.Condition {
465525 Type : string (gatewayv1 .GatewayConditionProgrammed ),
466526 Status : metav1 .ConditionTrue ,
@@ -485,8 +545,7 @@ func TestHTTPProxyReconcile(t *testing.T) {
485545 var patchList envoygatewayv1alpha1.EnvoyPatchPolicyList
486546 err := t .downstreamClient .List (context .Background (), & patchList )
487547 assert .NoError (t , err )
488- assert .Len (t , patchList .Items , 1 )
489- assert .Equal (t , fmt .Sprintf ("connector-%s" , httpProxy .Name ), patchList .Items [0 ].Name )
548+ assert .Len (t , patchList .Items , 0 )
490549 },
491550 },
492551 {
@@ -512,12 +571,7 @@ func TestHTTPProxyReconcile(t *testing.T) {
512571 },
513572 },
514573 postCreateGatewayStatus : func (g * gatewayv1.Gateway ) {
515- apimeta .SetStatusCondition (& g .Status .Conditions , metav1.Condition {
516- Type : string (gatewayv1 .GatewayConditionProgrammed ),
517- Status : metav1 .ConditionTrue ,
518- ObservedGeneration : g .Generation ,
519- Reason : string (gatewayv1 .GatewayReasonProgrammed ),
520- })
574+ setGatewayProgrammedWithDefaultHTTPSListener (g )
521575 },
522576 expectedError : false ,
523577 expectedConditions : []metav1.Condition {
@@ -600,13 +654,7 @@ func TestHTTPProxyReconcile(t *testing.T) {
600654 },
601655 },
602656 postCreateGatewayStatus : func (g * gatewayv1.Gateway ) {
603- // EnvoyPatchPolicy is only created after Gateway is Programmed
604- apimeta .SetStatusCondition (& g .Status .Conditions , metav1.Condition {
605- Type : string (gatewayv1 .GatewayConditionProgrammed ),
606- Status : metav1 .ConditionTrue ,
607- ObservedGeneration : g .Generation ,
608- Reason : string (gatewayv1 .GatewayReasonProgrammed ),
609- })
657+ setGatewayProgrammedWithDefaultHTTPSListener (g )
610658 },
611659 expectedError : false ,
612660 expectedConditions : []metav1.Condition {
@@ -1508,6 +1556,35 @@ func TestHTTPProxyFinalizerCleanup(t *testing.T) {
15081556 }
15091557}
15101558
1559+ func setGatewayProgrammedWithDefaultHTTPSListener (g * gatewayv1.Gateway ) {
1560+ apimeta .SetStatusCondition (& g .Status .Conditions , metav1.Condition {
1561+ Type : string (gatewayv1 .GatewayConditionProgrammed ),
1562+ Status : metav1 .ConditionTrue ,
1563+ ObservedGeneration : g .Generation ,
1564+ Reason : string (gatewayv1 .GatewayReasonProgrammed ),
1565+ })
1566+
1567+ defaultHTTPSListenerStatus := gatewayv1.ListenerStatus {
1568+ Name : gatewayutil .DefaultHTTPSListenerName ,
1569+ Conditions : []metav1.Condition {
1570+ {
1571+ Type : string (gatewayv1 .ListenerConditionProgrammed ),
1572+ Status : metav1 .ConditionTrue ,
1573+ ObservedGeneration : g .Generation ,
1574+ Reason : string (gatewayv1 .ListenerReasonProgrammed ),
1575+ },
1576+ },
1577+ }
1578+
1579+ for i := range g .Status .Listeners {
1580+ if g .Status .Listeners [i ].Name == gatewayutil .DefaultHTTPSListenerName {
1581+ g .Status .Listeners [i ] = defaultHTTPSListenerStatus
1582+ return
1583+ }
1584+ }
1585+ g .Status .Listeners = append (g .Status .Listeners , defaultHTTPSListenerStatus )
1586+ }
1587+
15111588func newHTTPProxy (opts ... func (* networkingv1alpha.HTTPProxy )) * networkingv1alpha.HTTPProxy {
15121589 p := & networkingv1alpha.HTTPProxy {
15131590 ObjectMeta : metav1.ObjectMeta {
0 commit comments