rust-lang-ve / hilow

"Hilow" is a microblogging social feed where users are able to share they thoughts on different topics
Other
3 stars 4 forks source link

feat: add /health_check #18

Closed morenol closed 3 years ago

morenol commented 3 years ago

This PR adds a health_check endpoint. Right now we are only testing the connection with the database.

Fixes https://github.com/rust-lang-ve/hilow/issues/16

EstebanBorai commented 3 years ago

Perhaps is a good idea merging this after #21?

EstebanBorai commented 3 years ago

@morenol theres something in regards to running multiple instances of the server in parallel during tests I think I'm not aware of, if you don't mind elaborating a bit on that, perhaps I'm missing something

morenol commented 3 years ago

@morenol theres something in regards to running multiple instances of the server in parallel during tests I think I'm not aware of, if you don't mind elaborating a bit on that, perhaps I'm missing something

The idea is to create an instance of the server for each test in order to isolate the feature that I want to test. Think about those tests as integration tests

EstebanBorai commented 3 years ago

@morenol theres something in regards to running multiple instances of the server in parallel during tests I think I'm not aware of, if you don't mind elaborating a bit on that, perhaps I'm missing something

The idea is to create an instance of the server for each test in order to isolate the feature that I want to test. Think about those tests as integration tests

Thing is that by doing this approach we are going over some optimizations an issues Actix Runtime already have solved on top of Tokio as well. We should rely on Actix Runtime to accomplish this (here) which already takes care of this and have support for unit and integration tests as well.

Actix Runtime acts as a proxy to Tokio runtime and takes care of futures emitted during our tests as well: https://github.com/actix/actix-net/blob/master/actix-rt/src/system.rs

By spawning our own Tokio task we have to handle all of these edge cases ourselves.

Here is how Actix recommends how tests must be implemented: https://actix.rs/docs/testing/

morenol commented 3 years ago

Thing is that by doing this approach we are going over some optimizations an issues Actix Runtime already have solved on top of Tokio as well. We should rely on Actix Runtime to accomplish this (here) which already takes care of this and have support for unit and integration tests as well.

Thanks, I will take a look to those links!

EstebanBorai commented 3 years ago

With #26 we should be able to merge this, @morenol