Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

clean up health check tests #38

Merged
merged 1 commit into from
Dec 1, 2017
Merged

clean up health check tests #38

merged 1 commit into from
Dec 1, 2017

Conversation

jskelcy
Copy link
Contributor

@jskelcy jskelcy commented Nov 28, 2017

No description provided.

@coveralls
Copy link

coveralls commented Nov 28, 2017

Coverage Status

Coverage increased (+1.4%) to 49.356% when pulling edd02e4 on js/config-r2ctrl-cover into 5dc4c6a on master.

@jskelcy
Copy link
Contributor Author

jskelcy commented Nov 28, 2017

I may have changed the health check endpoint on this one. going to look into why the tests are still passing

@@ -95,7 +90,7 @@ func m3ctlHealthCheck(w http.ResponseWriter, r *http.Request) {
// RegisterHandlers registers health handlers.
func (s *service) RegisterHandlers(router *mux.Router) {
log := s.iOpts.Logger()
router.HandleFunc("", m3ctlHealthCheck)
router.HandleFunc(s.URLPrefix(), m3ctlHealthCheck)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little confused as to why the health check was at the root, and how this worked, to begin with.

@jskelcy
Copy link
Contributor Author

jskelcy commented Nov 28, 2017

Fixed the health check issue. I didnt realize it was using a prefixed router.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.4%) to 49.356% when pulling 2fd77bb on js/config-r2ctrl-cover into 5dc4c6a on master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 28, 2017

Coverage Status

Coverage increased (+1.4%) to 49.356% when pulling 2fd77bb on js/config-r2ctrl-cover into 5dc4c6a on master.

@@ -42,18 +45,18 @@ func TestHealthCheck(t *testing.T) {
rr := httptest.NewRecorder()
// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
// pass 'nil' as the third parameter.
req := http.Request{Method: "GET", RequestURI: "/health"}
req, err := http.NewRequest("GET", "/health", bytes.NewBuffer(nil))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just pass nil as third arg here, no need to create a new buffer that never get's used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I figured that would error down the line somewhere but it looks like that totally works.

h.ResponseTime = time.Since(start)

h.Status = status
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a slight change to the functionality here where if there is a !ok status we return a 200 with the status as part of the body. Personally, I think this is helpful because you can convey information like being in a bootstrapping state, where the server is up but not ready to receive requests. It is also the case that we hardcode the status to be ok which means that under no circumstances can we return a 500 here anyway.

@coveralls
Copy link

coveralls commented Nov 28, 2017

Coverage Status

Coverage increased (+1.4%) to 49.356% when pulling 2df1160 on js/config-r2ctrl-cover into 5dc4c6a on master.

Copy link
Contributor

@m-sandusky m-sandusky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jskelcy jskelcy merged commit 9dc7cef into master Dec 1, 2017
@xichen2020 xichen2020 deleted the js/config-r2ctrl-cover branch December 13, 2017 18:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants