Class: GitlabQuality::TestTooling::CodeCoverage::ClickHouse::JestQuarantinedTestsTable

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/gitlab_quality/test_tooling/code_coverage/click_house/jest_quarantined_tests_table.rb

Overview

Replaces ‘code_coverage.jest_quarantined_tests_today` with the current contents of `scripts/frontend/quarantined_vue3_specs.txt` before each nightly risk aggregation. The helper table is a transient snapshot: it is truncated and repopulated on every aggregation run so the aggregation SQL can treat it as a simple LEFT JOIN for is_quarantined enrichment without needing a time-windowed query.

Constant Summary collapse

TABLE_NAME =
'jest_quarantined_tests_today'

Instance Method Summary collapse

Constructor Details

#initialize(url:, database:, username: nil, password: nil, logger: nil) ⇒ JestQuarantinedTestsTable

Returns a new instance of JestQuarantinedTestsTable.



20
21
22
23
24
25
26
# File 'lib/gitlab_quality/test_tooling/code_coverage/click_house/jest_quarantined_tests_table.rb', line 20

def initialize(url:, database:, username: nil, password: nil, logger: nil)
  @url = url
  @database = database
  @username = username
  @password = password
  @logger = logger || Runtime::Logger.logger
end

Instance Method Details

#populate(quarantine_file:) ⇒ void

This method returns an undefined value.

Reads ‘quarantine_file`, truncates `jest_quarantined_tests_today`, then inserts one row per non-blank, non-comment line. Idempotent: repeated calls with the same flat file produce the same table state.

Parameters:

  • quarantine_file (String)

    path to the quarantine flat file



34
35
36
37
38
39
# File 'lib/gitlab_quality/test_tooling/code_coverage/click_house/jest_quarantined_tests_table.rb', line 34

def populate(quarantine_file:)
  truncate_and_insert(read_quarantine_file(quarantine_file))
rescue StandardError => e
  logger.error("#{LOG_PREFIX} Error populating #{full_table_name}: #{e.message}")
  raise
end