Commit Graph

154 Commits

Author SHA1 Message Date
Ken Tsang
7011b90bd4 Refactor is_precompiled_letter to model 2018-03-07 23:03:03 +00:00
Richard Chapman
271e157d1a Merge pull request #1737 from alphagov/add_precompiled_letters
Updated API to handle pre-compiled pdfs
2018-03-06 08:39:49 +00:00
Richard Chapman
a4feaba309 Added tests to tests for precompiled flow and refactored a little
* Added is_precompiled_letter method to letter/utils.py
* Added tests for letter/utils.py
* Added tests for the rest endpoint
* Moved the Precompiled name to a central location
* Added hidden field to the test method to create a template
2018-03-05 14:11:37 +00:00
Rebecca Law
c474b2312b Process responses for letters even after the notification has been deleted.
This will continue to update the notification history for letter notifications.
We currently have an issue where the responses to letters from the provider is taking a long time.
This is due to the manual nature of their process.
Updating the status of the letter will still work if the notification has been purged.

Also turned back on the purge letter notification scheduled task.
2018-03-02 11:29:22 +00:00
Rebecca Law
bffc4863db Remove all methods no longer used now that we only send pdf files to DVLA. 2018-03-02 11:05:05 +00:00
Rebecca Law
be7989bbc9 Suspend the delete-letter-notifications scheduled job.
We have an issue with the provider. If we need to resend these letters, we need the notification.
2018-03-01 11:47:00 +00:00
Leo Hemsted
5b71d2f36e add org invite template to db 2018-02-23 10:45:18 +00:00
Leo Hemsted
c52ca3e7bb Merge pull request #1681 from alphagov/fix-test-db
make sure tests always run in test db
2018-02-22 16:54:57 +00:00
Athanasios Voutsadakis
c61ed043b3 Ensure pool size is an integer 2018-02-22 10:27:02 +00:00
Leo Hemsted
ee1be970fc make test config inherit from dev config
gets some secret keys and things set up for free
2018-02-21 18:42:24 +00:00
Leo Hemsted
073c48a0a7 move all static env vars from env.sh to config file in dev
There's no reason to have things that never change in environment.sh.
you'll want to update your environment.sh, then restart your shells
(`exec bash` or `exec zsh` etc)

This also changes the database to be set statically in the config, but
overridable from the command line if you need to - for example, jenkins
will override it with the dockerised postgres uri.
2018-02-21 18:12:03 +00:00
Athanasios Voutsadakis
dc19e644a6 Increase DB connection pool size to 10
This is to address some errors we saw yesterday such as:

`sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10
reached, connection timed out, timeout 30`

Related flask-sqlalchemy docs:
http://flask-sqlalchemy.pocoo.org/2.3/config/#configuration-keys
2018-02-21 15:47:58 +00:00
Rebecca Law
e736c90d00 Switch to using the pdf letter flow.
When sending letters always use the pdf letter flow regardless of service permissions.
2018-02-13 18:38:32 +00:00
Richard Chapman
49d69a84d9 Changed the time of the task to run at 00:05 as the query gets data for
the day before 0:00, so to minimise the report being out of date run the
query at 0:05.
2018-01-26 09:56:53 +00:00
Alexey Bezhan
5298f28f80 Add utils DeskproClient and configuration variables
Deskpro client is used to create tickets from celery alerting tasks
(eg alerts for missing ack or response files from DVLA).
2018-01-17 15:04:17 +00:00
venusbb
24b785e7e0 Added process for dvla acknowledgement file
Daily schedule task to check ack file against zip file lists
if we haven't receive ack for a zip file, raise a 500 exception
2018-01-12 15:44:00 +00:00
Rebecca Law
9c4e43bfac Some pseudo code and notes of how to implement a check for the letter acknowledgement file. 2018-01-11 16:37:39 +00:00
Katie Smith
b07db16cd1 Get rate limit from service.rate_limit column (not config)
PR #1550 added the rate_limit column to the Service table.

This PR removes the rate limits from the config and uses rate_limit from
the Service model instead. Rate limits are still separated into 'team',
'normal' and 'test', but these values are the same for a service.

Pivotal story https://www.pivotaltracker.com/story/show/153992529
2018-01-11 10:28:11 +00:00
Alexey Bezhan
d82801fa5d Remove unused PERFORMANCE_PLATFORM_TOKEN config variable 2018-01-09 10:45:03 +00:00
Richard Chapman
b90ee832a7 Moved the SQL Alchemy config from staging to all environments
During database upgrades and database fail overs there has been errors
because the database connection stays open, when a query is run the
query fails and the connection is re-established. To avoid these errors
shorter timeouts have been used to keep the connections from getting
stale.

-  SQLALCHEMY_POOL_TIMEOUT timeout idle connections after 30 secs
- Updated SQLALCHEMY_POOL_RECYCLE to recycle the connection every 5 mins

See guide on optimistic disconnect handling - using the pool recycle
as a way to manage this:
http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-optimistic
2018-01-05 05:53:40 +00:00
Katie Smith
644b110a8d Group letters into a max number of files for sending to DVLA
Grouping the letters into a maximum number of files is necessary because
the SQS task needs to be under a certain size. We also compress the task
when sending.
2018-01-03 11:31:22 +00:00
Leo Hemsted
309b4d7d33 add collate-letter-pdfs task
add collate-letter-pdfs task (name pending). This retrieves a list of
letter pdf files (just the metadata, not the actual data) from s3, and
loops through them, calling the ftp task zip-and-send-letter-pdfs. It
groups them up by adding them to lists while counting the total
filesize, if it gets over a certain filesize (currently set to 500mb)
it breaks at that chunk, sends off that list of files to the ftp app,
and then starts building up a new list.

DVLA have a hard 2gb limit on how big the zip files we can send is -
however we're going to be limited by the amount of memory on the ftp
app well before we get around to handling 2gb of pdf data - so the
limit is 500mb for now. We'll adjust it after we see how ftp performs.
2018-01-02 10:39:21 +00:00
Richard Chapman
20d5a946f6 Add back in SQLALCHEMY config changes on staging
SQL Alchemy config changes were made to decrease the downtime of the
application. The last test only had 1 min of downtime in the upgrade
period i.e. 40 mins. Tested without the config changes to double
check the change had the desired effect. Adding back in so we can test
the changes under load and performance test outside of upgrade.
2017-12-22 08:21:53 +00:00
Ken Tsang
3ca97f67c9 Change live-letters-pdf to production-letters-pdf 2017-12-21 14:57:37 +00:00
Richard Chapman
66ae4ea9f2 Revert the SQLALCHEMY config changes on staging
SQL Alchemy config changes were made to decrease the downtime of the
application. The last test only had 1 min of downtime in the upgrade
period i.e. 40 mins. Reverting the changes so that the same process
can be followed to ensure the changes had the desired effect.
2017-12-21 11:31:38 +00:00
Richard Chapman
2bc4c8ac39 Added SQLALCHEMY settings to staging for db connections
- Updated SQLALCHEMY_POOL_TIMEOUT timeout idle connections after  30 secs
- Updated SQLALCHEMY_POOL_RECYCLE to receyle the connection every 5 mins
2017-12-20 14:22:23 +00:00
Ken Tsang
8103540261 Renamed run-letter-pdfs to trigger-letter-pdfs-for-day
- also set optional date_to_process argument for dao_get_count_of_letters_to_process_for_date to None, so it's set in the code instead
2017-12-19 13:23:55 +00:00
Ken Tsang
441651bbd1 Add get_count_of_letters_to_process to notifications_dao
- will get the letter notifications from day before >= letter processing deadline (17:30)
- letters_as_pdf permission is required in the service
2017-12-19 13:23:55 +00:00
venusbb
ab66f5c0ac Change MMG username to look at env variable 2017-12-15 12:19:58 +00:00
venusbb
2e6c46c163 Merge branch 'master' of https://github.com/alphagov/notifications-api into add-mmg-inbound-sms-auth 2017-12-15 09:15:49 +00:00
Ken Tsang
0ad43f0c5b Create letters pdf queue was renamed with tasks, but was lost in another merge
- needs to be correct name otherwise the delivery worker will not pick up the queue
2017-12-14 16:00:51 +00:00
Katie Smith
a8d3b0952f Add MMG_INBOUND_SMS_AUTH config variable and auth check
Checks authentication header value on inbound SMS requests from
MMG  against a list of allowed API keys set in the application
config.

At the moment, we're only logging the attempts without aborting the
requests. Once this is rolled out to production and we've checked
the logs we'll switch on the aborts and add the tests for 401 and 403
responses.

This work has already been done for Firetext in a previous PR:
https://github.com/alphagov/notifications-api/pull/1409
2017-12-14 13:37:50 +00:00
venusbb
11152ab117 Add new queue for callbacks 2017-12-13 10:57:08 +00:00
Ken Tsang
ebfd78f3cf Add template preview host url and key to cf config 2017-12-12 14:53:38 +00:00
Ken Tsang
6b118ec1ef Add create-letters-pdf queue name 2017-12-12 12:07:55 +00:00
Ken Tsang
c8a434fe98 Updated config for template preview env vars 2017-12-12 12:07:55 +00:00
Richard Chapman
af1ab437be Revert changes to staging for performance tests and increased rate limit
- Reverted the Gunicorn worker number to 5 (this should be investigated
further on a well baselined system to compare)
- Enabled REDIS
- Increased the rate limit to 400 req/sec as using early testing
yesterday 450+ was being achieved
2017-12-06 09:38:31 +00:00
Ken Tsang
d62b350fcb Add config for letters pdf s3 bucket different environments 2017-12-04 16:29:04 +00:00
Athanasios Voutsadakis
c2228bb7d2 Enable proxy header check on live 2017-12-04 16:14:30 +00:00
Richard Chapman
5f25d3162a Disable Redis for Staging added statsd for post methods
- Disable Redis as there is a current connection limit of 256 which
 could slow down the request if they are all used
 - Added statd to methods in the post to help spot any bottlenecks
2017-12-01 15:41:53 +00:00
Rebecca Law
3b1112d4e4 Remove SQLALCHEMY_ECHO for test 2017-11-29 15:15:03 +00:00
Rebecca Law
39950c47bc Remove \t 2017-11-29 14:30:02 +00:00
Athanasios Voutsadakis
a2aa9c7e32 Bump staging rate limit in preparation for Load Tests 2017-11-23 14:35:36 +00:00
Alexey Bezhan
5e53d781e0 Add FIRETEXT_INBOUND_SMS_AUTH config variable and auth check
Checks authentication header value on inbound SMS requests from
Firetext against a list of allowed API keys set in the application
config.

At the moment, we're only logging the attempts without aborting the
requests. Once this is rolled out to production and we've checked
the logs we'll switch on the aborts and add the tests for 401 and 403
responses.
2017-11-22 09:54:42 +00:00
Athanasios Voutsadakis
0886f6d9f9 Merge branch 'master' into add_proxy_header_check 2017-11-16 16:36:02 +00:00
Richard Chapman
e7de0c0900 Added a template_type to the rest call
Added a template type which is required for the admin UI and updated the
tests. The rest tests needed updated because of the bug fix for
aggregation.
2017-11-16 15:17:27 +00:00
Athanasios Voutsadakis
5d687d87e7 Enable header checking on preview and staging, add test 2017-11-16 12:02:09 +00:00
Richard Chapman
17d1cfe758 Reverted Config on SQLALCHEMY_ECHO
Used for debugging not needed for production so reverted.
2017-11-15 16:00:13 +00:00
Richard Chapman
1e4850b70f Add Template name to response and filter by year
The template name should be returned for the response and the user will
pick a year, so ths adds those two features to the
notifications/templates_usage/monthly endpoint and added some tests to
test the functionality.
2017-11-15 15:55:00 +00:00
Richard Chapman
c27edf5e3c Added new endpoint to get the new template stats
Added a new endpoint which combines the usage of the stats table and the
data from the notifications tables, instead of using all the data from
the notification_history table. This should speed up the query times
and improve the page performance.

- Updated to make the stats create and update function transactional as
it actually wasn't committing the data to the table
- Added the get from the stats table
- Add a a method to combine the two results
- Added the endpoint
2017-11-15 12:58:39 +00:00