351 Commits

Author SHA1 Message Date
leigh-mil
c2814416fb Update atst to atat 2020-03-04 11:51:15 -05:00
graham-dds
108f65f928 Use pendulum for datetime operations when possible
Currently, we use both Python's built-in datetime library and Pendulum
to do datetime operations. For the sake of consistency, we should try to
stick to one library for datetimes. We could have used either, but
Pendulum has a more ergonomic API, so I decided to go with it when
possible.

The places where were we didn't / couldn't replace datetime are:
- checking instances of datetimes. Pendulum's objects are subclasses of
  python native datetime objects, so it's still useful to import
  datetime in those cases of using is_instance()
- WTForms date validators expect datetime style string formats --
  Pendulum has its own format for formatting/ parsing strings. As such,
  our custom validator DateRange needs to use datetime.stptime() to
  account for this format.
2020-02-17 10:38:52 -05:00
graham-dds
321b0a9cd4 Fix upcoming TO PoP bug in seed_sample
Some kwargs were in the wrong places
2020-02-11 14:27:30 -05:00
dandds
0142151558 Database user needs to own tables and sequences.
This change allows the newly made database user to apply migrations.

It also includes a very Azure-specific change. Say we have an Azure
Postgres database user "root", which is the user making the database
connections for this script, and it is creating an "atat" user/role.
That root user will be a member of the azure_pg_admin group. In order
for root to change the ownership of the tables in the database to
atat, it needs to have membership in the atat role. To achieve this we
grant azure_pg_admin the atat role.
2020-02-09 10:40:46 -05:00
dandds
46643f7f41 Config for JEDI dev cluster.
- Transition to VMSS identity for flexvol
- Update some environment variables for cloudzero dev
- Overlay for applying migrations
- Updates to disable CDN, which will not be available
- Removes CronJob for resetting the database; don't need that in this
  cluster for now.
2020-02-08 15:06:43 -05:00
dandds
adacb6ff19 Cleanup cruft 2020-01-27 13:17:09 -05:00
dandds
058ee57527 Create database with separate script.
Creating the ATAT database requires a separate connection to one of the
default Postgres databases, like `postgres`. This updates the scripts
and secrets-tool command to handle creating the database. It also
removes database creation from Terraform and updates the documentation.
2020-01-27 13:17:09 -05:00
dandds
a8f6befc17 secrets-tool command for bootstrapping database.
This additional secrets-tool command can be used to run the database
bootsrapping script (`script/database_setup.py`) inside an ATAT docker
container against the Azure database. It sources the necessary keys from
Key Vault.
2020-01-27 13:17:09 -05:00
dandds
49a1a219ae Script for setting up database user, schema, and seed data.
This script is for bootstrapping the initial database. It can be run via
a container, but requires that a Postgres superuser's credentials be
provided via our normal config. That way the superuser can provision a
less-privileged user for the application's database connection.
2020-01-27 13:17:09 -05:00
tomdds
d02d47615e First step in breaking out cloud.py
Move cloud.py to a module init. Move policy with it. Update related unit tests. Also adds a patch to state machine test to prevent randomness in mock from failing test.
2020-01-26 14:03:09 -05:00
raydds
b059605b37 Dropdb has a handy argument for conditionally dropping a database 2020-01-16 11:52:18 -05:00
raydds
d595ef60d3 Also supress the --version error 2020-01-16 11:46:03 -05:00
raydds
741636f00a This was erroring if the uploads directory already existed 2020-01-16 11:42:12 -05:00
raydds
e6078cbe4a pipenv --py reports a big scary error on the first run. Silence stderr 2020-01-16 11:41:56 -05:00
dandds
a54db5a688 Remove Minkube config.
We do not have the bandwidth to keep the Minikube deployment up-to-date,
so rather than leave half-baked config in the repo we'll remove it for
now. Complications that would have to be resolved for running Minikube
locally include managing secrets out of Azure Key Vault and managing TLS
termination over localhost.

The Synack audit also identified the Minikube basic auth password as an
issue; it's only for demo purposes, but this will resolve that ticket.
2020-01-14 15:46:08 -05:00
leigh-mil
959636fc91 Fix seed_sample script 2020-01-10 10:25:55 -05:00
leigh-mil
8710028256 Fix factories and seed sample script
Update display of defense component on portfolio settings page
2020-01-06 13:08:57 -05:00
dandds
a660f41171 Do not catch errors in CI.
This removes all error-catching from the test scripts. If unit tests
fail, the script will exit immediately. The error catching functionality
was not working correctly using the sh shell in Alpine inside the
containers, and so CI was allowed to continue after test failures.
2019-12-20 14:25:41 -05:00
graham-dds
d247620c51 Slience output from curl for integration tests
We use curl in our integration test script to make sure the application container is
available before moving on. We expect many connection errors and don't care
about the output of curl, so this will just swallow all of the output.
2019-12-18 16:43:30 -05:00
dandds
3457f51d99 CI script should fail hard.
Right now, unit test failures in script/cibuild are not being emitted
correctly. Instead, we'll just `set -e` at the top of the CI script so
that failures are fast and obvious.
2019-12-16 11:04:57 -05:00
graham-dds
9417cae493 Modify seed_sample to integrate with fixture data
Adds reasonable figures to active clins in A-Wing and B-Wing so that the obligated funding
graphs show a variety of UI states
2019-12-10 11:23:53 -05:00
graham-dds
ac4b15e4b2 Update seed sample script to conform to new fixture data 2019-12-10 11:23:53 -05:00
dandds
0851e42572 Add script for running Ghost Inspector tests locally.
Eventually, this should replace the CircleCI config for running the
integration tests to avoid duplication. In the interest of time so that
I don't have to debug broken builds, I'm only adding it as a utility
script.
2019-12-05 16:50:53 -05:00
leigh-mil
b5c6fd35bd
Merge branch 'staging' into schema-review 2019-12-03 09:46:01 -05:00
tomdds
9469d1ff1b Introduce TEMPLATE_ID variable for FlexVolume
FlexVolume requires you specify the tenant id of the key vault instance, so this will need to be templated in for future enviroments
2019-12-02 15:45:16 -05:00
leigh-mil
614514d6a2 Update tables to match business logic 2019-12-02 14:46:11 -05:00
dandds
d5865c1ab3 Script for compiling K8s config. 2019-11-25 14:24:53 -05:00
leigh-mil
eab8cbdd56
Merge pull request #1200 from dod-ccpo/add-ccpo-script
Add CCPO user script
2019-11-25 09:47:00 -05:00
leigh-mil
778cda0924 Add script for giving a user CCPO permissions from the command line 2019-11-22 09:44:11 -05:00
dandds
cd3cb7b614 Adjust script to drop all tables and reset from scratch.
This updates the script for resetting the database so that it drops and
recreates all the tables, instead of disabling Postgres triggers and
truncating most of the tables. The latter strategy requires superuser
permissions in Postgres that the db user we manage in Azure does not
have. The script now:

- drops the tables
- reruns the alembic migrations
- reseeds the permission sets
2019-11-21 15:37:31 -05:00
dandds
7e468f8ac6 Rename script for resetting the database.
Renamed this script because it's current name is misleading. It does not
just remove sample data; it truncates every table except the alembic
version table and `permission_sets`.
2019-11-18 10:17:44 -05:00
dandds
387f957aa4 Add CircleCI config for staging deployment.
This generalizes the deploy step into a configurable CircleCI command.
The available parameters are:

- `namespace`: the K8s namespace to alter
- `tag`: the docker tag to apply to the image

The script for applying migrations to the K8s environment and the
corresponding K8s Job config have been generalized so that they can be
configured to run in the specified namespace.

The main workflow has been updated so that the appropriate deployment
will happen, depending on whether we are merging to staging or master.
In the future, we could look to add an additional workflow based around
Git tags for production.

Note that this also removes the creation of the `latest` tag from CD.
That tag is no longer hard-coded into our K8s config and so there's no
longer a need to update it in our container registry.
2019-11-13 09:56:36 -05:00
dandds
23c4ba32eb CI/CD uses Docker containers exclusively and removes CircleCI Orbs.
The CircleCI Orbs were useful for getting started, but now that we only
have to deploy to one provider our pipeline should be tailored to
efficiently push to just that environment. This inlines all the relevant
pieces from the Orbs we were relying on as bash/sh commands instead.

This builds the Docker images upfront. Since we have a multi-stage
Dockerfile, it builds the first stage as a separate image and then
proceeds to build the complete image. This is done so that the first
stage (called "builder") can be used for testing. It retains executables
like pipenv that we need to install development dependencies needed for
tests.

Other notes:
- CircleCI does not persist Docker images between jobs. As a
  work-around, we use the CircleCI caching mechanism to create a named
  cache with *.tar copies of the images. Subsequent jobs use the cache
  and load the images.
- Both the test and integration-tests jobs need to make minor
  modifications to the container to run correctly. The test job needs to
  install the development Python dependencies, and the integration-tests
  job needs to rebuild the JS bundle so that it uses the mock uploader
  (the container is build to use the Azure uploader by default).
- The test and integration-tests jobs run in parallel.
- This adjusts the Dockerfile so that the TZ environment variable is set
  for both stages of the build.
2019-10-30 12:04:21 -04:00
dandds
380a9beb6f
Merge pull request #1140 from dod-ccpo/azure-ci
Update CI and remove AWS config.
2019-10-28 11:34:25 -04:00
dandds
d514305f26 Remove unused scripts. 2019-10-26 16:15:32 -04:00
richard-dds
c66b1ef2f9 Add mypy and add typechecking step to script/test
Only check atst/domain/csp/cloud.py for now
2019-10-24 14:44:53 -04:00
leigh-mil
6619c77df5
Merge pull request #1123 from dod-ccpo/add-test-templates-gitignore
Ignore js/test_templates
2019-10-18 12:06:30 -04:00
dandds
4169dcb310 Fix CI/CD bug with PGSSLROOTCERT.
Because I pushed the environment variable changes to the cluster
already, psycopg2 was automatically trying to connect to the database
using the file specified in PGSSLROOTCERT. That ConfigMap was not
mounted into the migrations container, so I'm doing that here.
2019-10-17 14:59:41 -04:00
leigh-mil
248e93103b Add js/test_templates to .gitignore file and remove ignored folder 2019-10-16 13:53:40 -04:00
dandds
d1ed0f6692 Add setup script and configuration for Minikube cluster.
The Minikube version of the cluster has some differences from the main
config (noted in the README) but will be useful for for future DevOps
development.
2019-10-04 17:48:46 -04:00
dandds
ae57baf455
Merge pull request #1094 from dod-ccpo/test-changes
updates to script/test and JS coverage
2019-09-26 15:44:14 -04:00
dandds
6c22d5a524 Apply section heads to test output for clarity.
This also removes a test setup command that added an uploads directory.
It's no longer necessary.
2019-09-26 13:23:17 -04:00
leigh-mil
7ad7c79897 Update seed script so app members have invites 2019-09-26 09:46:24 -04:00
dandds
8d7c7a0d6e Render Vue component templates as part of test script.
Add a command to the test script to output up-to-date Vue component
templates. Most of the Vue component tests rely on HTML templates built
from Jinja.
2019-09-25 11:32:10 -04:00
dandds
3a23c54723 Add a beat processing schedule for environment provisioning jobs.
The beat schedule is set to once per minute for each of the three
environment provisioning tasks.

Adding a beat schedule surfaced two problems that are addressed here
with the following changes:
- Commit the SQLALchemy session in order to release the environment
  lock. Otherwise the change to the `claimed_until` field is not
  persisted.
- Set `none_as_null` on the JSOB fields on the `Environment`. This
  avoids problems with querying on Postgres JSON fields that are empty.

This also adds a small change to the development command for the Celery
worker. Multiple child processes were executing the beat jobs, which
lead to exceptions for environment locks and confusing log output. This
contrains the dev command to a single Celery worker.
2019-09-18 16:34:56 -04:00
dandds
b107f84c75 Do not try to copy crl-tmp contents if empty.
The Kubernetes CronJob for syncing CRLs syncs them to a temporary folder
and then copies them to the real location once the sync is complete. If
the temporary folder is empty, the `cp` command throws an error. This
updates the bash script that manages the sync so that it will skip the
copy command if the temporary location is empty.
2019-09-16 11:23:15 -04:00
richard-dds
f6cb6f2a31 Change Environment.creator relation from ApplicationRole to User 2019-09-11 11:42:59 -04:00
richard-dds
ac0c194490 Add celery beat worker 2019-09-11 11:41:57 -04:00
dandds
dfb4536b5d Do not add User.permission_sets to sample portfolio users 2019-09-04 13:02:53 -04:00
dandds
d7478e322a Use Celery instead of RQ.
Celery provides a more robust set of queueing options for both tasks and
worker processes. Updates include:
- infrastructure necessary to run Celery, including celery entrypoint
- backgrounded functions are now imported directly from atst.jobs
- update tests as-needed
- update kubernetes worker pod command
2019-08-29 09:33:47 -04:00