Running Selenium Tests in CI pipeline

I want to run selenium tests on a django application that I am developing as a part of a pre-established gitlab CI pipeline. I have some conceptual questions about how to go about doing that.

My preferred way of testing would be to have the testing entirely contained within gitlab. That is, to have gitlab start the django development server, run the unit tests (some of which are selenium tests), and then shut down the development server and report back whether the tests passed or failed. The problem is that those are two different processes that need to happen at the same time as selenium tests depend on being able to connect to the application that is being tested. My guess is that this might somehow be possible with running two docker images, one to host the django dev server and one to run the selenium test. My experience with docker is functionally zero so I don’t know if that is even possible, and if it is I do not know how to implement any of it. If it is possible, how would that work?

I am guessing though that that can’t happen, and so I have a backup idea. The application is currently deployed through openshift, so I thought if I can’t create an instance of the application in gitlab, then I could use a testing/dev application on openshift. It would get built and deployed every time the test is run and can then be reached by the selenium tests. I already have gitlab-ci trigger openshift to build and deploy the app for production so i know that is possible. The problem would be the latency between triggering the build in openshift and when the tests can actually be ran because the build and deploy process usually takes a minute or two. I had an idea that gitlab could trigger the build, then wait for a hook to be triggered before running the tests. There is a script that runs after the build has happened, so I could have a curl command execute there to trigger or update something in the gitlab pipeline, but again I don’t know if that is possible/how to do it.

Does anyone have any advice on how to go about doing either of these, or maybe there is some other much easier way of doing this? I could definitely be missing something, this is all relatively unfamiliar to me. Happy to provide more info. Thanks.

1 Like