Add in a fixed percentage of 500 errors in responses.
This commit is contained in:
parent
acd728efcf
commit
bbb2ac1fc4
1 changed files with 7 additions and 0 deletions
|
@ -43,6 +43,13 @@ func (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
log := r.Context().Value(ctxKeyLog{}).(logrus.FieldLogger)
|
log := r.Context().Value(ctxKeyLog{}).(logrus.FieldLogger)
|
||||||
log.WithField("currency", currentCurrency(r)).Info("home")
|
log.WithField("currency", currentCurrency(r)).Info("home")
|
||||||
currencies, err := fe.getCurrencies(r.Context())
|
currencies, err := fe.getCurrencies(r.Context())
|
||||||
|
|
||||||
|
// NOTE: This artificially injects failures in a fixed percentage of the responess
|
||||||
|
if (rand.Intn(100) < 3) {
|
||||||
|
renderHTTPError(log, r, w, errors.Wrap(err, "Random artificial 500 error"), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve currencies"), http.StatusInternalServerError)
|
renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve currencies"), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue