-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from CSCI-5828-S24/stage
Monitoring added
- Loading branch information
Showing
11 changed files
with
144 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,3 +85,5 @@ def collect(request): | |
return "done!!" | ||
|
||
|
||
if __name__=="__main__": | ||
collect(None) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
Initial Creation of back end for HW5 Testing CI/CD | ||
## Flask Backend | ||
|
||
This Backend host both the APIs and web pages for the web-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
exceptiongroup==1.2.1 | ||
idna==3.7 | ||
iniconfig==2.0.0 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
pytest==8.2.0 | ||
python-dateutil==2.9.0.post0 | ||
requests==2.31.0 | ||
pytest==8.2.0 | ||
six==1.16.0 | ||
tomli==2.0.1 | ||
urllib3==2.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,43 @@ | ||
from datetime import datetime | ||
import time | ||
import requests | ||
from dateutil.relativedelta import relativedelta | ||
|
||
BACKEND_URL = "https://betafish-flask-backend-3asud65paa-uc.a.run.app/" | ||
BACKEND_URL = "https://betafish-flask-backend-3asud65paa-uc.a.run.app" | ||
COLLECTOR_URL = "https://us-central1-csci-5828-final-project.cloudfunctions.net/betafish-collector" | ||
ANALYZER_URL = "https://us-central1-csci-5828-final-project.cloudfunctions.net/betafish-analyzer" | ||
|
||
def test_backend_is_deployed_and_healthy(): | ||
response = requests.get(BACKEND_URL + "/api/health") | ||
assert response.status_code is 200 | ||
assert response.status_code == 200 | ||
|
||
def test_backend_is_not_storing_beyond_31_days(): | ||
timeToFilter = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) - relativedelta(days=33) | ||
startReportedDateFilter = int(time.mktime(timeToFilter.timetuple()) * 1000) | ||
timeToFilter = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) - relativedelta(days=32) | ||
endReportedDateFilter = int(time.mktime(timeToFilter.timetuple()) * 1000) | ||
response = requests.get(BACKEND_URL + f"/api/alldata?startTime={startReportedDateFilter}&endTime={endReportedDateFilter}&lat=39.74956044238265&long=-104.95078325271608&pageno=1&pagesize=20") | ||
assert len(response.json()['data']) == 0 | ||
assert response.status_code == 200 | ||
|
||
# premise: there will always be at least one crime each day | ||
def test_backend_is_storing_for_last_30_days(): | ||
timeToFilter = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) - relativedelta(days=30) | ||
startReportedDateFilter = int(time.mktime(timeToFilter.timetuple()) * 1000) | ||
timeToFilter = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) - relativedelta(days=29) | ||
endReportedDateFilter = int(time.mktime(timeToFilter.timetuple()) * 1000) | ||
response = requests.get(BACKEND_URL + f"/api/alldata?startTime={startReportedDateFilter}&endTime={endReportedDateFilter}&lat=39.74956044238265&long=-104.95078325271608&pageno=1&pagesize=20") | ||
assert len(response.json()['data']) > 0 | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_collector_prod(): | ||
response = requests.get(COLLECTOR_URL) | ||
assert response.text == "done!!" | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_analyzer_prod(): | ||
response = requests.get(ANALYZER_URL) | ||
assert response.text == "success" | ||
assert response.status_code == 200 |
Oops, something went wrong.