-
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 #47 from CSCI-5828-S24/dev
Monitoring added
- Loading branch information
Showing
19 changed files
with
196 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: integration-test | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
run-python-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
working-directory: ./integration-test | ||
run: python -m pip install -r requirements.txt | ||
- name: Test with pytest | ||
working-directory: ./integration-test | ||
run: python -m pytest |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: playwright-acceptance-test | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
run-python-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
working-directory: ./playwright-acceptance-test | ||
run: python -m pip install -r requirements.txt | ||
- name: Install playwright | ||
working-directory: ./playwright-acceptance-test | ||
run: python -m playwright install --with-deps | ||
- name: Test with pytest | ||
working-directory: ./playwright-acceptance-test | ||
run: python -m pytest |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Folder for housing integration tests for determining if services are up and running. |
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 |
---|---|---|
@@ -0,0 +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 | ||
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 |
---|---|---|
@@ -0,0 +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" | ||
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 == 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 |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Playwright tests that interact with deployed application to test user functionality | ||
|
||
https://playwright.dev/python/ |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest-playwright==0.4.4 |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import re | ||
from playwright.sync_api import Page, expect | ||
|
||
def test_home_page_has_title(page:Page): | ||
page.goto("https://betafish-flask-backend-3asud65paa-uc.a.run.app/") | ||
expect(page).to_have_title(re.compile("Denver Crime Tracker")) | ||
|
||
def test_click_analytics_changes_display(page:Page): | ||
page.goto("https://betafish-flask-backend-3asud65paa-uc.a.run.app/") | ||
|
||
page.get_by_text("Analytics").click() | ||
expect(page.locator("#first-chart")).to_be_visible() | ||
expect(page.locator("#second-chart")).to_be_visible() | ||
|
||
def test_search_returns_results(page:Page): | ||
page.goto("https://betafish-flask-backend-3asud65paa-uc.a.run.app/") | ||
expect(page.locator("tbody")).to_contain_text("-") | ||
page.get_by_label("Start date").fill("2024-03-01") | ||
page.get_by_role("button", name="Search").click() | ||
expect(page.get_by_role("cell", name="4/25/").first).to_be_visible() | ||
|
||
def test_search_adds_icon_to_map(page:Page): | ||
page.goto("https://betafish-flask-backend-3asud65paa-uc.a.run.app/") | ||
page.get_by_label("Start date").fill("2024-03-01") | ||
page.get_by_role("button", name="Search").click() | ||
expect(page.locator(".leaflet-pane > img:nth-child(2)")).to_be_visible() |
Oops, something went wrong.