Commit f0d2d2a2 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '212463-remove-export-fast-serialize-feature-flag' into 'master'

Resolve "Remove  export_fast_serialize feature flag"

See merge request gitlab-org/gitlab!28037
parents 1d05a0db 4a801969
---
title: Remove feature flag 'export_fast_serialize' and 'export_fast_serialize_with_raw_json'
merge_request: 28037
author:
type: performance
......@@ -142,12 +142,7 @@ module Gitlab
# returned by database when no `ORDER` is specified
batch = batch.reorder(batch.klass.primary_key)
if Feature.enabled?(:export_fast_serialize_with_raw_json, default_enabled: true)
data.append(JSONBatchRelation.new(batch, options, preloads[key]).tap(&:raw_json))
else
batch = batch.preload(preloads[key]) if preloads&.key?(key)
data += batch.as_json(options)
end
data.append(JSONBatchRelation.new(batch, options, preloads[key]).tap(&:raw_json))
end
data
......
......@@ -6,13 +6,9 @@ module Gitlab
include Gitlab::ImportExport::CommandLineUtil
def serialize(exportable, relations_tree)
if Feature.enabled?(:export_fast_serialize, default_enabled: true)
Gitlab::ImportExport::FastHashSerializer
.new(exportable, relations_tree)
.execute
else
exportable.as_json(relations_tree)
end
Gitlab::ImportExport::FastHashSerializer
.new(exportable, relations_tree)
.execute
end
def save(tree, dir_path, filename)
......
......@@ -23,50 +23,6 @@ describe Gitlab::ImportExport::Group::TreeSaver do
expect(group_tree_saver.save).to be true
end
context ':export_fast_serialize feature flag checks' do
before do
expect(Gitlab::ImportExport::Reader).to receive(:new).with(shared: shared, config: group_config).and_return(reader)
expect(reader).to receive(:group_tree).and_return(group_tree)
end
let(:reader) { instance_double('Gitlab::ImportExport::Reader') }
let(:group_config) { Gitlab::ImportExport::Config.new(config: Gitlab::ImportExport.group_config_file).to_h }
let(:group_tree) do
{
include: [{ milestones: { include: [] } }],
preload: { milestones: nil }
}
end
context 'when :export_fast_serialize feature is enabled' do
let(:serializer) { instance_double(Gitlab::ImportExport::FastHashSerializer) }
before do
stub_feature_flags(export_fast_serialize: true)
expect(Gitlab::ImportExport::FastHashSerializer).to receive(:new).with(group, group_tree).and_return(serializer)
end
it 'uses FastHashSerializer' do
expect(serializer).to receive(:execute)
group_tree_saver.save
end
end
context 'when :export_fast_serialize feature is disabled' do
before do
stub_feature_flags(export_fast_serialize: false)
end
it 'is serialized via built-in `as_json`' do
expect(group).to receive(:as_json).with(group_tree).and_call_original
group_tree_saver.save
end
end
end
# It is mostly duplicated in
# `spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb`
# except:
......
......@@ -8,35 +8,17 @@ describe Gitlab::ImportExport::LegacyRelationTreeSaver do
let(:tree) { {} }
describe '#serialize' do
context 'when :export_fast_serialize feature is enabled' do
let(:serializer) { instance_double(Gitlab::ImportExport::FastHashSerializer) }
let(:serializer) { instance_double(Gitlab::ImportExport::FastHashSerializer) }
before do
stub_feature_flags(export_fast_serialize: true)
end
it 'uses FastHashSerializer' do
expect(Gitlab::ImportExport::FastHashSerializer)
.to receive(:new)
.with(exportable, tree)
.and_return(serializer)
it 'uses FastHashSerializer' do
expect(Gitlab::ImportExport::FastHashSerializer)
.to receive(:new)
.with(exportable, tree)
.and_return(serializer)
expect(serializer).to receive(:execute)
expect(serializer).to receive(:execute)
relation_tree_saver.serialize(exportable, tree)
end
end
context 'when :export_fast_serialize feature is disabled' do
before do
stub_feature_flags(export_fast_serialize: false)
end
it 'is serialized via built-in `as_json`' do
expect(exportable).to receive(:as_json).with(tree)
relation_tree_saver.serialize(exportable, tree)
end
relation_tree_saver.serialize(exportable, tree)
end
end
end
......@@ -25,51 +25,6 @@ describe Gitlab::ImportExport::Project::LegacyTreeSaver do
expect(project_tree_saver.save).to be true
end
context ':export_fast_serialize feature flag checks' do
before do
expect(Gitlab::ImportExport::Reader).to receive(:new).with(shared: shared).and_return(reader)
expect(reader).to receive(:project_tree).and_return(project_tree)
end
let(:serializer) { instance_double('Gitlab::ImportExport::FastHashSerializer') }
let(:reader) { instance_double('Gitlab::ImportExport::Reader') }
let(:project_tree) do
{
include: [{ issues: { include: [] } }],
preload: { issues: nil }
}
end
context 'when :export_fast_serialize feature is enabled' do
before do
stub_feature_flags(export_fast_serialize: true)
end
it 'uses FastHashSerializer' do
expect(Gitlab::ImportExport::FastHashSerializer)
.to receive(:new)
.with(project, project_tree)
.and_return(serializer)
expect(serializer).to receive(:execute)
project_tree_saver.save
end
end
context 'when :export_fast_serialize feature is disabled' do
before do
stub_feature_flags(export_fast_serialize: false)
end
it 'is serialized via built-in `as_json`' do
expect(project).to receive(:as_json).with(project_tree)
project_tree_saver.save
end
end
end
# It is mostly duplicated in
# `spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb`
# except:
......
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