Commit 36f39eb3 authored by Ryan Cobb's avatar Ryan Cobb

Remove CommonMetricsImporter patch

Remove CommonMetricsImporter patch and change all references to
CommonMetrics::Importer. Move specs into their appropriate folders. Also
cleans up some common_metric importer namespacing.
parent 3cabc558
# frozen_string_literal: true
require Rails.root.join('db/importers/common_metrics_importer.rb')
::Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
# frozen_string_literal: true
require Rails.root.join('db/importers/common_metrics_importer.rb')
::Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
# This functionality has been moved to the lib/gitlab/importers/common_metrics module.
# This is here only to preserve existing ::Importers::CommonMetricsImporter api
module Importers
module CommonMetricsImporter
def self.new(*args)
Gitlab::Importers::CommonMetrics::Importer.new(*args)
end
end
end
......@@ -3,12 +3,10 @@
class ImportCommonMetrics < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
require Rails.root.join('db/importers/common_metrics_importer.rb')
DOWNTIME = false
def up
Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
end
def down
......
class ImportCommonMetricsNginxVts < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
require Rails.root.join('db/importers/common_metrics_importer.rb')
DOWNTIME = false
def up
Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -3,12 +3,10 @@
class ImportCommonMetricsKnative < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
require Rails.root.join('db/importers/common_metrics_importer.rb')
DOWNTIME = false
def up
Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -6,12 +6,10 @@
class PrometheusKnative05Fix < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
require Rails.root.join('db/importers/common_metrics_importer.rb')
DOWNTIME = false
def up
Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -33,12 +33,10 @@ For example: you might be interested in migrating all dependent data to a differ
class ImportCommonMetrics < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
require Rails.root.join('db/importers/common_metrics_importer.rb')
DOWNTIME = false
def up
Importers::CommonMetricsImporter.new.execute
::Gitlab::Importers::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -13,7 +13,7 @@ module Gitlab
end
def execute
::Gitlab::Importers::CommonMetrics::PrometheusMetric.reset_column_information
CommonMetrics::PrometheusMetric.reset_column_information
process_content do |id, attributes|
find_or_build_metric!(id)
......@@ -62,17 +62,17 @@ module Gitlab
def find_or_build_metric!(id)
raise MissingQueryId unless id
::Gitlab::Importers::CommonMetrics::PrometheusMetric.common.find_by(identifier: id) ||
::Gitlab::Importers::CommonMetrics::PrometheusMetric.new(common: true, identifier: id)
CommonMetrics::PrometheusMetric.common.find_by(identifier: id) ||
CommonMetrics::PrometheusMetric.new(common: true, identifier: id)
end
# rubocop: enable CodeReuse/ActiveRecord
def find_group_title_key(title)
::Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.groups[find_group_title(title)]
CommonMetrics::PrometheusMetricEnums.groups[find_group_title(title)]
end
def find_group_title(title)
::Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.group_titles.invert[title]
CommonMetrics::PrometheusMetricEnums.group_titles.invert[title]
end
end
end
......
......@@ -38,3 +38,5 @@ module Gitlab
end
end
end
::Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.prepend EE::Gitlab::Importers::CommonMetrics::PrometheusMetricEnums
# frozen_string_literal: true
require 'rails_helper'
require Rails.root.join("db", "importers", "common_metrics_importer.rb")
describe Gitlab::Importers::CommonMetrics::PrometheusMetric do
let(:existing_group_titles) do
::PrometheusMetricEnums.group_details.each_with_object({}) do |(key, value), memo|
memo[key] = value[:group_title]
end
end
it 'group enum equals ::PrometheusMetric' do
expect(described_class.groups).to eq(::PrometheusMetric.groups)
end
it 'GROUP_TITLES equals ::PrometheusMetric' do
expect(Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.group_titles).to eq(existing_group_titles)
end
end
describe Importers::CommonMetricsImporter do
describe Gitlab::Importers::CommonMetrics::Importer do
subject { described_class.new }
context "does import common_metrics.yml" do
......
# frozen_string_literal: true
require 'rails_helper'
describe Gitlab::Importers::CommonMetrics::PrometheusMetric do
let(:existing_group_titles) do
::PrometheusMetricEnums.group_details.each_with_object({}) do |(key, value), memo|
memo[key] = value[:group_title]
end
end
it 'group enum equals ::PrometheusMetric' do
expect(described_class.groups).to eq(::PrometheusMetric.groups)
end
it '.group_titles equals ::PrometheusMetric' do
expect(Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.group_titles).to eq(existing_group_titles)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment