You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/01/28 09:19:31 UTC
[GitHub] [apisix-dashboard] Yiyiyimu opened a new issue #1388: Help needed: bare `net/http` pkg would always return "404 Route not found"
Yiyiyimu opened a new issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388
The problem is actually about chaos test for apisix, but since it's more about a golang problem and it highly takes e2e test in apisix-dashboard for reference, so I think maybe I'll get more help here.
#### Background
To test if chaos effect qps of apisix, I try to visit a route in the same frequency, calculate ingress bandwidth per second from prometheus metrics, and then compare before and after the chaos take effect. Ref: https://github.com/apache/apisix/pull/3404
#### Problem
The current implementation is using `httpexpect` to visit the route. While it's not satisfactory, since it would print one log each time a request sent so it would print a lot logs and make test log into a mess ([commit](https://github.com/apache/apisix/pull/3404/commits/f2eb47702c3d12b2ef92b14bb626dc1626273f9f) and [messy log](https://github.com/apache/apisix/runs/1777055020#step:9:32)). So a bare HTTP get would be better.
However for some reason, using bare `net/http` pkg to access the route would always return "404 Route not found", although the route is created, accessing the same URL with `httpexpect` could work([commit](https://github.com/apache/apisix/pull/3404/commits/d0ca10d461fd493311a265f5db53a6297ae0c8fe)). So the next check would fail, `getIngressBandwidthPerSecond` would return 0 since no request succeeds (see [ci error](https://github.com/apache/apisix/pull/3404/checks?check_run_id=1776703854#step:9:33)).
It would be great if anyone could help me out 🥺
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu closed issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu closed issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu commented on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-771580985
> It seems the default printer is already the most simple one - CompactPrinter (see code). So there seems no better option for using httpexpect 😿
Sorry I made a mistake, `Printer` is an interface so I could implement a simpler one.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu edited a comment on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu edited a comment on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-771580985
> It seems the default printer is already the most simple one - CompactPrinter (see code). So there seems no better option for using httpexpect 😿
Sorry I made a mistake, `Printer` is an interface so I could implement a simpler one.
---
Done. Now it print no logs at all. Thanks for the suggestions!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu edited a comment on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu edited a comment on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-771580985
> It seems the default printer is already the most simple one - CompactPrinter (see code). So there seems no better option for using httpexpect 😿
Sorry I made a mistake, `Printer` is an interface so I could implement a simpler one.
---
Done. Now it print no logs at all. Thanks for the suggestions!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu closed issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu closed issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu commented on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-771577645
> you could set request.Close = true and have a try again.
Thanks for the suggestions @nic-chen !! But it seems still not works...
I just found out dashboard e2e test has almost the same function, I'll have a test to see if it works
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu commented on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-771579959
Thanks for the suggestions @starsz!
1. It's in that [commit](https://github.com/apache/apisix/pull/3404/commits/d0ca10d461fd493311a265f5db53a6297ae0c8fe), and would be something like
```go
func getWithoutTest(g *WithT, path string, headers map[string]string) string {
client := &http.Client{}
url := host + path
req, err := http.NewRequest(http.MethodGet, url, nil)
g.Expect(err).To(BeNil())
for key, value := range headers {
req.Header.Add(key, value)
}
resp, err := client.Do(req)
g.Expect(err).To(BeNil())
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
g.Expect(err).To(BeNil())
return string(body)
}
```
2. It seems the default printer is already the most simple one - `CompactPrinter` (see [code](https://github.com/gavv/httpexpect/blob/master/expect.go#L255-L263)). So there seems no better option for using `httpexpect` 😿
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] nic-chen commented on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
nic-chen commented on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-769792382
@Yiyiyimu you could set `request.Close = true` and have a try again.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
starsz commented on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-769604851
Hi @Yiyiyimu,
>`using bare net/http pkg to access the route would always return "404 Route not found", although the route is created, accessing the same URL with httpexpect could work(commit).`
1. How do you use the `bare net/http`?
2. If you don't want httpexpect to print a lot logs, you can config the httpexpect.
See more details: https://pkg.go.dev/github.com/gavv/httpexpect/v2#Config
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Yiyiyimu commented on issue #1388: request help: bare `net/http` pkg would always return "404 Route not found"
Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on issue #1388:
URL: https://github.com/apache/apisix-dashboard/issues/1388#issuecomment-771577645
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org