Create a database used for the license-exporter unit tests using the schema project

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Relates to : https://gitlab.com/gitlab-org/security-products/license-db/license-exporter/-/merge_requests/36#note_1405189022

This issue is related to improving the tests quality.

In most of the license-db projects, we're creating a minimal DB schema instead of building the tests on top of the schema we build using the license-db/schema project. This discrepancy might result in bugs. For instance, we could have a unique index in the DB schema used for test, and use that index to ensure data consistency, and we might forget about that index in the schema used in production.

We should test using https://gitlab.com/gitlab-org/security-products/license-db/schema. Perhaps is worth investigating if we could create a minimal schema using plpgsql functions

Implementation Plan

  • Modify schema project pipeline to build schema releases also for arm64 arch for dev.
  • Push on dev project a docker image for the latest release for `arm64. For example:
# If the latest release is v0.2.1
docker buildx build --push -t gcr.io/ext-license-db-dev-d6ba6f35/schema:0.2.1_arm64 .  
  • Update all license-db projects that use a docker postgres image for unit tests with the following:
  • Modify the start-pg stage of the makefile in order to run the schema docker image after running the postgres image . Probably you will need:
docker run --rm \
   -p 3000:3000 \
   -e POSTGRES_CONN="user=postgres password=temporary dbname=postgres sslmode=disable" \
   -e MIGRATION_CMD=up \
   -e ENV=dev \
   -e MIGRATION_DIR=/app/migrations/files/ \
   --name schema \
   gcr.io/ext-license-db-dev-d6ba6f35/schema:0.2.1_arm64 migrate
  • Remove all code from the project that creates/destroy the minimal_schema.
  • Run tests using make test-integration and ensure the tests run correctly.
  • Repeat for all license-db projects
Edited by 🤖 GitLab Bot 🤖