Commit Graph

161 Commits

Author SHA1 Message Date
Leo Hemsted
fcf3932bb4 Merge pull request #1418 from alphagov/remove-flask-script
Remove flask script
2017-11-24 10:28:56 +00:00
Alexey Bezhan
e813f1ff87 Add a script to fix migration ordering conflicts
When generating a new migration we give it a number that increments
the latest existing migration on master. This means that when there
are multiple PRs open containing a migration and one of them gets
merged the others need to be updated to move their migration files
to apply on top of the recently merged one.

This requires renaming the file and changing migration references
for both the migration revision and down_revision.

If a PR introduced more than 1 migration they all need to be updated
one after another since each one needs to be renamed.

This adds a script to simplify this process. `./scripts/fix_migrations.py`
will check for any branch points If it finds exactly one (which
should be the common case), it asks which migration should be moved
and renames / updates references to move the selected branch on top
of the other one.

It won't resolve any conflicts within migrations themselves (eg if
both branches modified the same column) and it won't try to resolve
cases with more than 1 branch.
2017-11-24 09:58:41 +00:00
Leo Hemsted
61b28ca523 update bootstrap to use new command 2017-11-23 17:12:13 +00:00
Leo Hemsted
9f56dccdee Remove flask-script, move commands to click
click (http://click.pocoo.org/) is used by flask to run its cli args.
In removing flask_script (it's unmaintained), we had to migrate all our
commands to use click. This is a change for the better in my eyes - you
don't need to define the command in several places, and it makes
managing options a bit easier.

View diff with whitespace turned off unless you're a masochist.
2017-11-23 17:04:58 +00:00
Leo Hemsted
8ef4e1e1da remove trailing underscore, which is sometimes created by alembic 2017-11-09 16:48:05 +00:00
Athanasios Voutsadakis
646290e2c4 Implement worker_abort server hook
Also update the manifest command to pass the config file in as a parameter
and modify the logs agent to start shipping the error log to cloudwatch
2017-09-22 15:03:45 +01:00
Leo Hemsted
e18e78180e update letter tests to use correct service
previously they were using sample_service fixture under the hood, but
with full permissions added - this works fine, **unless** there's
already a service with the name "sample service" in the database. This
can happen for two reasons:

* A previous test didn't tear down correctly
* This test already invoked the sample_service fixture somehow

If this happens, we just return the existing service, without modifying
its values - values that we might change in tests, such as
research mode or letters permissions.

In the future, we'll have to be vigilant! and aware! and careful! to
not use sample_service if we're doing tests involving letters, since
they create a service with a different name now
2017-09-21 11:50:49 +01:00
Leo Hemsted
c8ff45be2d don't create test db anymore, thats done in pytest 2017-09-20 11:21:27 +01:00
Athanasios Voutsadakis
4b88ec639f Remove * from logs matching pattern
Now we are only going to have one log file that we're interested in
2017-09-11 11:11:06 +01:00
Leo Hemsted
2fefe8a957 use sqlalchemy hooks rather than pyscopg2
seems to play nicer with docker?
2017-08-29 18:03:15 +01:00
Leo Hemsted
3d4dbaa632 run tests in multiple threads at once
previously we didn't do this because the tests all used the same DB
(test_notifications_api), however @minglis shared a snippet that simply
creates one test db per thread.
2017-08-29 17:46:11 +01:00
Leo Hemsted
4e7c19a98f update utils to v20 - log from multiple app.log*.json files
the rotating file handler puts the date on the end, so those old files won't be pushed
2017-08-25 14:38:04 +01:00
Leo Hemsted
e7b13e727a don't capture logs directly from stdout
previously in run_app_paas.sh, we captured stdout from the app and
piped that into the log file. However, this came up with a bunch of
problems, mainly:

* exceptions with stack traces often weren't formatted properly,
  and kibana could not parse them
* celery logs were duplicated - we'd collect both the json logs and
  the human readable stdout logs.

instead, with the updated utils library, we can use that to log json
straight to the appropriate directory directly.
2017-08-09 15:29:39 +01:00
Imdad Ahad
6da3d3ed0b Remove wheels-ing on deployment 2017-07-21 14:26:59 +01:00
minglis
033fe0f4dd Merge pull request #998 from alphagov/update-queues-script
Did some work around the delete queues script
2017-05-31 15:08:35 +01:00
Martyn Inglis
b98b97c4a2 Added a comment about delete queues 2017-05-31 15:06:21 +01:00
Martyn Inglis
68e15b57f5 Fixed pep8 2017-05-30 17:29:14 +01:00
Martyn Inglis
8f7afcdb16 Did some work around the delete queues script 2017-05-30 17:07:43 +01:00
Imdad Ahad
a58e724d21 Add a script and make command to detect if there are any migration changes 2017-05-26 16:44:23 +01:00
Imdad Ahad
586c83a2c7 Add a script to delete sqs queues:
* Uses boto to retrieve/delete queues
* Additional functions to output/read from csv
2017-05-25 13:33:26 +01:00
bandesz
bacce90ac2 PaaS run script: redirect stderr to stdout 2017-03-21 15:03:03 +00:00
bandesz
b453dd59d0 Add termination timeout to run_app_paas.sh 2017-02-28 17:39:04 +00:00
imdadahad
4ac6043701 Revert "Ensure all wheels are installed offline from the wheelhouse directory" 2017-02-23 16:43:09 +00:00
imdadahad
1254008e2e Merge pull request #831 from alphagov/feat-install-all-wheels-offline
Ensure all wheels are installed offline from the wheelhouse directory
2017-02-23 15:58:12 +00:00
bandesz
72dc93c6db Add awslogs logging for PaaS 2017-02-16 17:38:30 +00:00
Imdad Ahad
79ae0219e6 Ensure all wheels are installed offline from the wheelhouse directory 2017-02-15 16:57:44 +00:00
Imdad Ahad
2e4b09154e Remove verbose logging of directory creation 2017-02-14 11:37:47 +00:00
Imdad Ahad
5ac3643d9d Cancel uninstalling all py3 packages 2017-02-14 11:36:38 +00:00
Imdad Ahad
383553b964 Remove notify app folder and installed python packages before we deploy the app 2017-02-13 17:13:39 +00:00
Martyn Inglis
19fd4b3ce9 Log which file we're trying to stop. 2017-02-08 16:58:26 +00:00
Martyn Inglis
a7cfaf3f13 Better logging for multiple instances running. 2017-02-08 16:35:09 +00:00
Martyn Inglis
703e12e516 Code style check passed. 2017-02-08 16:26:12 +00:00
Martyn Inglis
5d0bc0abe8 Add a stop celery script into the scripts folder.
Stopping celery via upstart issues a TERM signal to the whole process group, which immediately kills the worker threads. This can lead to inconsistentcy in the state of a notification as an API call, for example, can take several seconds consequently the likelihood of the call being lost due to a restart is relatively high.

We need to ensure that we stop cleanly to ensure code deploys and autoscale events do not cause issues.

this script is called as part of a pre-stop hook in upstart, which passes a pid file location to the script. The script will then issues the TERM signal to only the master celery process. which will cleanly shut down the workers and exit.

the script will loop based on the existence of a /proc/{pid} for the celery master process. Once the file is gone the script will exit. Upstart blocks on this script before issuing kill on whatever processes may be left hanging around.

the length of the loop is a maximum 15 minutes - which is the tested max time a task may take. In reality it will exit much quicker.
2017-02-08 16:17:50 +00:00
Chris Hill-Scott
c2999ed5ad Use pycodestyle instead of PEP8
PEP8 was renamed to pycodestyle; this issue explains why:
https://github.com/PyCQA/pycodestyle/issues/466

This commit changes our tests to use pycodestyle instead of pep8.

It also means:
- making a couple of whitespace changes to appease the linter
- disabling warnings for bare `Except`s (ie `Except` instead of `Except
  ValueError`) – this seems like a sensible thing to catch but I’m not
  going to make meaningful code changes in this commit
2017-02-01 09:19:32 +00:00
Rebecca Law
4e4afc5d0b Rename test with duplicate name 2017-01-27 15:21:59 +00:00
Imdad Ahad
177515de8f Use python wheels to speed up AS deployment:
* Create wheels from python dependencies on building codedeploy artifact
* Update script to install wheels and default to pypi if not found
2016-10-21 16:16:10 +01:00
Peter Chamberlin
b0d0a5627d Use make to generate version file 2016-10-04 12:03:07 +01:00
Peter Chamberlin
1539a527e6 Updated bootstrap to copy version.py.dist as required 2016-10-04 11:13:43 +01:00
Martyn Inglis
19f2a6cb65 Added stop for research mode worker 2016-09-30 11:25:12 +01:00
Martyn Inglis
6ce85878d8 Added start for research mode worker 2016-09-30 11:23:54 +01:00
bandesz
8ab7fa3395 Build db migration codedeploy artifact 2016-09-21 11:21:12 +01:00
Leo Hemsted
b294568a91 Merge pull request #653 from alphagov/junit-test-results
add junit xml reporting to pytest
2016-09-02 09:38:01 +01:00
Leo Hemsted
00cac0f88b add junit xml reporting to pytest
also add file location to gitignore preemptively
2016-08-31 15:03:28 +01:00
Martyn Inglis
ce006bd92d Start/Stop the new worker scripts on the code deploy actions. 2016-08-31 11:40:47 +01:00
Leo Hemsted
7835339165 Merge branch 'master' into test-fixes 2016-08-26 10:57:41 +01:00
bandesz
9b4188f05a Travis cleanup: remove deploy + functest trigger 2016-08-25 16:19:52 +01:00
Leo Hemsted
9d624ef280 prevent errors if user has no venv setup at all 2016-08-23 13:56:10 +01:00
Leo Hemsted
a3843053cd improved local test-running ability
call generate-version-file before tests, since they'll fall over if the version file isn't present
use /Users/leohemsted/.virtualenvs/api rather than looking for ./venv/ - if there's some other venv already active, then don't try and look for a current venv to activate
2016-08-23 12:17:56 +01:00
bandesz
68c1135379 Create Docker build image, build project with Docker 2016-08-22 17:25:41 +01:00
Martyn Inglis
e606202a08 Increase ELB wait time 2016-07-29 10:15:34 +01:00