Copilot commented on code in PR #13499:
URL: https://github.com/apache/apisix/pull/13499#discussion_r3385394681


##########
t/plugin/proxy-mirror3.t:
##########
@@ -68,9 +89,40 @@ routes:
 #END
 --- exec
 grpcurl -import-path ./t/grpc_server_example/proto -proto helloworld.proto 
-plaintext -d '{"name":"apisix"}' 127.0.0.1:1984 helloworld.Greeter.SayHello
+sleep 0.5
 --- response_body
 {
   "message": "Hello apisix"
 }
---- error_log eval
-qr/Connection refused\) while connecting to upstream/
+--- error_log
+grpc mirror server got request: path=/helloworld.Greeter/SayHello 
content_type=application/grpc body_len=13
+
+
+
+=== TEST 2: grpc mirror keeps the URI rewritten by access phase plugins 
(grpc-web)
+--- apisix_yaml
+routes:
+  -
+    id: 1
+    uris:
+        - /grpc/web/*
+    plugins:
+        grpc-web: {}
+        proxy-mirror:
+            host: grpc://127.0.0.1:19797
+            sample_ratio: 1
+    upstream:
+      scheme: grpc
+      nodes:
+        "127.0.0.1:10051": 1
+      type: roundrobin
+#END
+--- exec
+printf '\000\000\000\000\010\012\006apisix' | curl -s -o /dev/null -w 
"code=%{http_code}" -X POST \
+    -H 'Content-Type: application/grpc-web+proto' --data-binary @- \
+    http://127.0.0.1:1984/grpc/web/helloworld.Greeter/SayHello
+sleep 0.5
+--- response_body chomp
+code=200
+--- error_log
+grpc mirror server got request: path=/helloworld.Greeter/SayHello 
content_type=application/grpc body_len=13

Review Comment:
   This assertion hard-codes `body_len=13`, which may vary with client/library 
differences and cause flaky failures. Use a regex to assert the mirrored 
request has the expected rewritten path and `application/grpc` content-type, 
while allowing any numeric body length.



##########
t/plugin/proxy-mirror3.t:
##########
@@ -68,9 +89,40 @@ routes:
 #END
 --- exec
 grpcurl -import-path ./t/grpc_server_example/proto -proto helloworld.proto 
-plaintext -d '{"name":"apisix"}' 127.0.0.1:1984 helloworld.Greeter.SayHello
+sleep 0.5
 --- response_body
 {
   "message": "Hello apisix"
 }
---- error_log eval
-qr/Connection refused\) while connecting to upstream/
+--- error_log
+grpc mirror server got request: path=/helloworld.Greeter/SayHello 
content_type=application/grpc body_len=13
+

Review Comment:
   The test asserts an exact gRPC body length (`body_len=13`), which can change 
across grpcurl/curl/protobuf versions or minor framing differences, making the 
test brittle. Prefer a regex that keeps the `:path` and `content-type` checks 
strict while allowing any numeric body length.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to