diff --git a/src/loadgenerator/.gitignore b/src/loadgenerator/.gitignore new file mode 100644 index 0000000..f9b48b3 --- /dev/null +++ b/src/loadgenerator/.gitignore @@ -0,0 +1 @@ +credentials.py diff --git a/src/loadgenerator/Dockerfile b/src/loadgenerator/Dockerfile index b894dc5..60932ec 100644 --- a/src/loadgenerator/Dockerfile +++ b/src/loadgenerator/Dockerfile @@ -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 diff --git a/src/loadgenerator/loadgen.sh b/src/loadgenerator/loadgen.sh index 4a0f35e..97ca0dc 100755 --- a/src/loadgenerator/loadgen.sh +++ b/src/loadgenerator/loadgen.sh @@ -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 diff --git a/src/loadgenerator/locustfile.py b/src/loadgenerator/locustfile.py index b134538..c20c6d8 100644 --- a/src/loadgenerator/locustfile.py +++ b/src/loadgenerator/locustfile.py @@ -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', diff --git a/src/loadgenerator/requirements.txt b/src/loadgenerator/requirements.txt index 7cd1fc2..3d2cebe 100644 --- a/src/loadgenerator/requirements.txt +++ b/src/loadgenerator/requirements.txt @@ -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