felipenoris / hyper-reverse-proxy

A simple reverse proxy for use with Hyper and Tokio
Apache License 2.0
181 stars 63 forks source link

test: add basic parallel unit tests #17

Closed bamthomas closed 2 years ago

bamthomas commented 2 years ago

This PR adds http integration tests for the proxy.

It runs parallel with a port allocated for the server and one for the proxy for each test. For example you could see with ngrep

$ sudo ngrep -d lo
###########                                                                                                                                                                                                 [2/543]
T 127.0.0.1:58094 -> 127.0.0.1:12397 [AP] #151                                                                                                                                                                     
  GET /500 HTTP/1.1..host: localhost:12397....                                                                                                                                                                     
#                                                                                                                                                                                                                  
T 127.0.0.1:55480 -> 127.0.0.1:12396 [AP] #152                                                                                                                                                                     
  GET /foo HTTP/1.1..host: localhost:12396....                                                                                                                                                                     
#########                                                                                                                                                                                                          
T 127.0.0.1:39576 -> 127.0.0.1:12399 [AP] #161                                                                                                                                                                     
  GET /500 HTTP/1.1..host: localhost:12397..x-forwarded-for: 127.0.0.1....                                                                                                                                         
#                                                                                                                                                                                                                  
T 127.0.0.1:56454 -> 127.0.0.1:12398 [AP] #162                                                                                                                                                                     
  GET /foo HTTP/1.1..host: localhost:12396..x-forwarded-for: 127.0.0.1....                                                                                                                                         
###                                                                                                                                                                                                                
T 127.0.0.1:12399 -> 127.0.0.1:39576 [AP] #165                                                                                                                                                                     
  HTTP/1.1 500 Internal Server Error..content-length: 0..date: Sat, 12 Mar 2022 19:36:37 GMT....                                                                                                                   
##                                                                                                                                                                                                                 
T 127.0.0.1:12398 -> 127.0.0.1:56454 [AP] #167                                                                                                                                                                     
  HTTP/1.1 200 OK..content-length: 0..date: Sat, 12 Mar 2022 19:36:37 GMT....                                                                                                                                      
##                                                                                                                                                                                                                 
T 127.0.0.1:12396 -> 127.0.0.1:55480 [AP] #169                                                                                                                                                                     
  HTTP/1.1 200 OK..date: Sat, 12 Mar 2022 19:36:37 GMT..content-length: 0....                                                                                                                                      
#                                                                                                                                                                                                                  
T 127.0.0.1:12397 -> 127.0.0.1:58094 [AP] #170                                                                                                                                                                     
  HTTP/1.1 500 Internal Server Error..date: Sat, 12 Mar 2022 19:36:37 GMT..content-length: 0....                                                                                                                 
##############
somehowchris commented 2 years ago

@bamthomas tried to rebase your branch to have the changes from master as I think these tests are really useful. Somehow I keep on getting merge conflicts after a successful rebase on the gh pr page.

I see 2 option, you rebase it yourself or me targeting @felipenoris repository co-authoring your commit due to rebasing

bamthomas commented 2 years ago

I made a branch integration_tests on our repository merging the conflicts on Cargo.toml it builds locally, and tests are green.