Add rollbar configuration to loadgenerator

This commit is contained in:
Letania Ferreira 2020-10-12 14:29:02 -07:00
parent fee184176f
commit a01a60fb9e
5 changed files with 24 additions and 3 deletions

1
src/loadgenerator/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
credentials.py

View file

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM python:3-slim as base
FROM python:3.6-slim as base
FROM base as builder
@ -22,6 +22,8 @@ RUN apt-get -qq update \
COPY requirements.txt .
#RUN python -m pip install --force-reinstall pip==20.1.1
#RUN pip install --install-option="--prefix=/install" -r requirements.txt
RUN pip install --prefix="/install" -r requirements.txt
FROM base

View file

@ -25,11 +25,15 @@ fi
set -x
# if one request to the frontend fails, then exit
STATUSCODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" http://${FRONTEND_ADDR})
STATUSCODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" ${FRONTEND_ADDR})
#revert line above to the following if running all microservices together or http
#STATUSCODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" http://${FRONTEND_ADDR})
if test $STATUSCODE -ne 200; then
echo "Error: Could not reach frontend - Status code: ${STATUSCODE}"
exit 1
fi
# else, run loadgen
locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" 2>&1
locust --host="${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" 2>&1
#revert line above to the following if running all microservices together or http
#locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" 2>&1

View file

@ -16,6 +16,19 @@
import random
from locust import HttpLocust, TaskSet, between
import credentials
import rollbar
rollbar.init(credentials.POST_SERVER_ITEM_ACCESS_TOKEN, 'production') # access_token, environment
try:
main_app_loop()
except IOError:
rollbar.report_message('Got an IOError in the main loop', 'warning')
except:
# catch-all
rollbar.report_exc_info()
# equivalent to rollbar.report_exc_info(sys.exc_info())
products = [
'0PUK6V6EV0',

View file

@ -19,6 +19,7 @@ markupsafe==1.1.0 # via jinja2
msgpack-python==0.5.6 # via locustio
pyzmq==17.0.0 # via locustio
requests==2.21.0 # via locustio
rollbar
six==1.12.0 # via geventhttpclient-wheels, locustio
urllib3==1.24.2 # via requests
werkzeug==0.14.1 # via flask