Skip to content

Testing

Benjamin West edited this page Mar 18, 2023 · 10 revisions

Deploying vets into k8s

# Apply the raw manifest which defines the argocd apps
kubectl apply -n argocd -f deploy-descriptors/vets/argocd.yaml

# Check it comes up (race cond on db, need to fix, delete pod if necessary)
kubectl get pods -n dev-vets

This will create the deployment pipelines for two envs of vets app in the cluster which uses the helm chart from the same directory to deploy.

In the current configuration, the dev environment uses the develop branch and the production environment uses master branch as its source for deployment charts.

Deploying CI pipelines

helm install vets-ci -n argo-workflows build-descriptors/vets/chart

Local running and testing

Pretty simplistic, there is a testing folder within the vets django application which houses the tests.

I wrote VetsTestRunner which loads test data once at the start of the run from VetsTestData. This gives a bit of data to get off the ground. This is explicitly defined in settings.py as the test runner for this project.

Env vars for local testing

export DJANGO_SECRET_KEY="<< some long string>>>"
export DJANGO_DATABASE="local"
export DJANGO_DEBUG="True" 

Running the tests

Just a call to:

# Grab the deps
pip install -r application/requirements.txt

# Make the initial db migration file and apply it to local DB.
python application/manage.py makemigrations
python application/manage.py migrate

# Time the big elements of the run (db creation) and verbosity == 2 
# Also you can keep the db for later if you wish (this is unreliable at best for me though!)
python application/manage.py test --timing -v 2 --keepdb

Running local server

Make a superuser in the db and fire up the dev server:

python application/manage.py createsuperuser
python application/manage.py runserver

Database interactions / manual validation

python application/manage.py dbshell

Deploying vets into k8s

# Apply the raw manifest which defines the argocd apps
kubectl apply -n argocd -f deploy-descriptors/vets/argocd.yaml

# Check it comes up (race cond on db, need to fix, delete pod if necessary)
kubectl get pods -n dev-vets

This will create the deployment pipelines for two envs of vets app in the cluster which uses the helm chart from the same directory to deploy.

In the current configuration, the dev environment uses the develop branch and the production environment uses master branch as its source for deployment charts.

Branch environments

Testing vets in the cluster

Clone this wiki locally