Skip to content

[CA PoC] Implement basic test cases for ClickHouse

Why are we doing this work

We need to be able to run tests that are using the ClickHouse database. The goal here is to create a few test cases which are executing queries against a configured ClickHouse database and verify the returned values.

These test cases must be excluded on CI for now (use rspec tags). Having CH on the CI will be a follow-up issue: #414577 (closed)

Implementation plan

Assuming that we have a client (#414397 (closed)) in the GitLab repository, implement a new test file that queries data from the ClickHouse database.

Add an rspec tag click_house which will do the following before the suite:

  • Create a new database using a hardcoded schema (contains one table): schema.sql (we can store the schema in the repo for now)
  • If the DB exists, skip the creation

After each test case, the DB tables must be cleaned. Iterate over the tables in the DB: SHOW TABLES FROM gitlab_clickhouse_test and truncate them one by one.

Test case 1:

  1. Insert a record to events table.
  2. Read the record from the DB.
  3. Delete the record.
  4. Ensure that the record is not in the DB.

Test case 2:

  1. Check if the events table is empty. (tests our cleanup logic after each test case)
Edited by charlie ablett