Test methodology before deployment

Hello! :slight_smile:
I have an instance of JupyterHub which I created using the z2jh. I have a repo for the deployment. The repo contains two config files (one for Dev and one for Prod) and scripts inside before-notebook.d. The configs are basically create different profile lists with different configurations. Before running helm --upgrade and updating the deployment, I want to verify that my changes work. For that I want to create unit tests that test my changes before deployment. What is the recommended way to do it? Can someone suggest an open source project that does the same as my repo and have test methodology which I can check?

The Z2JH repo includes a test to check spawning works:

You could use that as the basis for your tests, e.g. Once the server has spawned you could use the notebook API to check everything is correct, or alternatively use the K8S API to query the contents of the pod.

If you come across any good frameworks for these sorts of tests please share them :smiley:

1 Like

Hi @manics, thank you for your reply. How do you use the tests? I run helm --upgrade to update the configurations. How can I run the tests on my configurations? Should it be before I run --upgrade?

Those CI tests check that the Z2JH deployment is working by checking a singleuser server can be spawned. I don’t know of a way to check something works without deploying it, so your best option is probably to have separate staging and production deployments.

The tests use pytest fixtures to reduce the amount of code needed to write the tests, but unfortunately they can be quite difficult to understand if you haven’t used pytest fixtures before.

This is the relevant pytest fixture config that controls the request to the hub:

The request_data fixture is automatically passed into the tests in tests/test_spawn.py so you could try modifying that.