Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/database/click_house/hooks.rb')
-rw-r--r--spec/support/database/click_house/hooks.rb24
1 files changed, 3 insertions, 21 deletions
diff --git a/spec/support/database/click_house/hooks.rb b/spec/support/database/click_house/hooks.rb
index c13778f9c36..77b33b7aaa3 100644
--- a/spec/support/database/click_house/hooks.rb
+++ b/spec/support/database/click_house/hooks.rb
@@ -2,6 +2,8 @@
# rubocop: disable Gitlab/NamespacedClass
class ClickHouseTestRunner
+ include ClickHouseTestHelpers
+
def truncate_tables
ClickHouse::Client.configuration.databases.each_key do |db|
# Select tables with at least one row
@@ -18,17 +20,6 @@ class ClickHouseTestRunner
end
end
- def clear_db(configuration = ClickHouse::Client.configuration)
- configuration.databases.each_key do |db|
- # drop all tables
- lookup_tables(db, configuration).each do |table|
- ClickHouse::Client.execute("DROP TABLE IF EXISTS #{table}", db, configuration)
- end
-
- ClickHouse::MigrationSupport::SchemaMigration.create_table(db, configuration)
- end
- end
-
def ensure_schema
return if @ensure_schema
@@ -38,7 +29,7 @@ class ClickHouseTestRunner
migrations_paths = ClickHouse::MigrationSupport::Migrator.migrations_paths
schema_migration = ClickHouse::MigrationSupport::SchemaMigration
migration_context = ClickHouse::MigrationSupport::MigrationContext.new(migrations_paths, schema_migration)
- migration_context.up
+ migrate(nil, migration_context)
@ensure_schema = true
end
@@ -49,10 +40,6 @@ class ClickHouseTestRunner
@tables ||= {}
@tables[db] ||= lookup_tables(db) - [ClickHouse::MigrationSupport::SchemaMigration.table_name]
end
-
- def lookup_tables(db, configuration = ClickHouse::Client.configuration)
- ClickHouse::Client.select('SHOW TABLES', db, configuration).pluck('name')
- end
end
# rubocop: enable Gitlab/NamespacedClass
@@ -61,9 +48,6 @@ RSpec.configure do |config|
config.around(:each, :click_house) do |example|
with_net_connect_allowed do
- was_verbose = ClickHouse::Migration.verbose
- ClickHouse::Migration.verbose = false
-
if example.example.metadata[:click_house] == :without_migrations
click_house_test_runner.clear_db
else
@@ -72,8 +56,6 @@ RSpec.configure do |config|
end
example.run
- ensure
- ClickHouse::Migration.verbose = was_verbose
end
end
end