Testing custom pulpcore-manager commands

We do not seem to have any tests for our custom django commands.

I’m trying to write one for the plugin removal.
The test needs to be able to call commands, stop/start pulp services, trigger typical workflows like sync/publish/distribute.

It looks more like a functional test but because it’s a command, it should be run next to the Django and can’t be run on a separate box. We have unit tests which run this way but semantically it’s not a unit test.
Does it need to be a separate category of tests?

In order to control services, pulp smash and its config should be available in the container with Django installation (currently it’s only installed in the box with functional tests in CI if I’m not mistaken). Or should it be just a custom exec (which will differ for local test and CI) but it sounds like a hack?

Thoughts are appreciated, +1 or any alternative approach is welcome.

1 Like

What you are describing is a functional test that can be run with all other functional tests. The pulpcore-manager command can be run using pulp-smash’s CLI client ‘run’ method[0]. The service manager can be used to restart services[1]. Using these facilities will ensure that the tests can be run both locally and in CI.

[0] https://github.com/pulp/pulp-smash/blob/master/pulp_smash/cli.py#L277
[1] https://github.com/pulp/pulp-smash/blob/master/pulp_smash/cli.py#L655

2 Likes