Chen-BUPT commented on code in PR #833:
URL: https://github.com/apache/dubbo-go-pixiu/pull/833#discussion_r2616927689


##########
pkg/filter/metric/metric_test.go:
##########
@@ -259,13 +276,29 @@ func TestFilterWithPullMode(t *testing.T) {
 
 // TestFilterWithPushMode tests filter encode with push mode
 func TestFilterWithPushMode(t *testing.T) {
+       restore := withTempPromRegistry(t)
+       defer restore()
+
+       pushCh := make(chan struct{}, 1)
+       var pushHits int32
+       server := httptest.NewServer(http.HandlerFunc(func(w 
http.ResponseWriter, r *http.Request) {
+               io.Copy(io.Discard, r.Body)
+               atomic.AddInt32(&pushHits, 1)
+               select {
+               case pushCh <- struct{}{}:
+               default:
+               }
+               w.WriteHeader(http.StatusAccepted)
+       }))
+       defer server.Close()
+
        factory := &FilterFactory{
                cfg: &Config{
                        Mode: "push",
                        Push: PushConfig{
-                               GatewayURL:   "http://localhost:9091";,
+                               GatewayURL:   server.URL,

Review Comment:
   这里之前因为重复在一个进程注册多个Prometheus Collector报错了 所以选择独立的Prometheus 
Registry每个测试方法都分配了个独立的端口 这样保证了不同测试是互相隔离的 生成mock服务的逻辑是随机的端口 所以用的server.url 
在start的方法里获取到的url



##########
configs/conf.yaml:
##########
@@ -50,9 +50,9 @@ static_resources:
                     allow_credentials: false
 
       config:
-        idle_timeout: "5s"
-        read_timeout: "5s"
-        write_timeout: "5s"
+        idle_timeout: "5000ms"
+        read_timeout: "5000ms"
+        write_timeout: "5000ms"

Review Comment:
   这个非必要



##########
pkg/filter/metric/metric_test.go:
##########
@@ -409,14 +449,30 @@ func TestMetricReporterPullMode(t *testing.T) {
 
 // TestMetricReporterPushMode tests push mode with Prometheus Push Gateway.
 func TestMetricReporterPushMode(t *testing.T) {
+       restore := withTempPromRegistry(t)
+       defer restore()
+
+       pushCh := make(chan struct{}, 1)
+       var pushHits int32
+       server := httptest.NewServer(http.HandlerFunc(func(w 
http.ResponseWriter, r *http.Request) {
+               io.Copy(io.Discard, r.Body)
+               atomic.AddInt32(&pushHits, 1)
+               select {
+               case pushCh <- struct{}{}:
+               default:
+               }
+               w.WriteHeader(http.StatusAccepted)
+       }))
+       defer server.Close()
+
        // Create factory with push mode
        factory := &FilterFactory{
                cfg: &Config{
                        Mode: "push",
                        Push: PushConfig{
-                               GatewayURL:   "http://127.0.0.1:9091";,
+                               GatewayURL:   server.URL,

Review Comment:
   这里之前因为重复在一个进程注册多个Prometheus Collector报错了 所以选择独立的Prometheus 
Registry每个测试方法都分配了个独立的端口 这样保证了不同测试是互相隔离的 生成mock服务的逻辑是随机的端口 所以用的server.url 
在start的方法里获取到的url



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to