~sschwarzer/ftputil#142: 
Make container for integration tests

For years, the tests in test/test_real_ftp.py have run against an FTP server that I have installed locally on my system. The tests therefore aren't really usable for anyone else, especially since the tests not only need a configured server, but also test data.

It would be nice to create an OCI container image so that others (and me!) can install the server and test data quickly and run tests against the container.

Status
RESOLVED FIXED
Submitter
schwa (unverified)
Assigned to
No-one
Submitted
3 years ago
Updated
3 years ago
Labels
tests

schwa (unverified) 3 years ago · edit

I have implemented this, see test_server . You can build the image with the test_server directory as the build context. There are also the make file targets build_test_server_image and run_test_server.

An image is also currently ​on the Docker hub, but again, you can build it yourself if you have cloned/pulled the ftputil source.

schwa (unverified) 3 years ago · edit

The implementation works, but has problems I'd like to solve:

  • When building the image with Docker, the ADD command in the Dockerfile correctly unpacks the tar.gz file with root:root or ftptest:ftpgroup as owner/group. That is, some directories and files are owned by ftptest to make them writable after ftptest logging into the FTP server. Other directories and files are deliberately owned by root, so that tests can assert that the user can't write to them.

However, due to a ​bug in some Podman versions the owner/group information isn't set correctly when unpacking the archive via podman build.

I'd like to change the Dockerfile so that the tar.gz file is copied into the image and then unpacked in a RUN command. This is supposed to work around the Podman problem.

  • At the moment, the tar.gz file is present as an artifact in the version control repository. However, that's not the "canonical form"; the tar.gz file is difficult to change. With the current state of the repository, users can clone the repository, build the image and run the tests, - but it's very cumbersome to change directories or files in the archive if necessary for a new or changed test. The least I'd like to do, if feasible, is to split the archive in a subdirectory that's owned by ftptest and one subdirectory owned by root. I need to look more into this.

schwa (unverified) 3 years ago · edit

I revised the Dockerfile to not use ADD so that it works with Podman. Also, the canonical content is now in the ftptest directory, not in the related ftptest.tar.gz file. Actually, the archive file is no longer used.

One downside of this approach is that presumably empty directories under the ftptest directory need a dummy file .empty, so that the directories can be represented in version control. The .empty files will be copied into the image, together the rest of the ftptest home directory, but the files will then be deleted in the RUN command and therefore won't be present in the final image.

schwa (unverified) 3 years ago · edit

Milestone deleted

Register here or Log in to comment, or comment via email.