|
|
---
|
|
|
title: Test Suite
|
|
|
keywords: current, activities, , pycast, test, testing
|
|
|
folder: pycast
|
|
|
---
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
The test suite for ShakeCast was designed to address isssues relating to monitoring of state-of-health and troubleshooting once the application is operational.
|
|
|
|
|
|
Before running the test suite, configure a username and password for pyCast to use. For some SMTP servers (GMail included) you'll need to configure this email account to be accessable from "less secure" applications with an [App-specific Password](https://support.google.com/accounts/answer/185833?hl=en). This should be a setting offered by your email provider. If you've already configured your pyCast instance with an email address, you can skip this step.
|
|
|
|
|
|
~~~
|
|
|
export SHAKECAST_SMTP_SERVER='smtp.server'
|
|
|
export SHAKECAST_SMTP_SECURITY='TLS'
|
|
|
export SHAKECAST_SMTP_PORT=587
|
|
|
export SHAKECAST_SMTP_USERNAME='username'
|
|
|
export SHAKECAST_SMTP_PASSWORD='app_password'
|
|
|
export SHAKECAST_SMTP_FROM='your@email.address'
|
|
|
~~~
|
|
|
|
|
|
Now you can test the email servive (or interactively via an IDE)
|
|
|
:
|
|
|
~~~
|
|
|
python -c "from shakecast.app.servertestfunctions import smtp_test; smtp_test()"
|
|
|
~~~
|
|
|
|
|
|
### Daily Heartbeat
|
|
|
The simplest form of state-of-health monitoring is to receive the automated daily heartbeat generated by the ShakeCast application. To enable this notification,
|
|
|
|
|
|
1. Create a notification group for the event type "HEARTBEAT" from a ShakeCast Workbook.
|
|
|
2. Add users to this group.
|
|
|
3. Upload the heartbeat group and user XML's into the ShakeCast database (web interface).
|
|
|
|
|
|
### Test Event (via Web Interface and Command Line)
|
|
|
The end-to-end system functional test can be manually triggered via the web interface with administrative privileges or interactively from command line/IDE.
|
|
|
|
|
|
The system test consists of three sub-tests, URL, DB, and SMTP. To run the tests or to troubleshoot the application interactively:
|
|
|
~~~
|
|
|
python -c "from shakecast.app.servertestfunctions import system_test; system_test()"
|
|
|
|
|
|
#Test URL connection to USGS web server
|
|
|
python -c "from shakecast.app.servertestfunctions import url_test; url_test()"
|
|
|
#Test DB connection for local ShakeCast server
|
|
|
python -c "from shakecast.app.servertestfunctions import db_test; db_test()"
|
|
|
#Test SMTP connection of remote SMTP server
|
|
|
python -c "from shakecast.app.servertestfunctions import smtp_test; smtp_test()"
|
|
|
~~~
|
|
|
|
|
|
### Comprehensive Test Bundle (Functions and Features)
|
|
|
The test bundle is mainly used as part of the CI/CD workflow to validate code chages. It can also be invoked by the end user to examine the inner working of the application for specific modules and functions. It is advised to run the bundle or individual tests from an IDE in order to capture the output.
|
|
|
~~~
|
|
|
python -m shakecast.tests.bundle
|
|
|
~~~
|
|
|
Individual test cases:
|
|
|
- API (shakecast.tests.api)
|
|
|
- Event Processing (shakecast.tests.eventprocessing)
|
|
|
- ShakeMap Grid (shakecast.tests.grid)
|
|
|
- AEBM Impact Assessment (shakecast.tests.impact)
|
|
|
- Inventory Processing (shakecast.tests.inventory)
|
|
|
- SQL/JSON Encoder (shakecast.tests.jsonencoders)
|
|
|
- Notification (shakecast.tests.notifications)
|
|
|
- ORM (shakecast.tests.orm)
|
|
|
- Earthquake Product Download (shakecast.tests.productdownload)
|
|
|
- Product Generation (shakecast.tests.productgeneration)
|
|
|
- ShakeCast Server (shakecast.tests.server_test)
|
|
|
- SMTP Server (shakecast.tests.smtpserver) |