What would be the best testing architecture for this project?

I have a project running multiple Docker containers:

  • db: contains a PostgreSQL database
  • scripts: contains Python scripts

I have a series of unit tests written in Python:

  • to test some custom functions in the PostgreSQL db
  • to test some methods in the Python scripts
  • Some of the Python scripts actually need to connect to the PostgreSQL db via ODBC (using Pyodbc)

I was wondering what would be the best architecture to execute my tests?
For instance:

Scenario 1

  • Use CircleCI VM as an executor
  • Configure the VM with .config.yml so that it has all the dependencies required to execute the unit tests (Python packages, ODBC drivers, ODBC configuration, etc…)
  • Run db containers in the VM
  • Execute unit tests directly in the VM (they would import the Python scripts from the base files of the scripts image)

Scenario

  • Use CircleCI VM as an executor
  • Build a dedicated test container, which I guess I can build based on the image of my scripts container to avoid redundancy
  • Run db containers in the VM
  • Run the tests directly within the test container

What would you suggest? Do you see another potential scenario?
I’ve actually tried scenario 1 in the first place but I’m having difficulties to configure the VM properly. See error here: https://stackoverflow.com/questions/52565165/pyodbc-error-unixodbc-driver-manager-data-source-name-not-found-in-circleci

Thank you

Either will work. I somewhat prefer (2) as you can run them locally with Docker or Docker Compose, and it does not tie your work as much to a specific CI provider.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.