Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API testing #824

Merged
merged 117 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
8f7b6ab
First set of API refactor changes
Aug 27, 2020
d4c65fa
added pins route and Gzip
Aug 28, 2020
63cc3b7
first draft of legacy endpoints
Sep 1, 2020
8886ca7
fixing lint issues from flake8
Sep 1, 2020
35628ff
added support for deploying new API in Docker
Sep 2, 2020
bd4ef1e
new date parsing and config changes
Sep 2, 2020
cc995e0
more docker and config changes plus README
Sep 3, 2020
58a340a
default LEGACY_MODE to True
Sep 3, 2020
d1b5daf
DB seed needs database URL
Sep 3, 2020
e53dbab
YAML fix
Sep 3, 2020
f32f628
compose networking
Sep 3, 2020
11b9441
set test default config
Sep 3, 2020
aef7f67
updated missing .env.example settings
Sep 3, 2020
a4cb368
postman tests accept either 400 or 422 for bad input
jmensch1 Sep 3, 2020
5b916f8
comparison set validation
jmensch1 Sep 4, 2020
a1f94c7
model models and added simple entity cache
Sep 8, 2020
986ba3e
added cache status check
Sep 8, 2020
6ed9777
fixing flake8
Sep 8, 2020
1dcf5f5
disabling cache build
Sep 8, 2020
3911501
first version of alembic
Sep 9, 2020
d7bc8f3
added testing
Sep 11, 2020
e4b4fc7
updating ENV and requirements
Sep 11, 2020
69fec6c
turned testing off
Sep 11, 2020
5316119
test tweaks
Sep 11, 2020
d8379dd
dockerignore changes
Sep 11, 2020
fa68515
adding cwd to pythonpath
Sep 11, 2020
05ac6ab
fixed db env settings
Sep 11, 2020
0c473fa
setting db to test in env
Sep 11, 2020
c6e7a79
don't add _test to db name if there
Sep 11, 2020
b8795b9
more reliable tests
Sep 11, 2020
6126a68
more test cleanup
Sep 11, 2020
e9db6da
always add map/vis views
Sep 12, 2020
52baa31
replacing db tests
Sep 12, 2020
370de62
setting testing
Sep 12, 2020
8fe0c22
more test cleanup
Sep 12, 2020
6e62c67
fix flake8
Sep 12, 2020
40dac4e
updated libraries
Sep 12, 2020
3d2d5f7
slimming docker image
Sep 12, 2020
8170c3c
removed lru decorator
Sep 12, 2020
e44b669
logging response text on postman test failure
jmensch1 Sep 12, 2020
d603132
Merge branch 'add-alembic' of https://github.com/hackforla/311-data i…
jmensch1 Sep 12, 2020
193b5ca
postman logging
jmensch1 Sep 13, 2020
155350f
running CI on push
jmensch1 Sep 13, 2020
a9c970a
more postman logging
jmensch1 Sep 13, 2020
a66ea53
commented build_cache
jmensch1 Sep 13, 2020
a066a0c
linting
jmensch1 Sep 13, 2020
1f0df0f
logging 500 errors for all positive postman tests
jmensch1 Sep 13, 2020
f40a7cd
revert to 2 databases
Sep 16, 2020
60702ed
Merge branch 'add-alembic' of https://github.com/hackforla/311-data i…
Sep 16, 2020
7c05209
testing to false
Sep 16, 2020
2205bc7
remove views from db_seed
Sep 16, 2020
d846040
removed db reset
Sep 16, 2020
9c09fd5
added data file
Sep 16, 2020
070d75e
removing TESTING env
Sep 16, 2020
65a5335
removing from api.env
Sep 16, 2020
fa7de52
fixing flake8
Sep 16, 2020
8dc6a0b
error improvement
Sep 16, 2020
711b39f
1 more change
Sep 16, 2020
60589b0
undo docker compose change
Sep 16, 2020
d649c45
test database logging
Sep 18, 2020
a89155b
keep test db and new db fixture
Sep 20, 2020
a2698cf
seed file and better alembic logging
Sep 20, 2020
fd0e99c
adding env for seed
Sep 20, 2020
af2135d
fix env
Sep 20, 2020
d53f499
weird cluster fix
Sep 20, 2020
a59fe2f
LAST_WEEK to YEAR_TO_DATE in cypress
Sep 20, 2020
87ffbd0
type selector change
Sep 20, 2020
ebd5b1b
direct request type all
Sep 20, 2020
6829636
handling 10K+
Sep 20, 2020
46cd64a
adding coverage
Sep 20, 2020
8fc30d1
added async redis caching
Sep 22, 2020
2eabea3
flake fix
Sep 22, 2020
8dd1c75
turning off legacy mode
Sep 22, 2020
ac21516
added map/pins placeholder
Sep 22, 2020
0a8a262
added cache retries, timeout + pool changes
Sep 23, 2020
39c2c9f
api status check and test
Sep 23, 2020
9c1caab
adding sentry
Sep 23, 2020
559366a
sentry tweaks
Sep 23, 2020
efce220
remove weirdness
Sep 23, 2020
e846e9e
fixing requirements
Sep 23, 2020
c29a8ba
works with new UI, pins, open-requests
Sep 25, 2020
edc8616
fixed date format problem
Sep 25, 2020
1ecdfd3
using gunicorn for API
Sep 25, 2020
7f60721
added caching to open-request and reset-cache tool
Sep 29, 2020
3a26baa
porting github and email services
Oct 6, 2020
b6a2aed
refactor status service
Oct 6, 2020
1143401
utilities refactor
Oct 6, 2020
d49b8b9
ported reports
Oct 6, 2020
41a4763
fixed bug in time reports
Oct 7, 2020
8479dfc
removed legacy service calls
Oct 7, 2020
05ea638
made SENTRY URL configurable
mattyweb Oct 19, 2020
decee73
adding SENTRY URL
mattyweb Oct 19, 2020
229e9b4
added feedback test w/201 code
mattyweb Oct 19, 2020
bcf930b
minor refactoring and new routes
mattyweb Oct 19, 2020
0027fa7
added TODOs
mattyweb Oct 19, 2020
d1a27b2
adding prefect data loading
mattyweb Oct 23, 2020
a34d651
changes to action and cleanup
mattyweb Oct 23, 2020
60baab8
removing old view tests
mattyweb Oct 23, 2020
ad709cc
Merge branch 'dev' into new-api-testing
mattyweb Oct 23, 2020
a72cba8
added some test for requests
mattyweb Oct 24, 2020
e1fe4db
bug fixes incl. map/pins format
mattyweb Oct 24, 2020
2cea5b7
Merge branch 'new-api-testing' of https://github.com/hackforla/311-da…
mattyweb Oct 24, 2020
16bb876
remove metadata, add log table
mattyweb Oct 25, 2020
ea8b64c
log status call and bug fixes
mattyweb Oct 25, 2020
79ae6ae
fixed flake8
mattyweb Oct 25, 2020
68706b0
made request_id a serial integer
mattyweb Oct 26, 2020
8114c21
dev update job with SLACK_HOOK
mattyweb Oct 26, 2020
c394a63
using DEV slack secret
mattyweb Oct 26, 2020
9ddf3f0
improved cache reset, smaller open requests
mattyweb Oct 27, 2020
035f09e
refactor of request pins
mattyweb Oct 28, 2020
4415d6d
visualization performance, config, flake8
mattyweb Oct 29, 2020
ad987de
added first create release action
mattyweb Oct 30, 2020
5764818
small api/report tweaks
mattyweb Oct 30, 2020
c6074cd
make prefect easier to configure for devs
mattyweb Nov 2, 2020
1bf0073
improving comparison report performance
mattyweb Nov 2, 2020
5acb70d
new tests and fixes
mattyweb Nov 2, 2020
adb41d4
test fix
mattyweb Nov 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/Continuous_Integration_Backend.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CI_Backend

on:
pull_request:
paths:
- 'server/**'
on: [push]
# pull_request:
# paths:
# - 'server/**'

defaults:
run:
Expand All @@ -23,8 +23,8 @@ jobs:
docker-compose up --no-start api

- name: Seed DB and Run Api
run: |
docker-compose run api python bin/db_seed.py --file data/requests.csv.gz
run: |
docker-compose run -e TESTING=True api alembic upgrade head
docker-compose up -d api

- name: Linting
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/Daily_Backend_Update.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/Daily_Backend_Update_Dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Daily_Backend_Update_Dev

on:
schedule:
- cron: '0 7 * * *'

jobs:
dev_update:
runs-on: ubuntu-latest
steps:
- name: run update script on DEV environment
uses: appleboy/ssh-action@master
env:
PREFECT__CONTEXT__SECRETS__SLACK_HOOK: ${{ secrets.SLACK_HOOK_DEV }}
with:
username: ec2-user
host: ${{ secrets.AWS_SSH_HOST_DEV }}
key: ${{ secrets.AWS_SSH_PEM_KEY }}
envs: PREFECT__CONTEXT__SECRETS__SLACK_HOOK
script: |
cd 311-data/server
docker-compose run -e PREFECT__CONTEXT__SECRETS__SLACK_HOOK prefect python flow.py
- name: clear API cache with curl
uses: wei/curl@v1
with:
args: -X POST ${{ secrets.API_URL_DEV }}/status/reset-cache
21 changes: 21 additions & 0 deletions .github/workflows/Daily_Backend_Update_Prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Daily_Backend_Update_Prod

on:
schedule:
- cron: '10 7 * * *'

jobs:
prod_update:
runs-on: ubuntu-latest
steps:
- name: run update script on AWS prod
uses: appleboy/ssh-action@master
with:
username: ec2-user
host: ${{ secrets.AWS_SSH_HOST_PROD }}
key: ${{ secrets.AWS_SSH_PEM_KEY }}
command_timeout: 60m
script: |
set -e
cd 311-data/server
docker-compose run --rm api python bin/db_update.py
44 changes: 44 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Create Release
on:
push:
# Sequence of patterns matched against refs/tags
branches:
- 'release/v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
name: Create Release and Docker Images
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Branch name
uses: nelonoel/branch-name@v1
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.BRANCH_NAME }}
release_name: Release ${{ env.BRANCH_NAME }}
body_path: server/docs/release_notes.md
draft: false
prerelease: false
- name: Build and Push API to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
path: server/api
registry: docker.pkg.github.com
repository: hackforla/311-data/api
tags: latest, ${{ env.BRANCH_NAME }}
- name: Build and Push Prefect to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
path: server/prefect
registry: docker.pkg.github.com
repository: hackforla/311-data/prefect
tags: latest, ${{ env.BRANCH_NAME }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ yarn-error.log*
# config
config.js
.env

# builds
dist
14 changes: 7 additions & 7 deletions e2e/cypress/integration/e2e_tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('311 Data', () => {
const {_} = Cypress

context('Explore My Council\'s 311 Data', () => {
it('Map: Last Week, Dead Animal [DAN]', () => {
it('Map: Year-to-date, Dead Animal [DAN]', () => {

cy.server()
cy.route({
Expand All @@ -19,9 +19,9 @@ describe('311 Data', () => {
cy.get('.menu-tabs > :nth-child(1)').click()
cy.get('.active').click()
cy.get('.dropdown-trigger > .button').click()
cy.get('[value="LAST_WEEK"]').click()
cy.get('[value="YEAR_TO_DATE"]').click()
cy.get(':nth-child(2) > .select-group-content > .select-item > .select-item-box').click()
cy.get('#type-selector-container > div.columns.is-gapless > div:nth-child(1) > div:nth-child(2) > span > input').click({force: true})
cy.get('#checkbox-request-checkbox-all').click({force: true})
cy.get('#btn-sidebar-submit-button').click()

cy.wait('@getFilterList').should((xhr) => {
Expand All @@ -41,7 +41,7 @@ describe('311 Data', () => {
})
})

it('Data Visualization: Last Week, Dead Animal [DAN]', () => {
it('Data Visualization: Year-to-date, Dead Animal [DAN]', () => {

cy.server()
cy.route({
Expand All @@ -56,9 +56,9 @@ describe('311 Data', () => {
cy.get('.navbar-end > :nth-child(1)').click()
cy.get('.menu-tabs > :nth-child(2)').click()
cy.get('.dropdown-trigger > .button').click()
cy.get('[value="LAST_WEEK"]').click()
cy.get('[value="YEAR_TO_DATE"]').click()
cy.get(':nth-child(2) > .select-group-content > .select-item > .select-item-box').click()
cy.get('#type-selector-container > div.columns.is-gapless > div:nth-child(1) > div:nth-child(2) > span > input').click({force: true})
cy.get('#checkbox-request-checkbox-all').click({force: true})
cy.get('#btn-sidebar-submit-button').click()

cy.wait('@getFilterList').should((xhr) => {
Expand All @@ -81,7 +81,7 @@ describe('311 Data', () => {
cy.visit('/')
cy.get('#navbar > div > div:nth-child(2)').click()
cy.get('#date-selector-dropdown > .dropdown-trigger > .button').click()
cy.get('[value="LAST_WEEK"]').click()
cy.get('[value="YEAR_TO_DATE"]').click()
cy.get('.district-selector > :nth-child(1)').click()
cy.get('#district-selector-dropdown > .dropdown-trigger > .button').click()
cy.get('[value="nc"]').click()
Expand Down
6 changes: 5 additions & 1 deletion e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import '@testing-library/cypress/add-commands'
//import 'cypress-mailosaur'

Cypress.Commands.add('format_number_with_K', (value) => {
return ((value / 1000).toFixed(1)) + "K"
if (value > 9999) {
return ((value / 1000).toFixed(0)) + "K"
} else {
return ((value / 1000).toFixed(1)) + "K"
}
})

Cypress.Commands.add('format_number_with_comma', (value) => {
Expand Down
1 change: 1 addition & 0 deletions misc/workflows/End_To_End_Tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# DISABLED UNTIL: (1) we get more test coverage, and
# (2) the tests run against the code that's being pushed
# instead of the code already on dev
Expand Down
82 changes: 34 additions & 48 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,58 +1,44 @@

############################### API SETTINGS #############################

# Server
HOST=0.0.0.0
PORT=5000
DEBUG=0
ACCESS_LOG=1
AUTO_RELOAD=1
WORKERS=1
TMP_DIR=./__tmp__
UPDATE_ON_START=0

# Database
DATABASE_URL=postgresql://311_user:311_pass@db:5432/311_db
DATABASE_LOG_QUERIES=0

# Redis
REDIS_ENABLED=1
REDIS_URL=redis://redis:6379
REDIS_TTL_SECONDS=3600

# Picklebase
PICKLEBASE_ENABLED=0
PICKLEBASE_BATCH_SIZE=400000

# Picklecache
PICKLECACHE_ENABLED=0
PICKLECACHE_TTL_SECONDS=3600

# Socrata
SOCRATA_TOKEN=
SOCRATA_BATCH_SIZE=50000

# Github
######################### DOCKER-COMPOSE SETTINGS ########################

COMPOSE_PROJECT_NAME=311_data

# host/public configs 80/5432 in prod
API_HOST_PORT=5000
DB_HOST_PORT=5433

# api config
DEBUG=True
API_RESTART_POLICY=no
APP_PORT=5000

# db connection config
DB_HOST=db
DB_PORT=5432
DB_USER=311_user
DB_PASS=311_pass
DB_NAME=311_db_test
DB_ECHO=False

############################ PREFECT CONFIG ##############################

# to populate a new database for development uncomment:
# PREFECT__MODE=full
# PREFECT__DATA__YEARS=2020,2019

############################ 3RD PARTY TOOLS ##############################

# GitHub
GITHUB_TOKEN=
GITHUB_ISSUES_URL=https://api.github.com/repos/hackforla/311-data-support/issues
GITHUB_PROJECT_URL=
GITHUB_SHA=DEVELOPMENT

# Slack
SLACK_WEBHOOK_URL=
SLACK_ERROR_CODES=[400, 500]
GITHUB_CODE_VERSION=2.0.0-alpha

# Sendgrid
SENDGRID_API_KEY=

######################### DOCKER-COMPOSE SETTINGS ########################

COMPOSE_PROJECT_NAME=311_data
DB_USER=311_user
DB_PASS=311_pass
DB_NAME=311_db
DB_HOST_PORT=5433
API_HOST_PORT=5000
API_RESTART_POLICY=no
# Sentry
SENTRY_URL=https://[email protected]/5439266

################################# OVERRIDES ##############################
############################################################################
6 changes: 4 additions & 2 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*.env
.env

/api/__tmp__
__tmp__
/jmeter/out

__pycache__
.pytest_cache

__working__
Binary file added server/api/.coverage
Binary file not shown.
15 changes: 15 additions & 0 deletions server/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ignore
*

# Don't ignore
!requirements.txt

!Dockerfile
!README.md
!alembic
!alembic.ini
!bin
!code
!setup.cfg
!src
!tests
Loading