8
8
package tests
9
9
10
10
import (
11
- "context"
12
- "fmt"
13
11
"testing"
14
- "time"
15
12
16
- "github.com/stretchr/testify/require"
17
13
"k8s.io/apimachinery/pkg/types"
18
- "k8s.io/apimachinery/pkg/util/wait"
19
- "sigs.k8s.io/controller-runtime/pkg/client"
20
- gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
21
- gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
22
14
"sigs.k8s.io/gateway-api/conformance/utils/http"
23
15
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
24
16
"sigs.k8s.io/gateway-api/conformance/utils/suite"
25
- "sigs.k8s.io/gateway-api/conformance/utils/tlog"
26
-
27
- egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
28
- "github.com/envoyproxy/gateway/internal/gatewayapi"
29
- "github.com/envoyproxy/gateway/internal/gatewayapi/resource"
30
17
)
31
18
32
19
func init () {
@@ -43,15 +30,6 @@ var EnvoyPatchPolicyTest = suite.ConformanceTest{
43
30
routeNN := types.NamespacedName {Name : "http-envoy-patch-policy" , Namespace : ns }
44
31
gwNN := types.NamespacedName {Name : "same-namespace" , Namespace : ns }
45
32
gwAddr := kubernetes .GatewayAndHTTPRoutesMustBeAccepted (t , suite .Client , suite .TimeoutConfig , suite .ControllerName , kubernetes .NewGatewayRef (gwNN ), routeNN )
46
-
47
- ancestorRef := gwapiv1a2.ParentReference {
48
- Group : gatewayapi .GroupPtr (gwapiv1 .GroupName ),
49
- Kind : gatewayapi .KindPtr (resource .KindGateway ),
50
- Namespace : gatewayapi .NamespacePtr (gwNN .Namespace ),
51
- Name : gwapiv1 .ObjectName (gwNN .Name ),
52
- }
53
- envoyPatchPolicyMustBeAccepted (t , suite .Client , types.NamespacedName {Name : "custom-response-patch-policy" , Namespace : ns }, suite .ControllerName , ancestorRef )
54
-
55
33
OkResp := http.ExpectedResponse {
56
34
Request : http.Request {
57
35
Path : "/foo" ,
@@ -80,26 +58,3 @@ var EnvoyPatchPolicyTest = suite.ConformanceTest{
80
58
})
81
59
},
82
60
}
83
-
84
- // envoyPatchPolicyMustBeAccepted waits for the specified EnvoyPatchPolicy to be accepted.
85
- func envoyPatchPolicyMustBeAccepted (t * testing.T , client client.Client , policyName types.NamespacedName , controllerName string , ancestorRef gwapiv1a2.ParentReference ) {
86
- t .Helper ()
87
-
88
- waitErr := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 60 * time .Second , true , func (ctx context.Context ) (bool , error ) {
89
- policy := & egv1a1.EnvoyPatchPolicy {}
90
- err := client .Get (ctx , policyName , policy )
91
- if err != nil {
92
- return false , fmt .Errorf ("error fetching EnvoyPatchPolicy: %w" , err )
93
- }
94
-
95
- if policyAcceptedByAncestor (policy .Status .Ancestors , controllerName , ancestorRef ) {
96
- tlog .Logf (t , "EnvoyPatchPolicy has been accepted: %v" , policy )
97
- return true , nil
98
- }
99
-
100
- tlog .Logf (t , "EnvoyPatchPolicy not yet accepted: %v" , policy )
101
- return false , nil
102
- })
103
-
104
- require .NoErrorf (t , waitErr , "error waiting for EnvoyPatchPolicy to be accepted" )
105
- }
0 commit comments