|
| 1 | +.. _migration_index: |
| 2 | + |
| 3 | +Migration |
| 4 | +========= |
| 5 | + |
| 6 | +Users of Open Klant version ``1.0.0`` willing to migrate to version ``2.0.0`` or higher |
| 7 | +can make use of the ``migrate_to_v2`` management command. This command **only** migrates |
| 8 | +``Klant`` instances from version ``1.0.0``. The command expects two URLs; a URL for the |
| 9 | +Open Klant instance of version ``1.0.0.``and a URL for version ``2.0.0``. The command |
| 10 | +also expects a ``ACCESS_TOKEN`` environment variable to be set, to authenticate to |
| 11 | +the Open Klant ``1.0.0`` instance. For the ``2.0.0`` instance a dummy token will be |
| 12 | +created. |
| 13 | + |
| 14 | +For this migration, tests are written using VCR, which records the (relevant) |
| 15 | +outgoing requests to cassette files. Whenever tests need to be updated, consider |
| 16 | +re-recording the corresponding cassettes. |
| 17 | + |
| 18 | +To re-record tests, a separate docker compose file is available to run a |
| 19 | +version ``1.0.0`` Open Klant instance next to the ``StaticLiveServer`` (which |
| 20 | +sets up a live server) which runs version ``2.0.0``. The `web` container from the |
| 21 | +docker compose setup should load the corresponding fixture which reside in the |
| 22 | +``migration/fixtures`` folder. A typical workflow, to re-record cassettes, |
| 23 | +could look like the following: |
| 24 | + |
| 25 | +.. code-block:: bash |
| 26 | +
|
| 27 | + # Start the docker compose setup |
| 28 | + $ docker compose up --detach |
| 29 | +
|
| 30 | + # Load a fixture for a certain test |
| 31 | + $ docker compose exec -it web \ |
| 32 | + ./src/manage.py loaddata migration/credentials migration/test_digitaal_adres |
| 33 | +
|
| 34 | + # Run the corresponding test |
| 35 | + $ ./src/manage.py test test openklant.tests.test_migrate.MigrateTestCase.test_digitaal_adres |
| 36 | +
|
| 37 | + # Stop and destroy the containers (to start with a clean slate on the next run) |
| 38 | + $ docker compose down |
| 39 | +
|
| 40 | +
|
| 41 | +After running the test a cassette should be created (with the test name as filename) |
| 42 | +in the ``migration/cassettes`` folder. |
| 43 | + |
| 44 | +Note that the docker compose setup, with its fixtures are only needed to (re)create |
| 45 | +cassettes for VCR. The migration tests can be ran without the docker compose setup. |
| 46 | + |
| 47 | +Some tests require custom responses, for example to retrieve the ``subjectIdentificatie`` |
| 48 | +when a ``subject`` URL is supplied. For these cases a ``test_server.py`` file is added |
| 49 | +that can be modified as needed to create a response for a cassette. |
0 commit comments