Commit 138c6e1e authored by Olena Horal-Koretska's avatar Olena Horal-Koretska Committed by Vitali Tatarintev

Enable custom mapping feature for alerts HTTP endpoints

Remove `multiple_http_integrations_custom_mapping` feature flag
parent 3a172309
...@@ -16,7 +16,6 @@ import { ...@@ -16,7 +16,6 @@ import {
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { isEmpty, omit } from 'lodash'; import { isEmpty, omit } from 'lodash';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { import {
integrationTypes, integrationTypes,
integrationSteps, integrationSteps,
...@@ -60,7 +59,6 @@ export default { ...@@ -60,7 +59,6 @@ export default {
directives: { directives: {
GlModal: GlModalDirective, GlModal: GlModalDirective,
}, },
mixins: [glFeatureFlagsMixin()],
inject: { inject: {
generic: { generic: {
default: {}, default: {},
...@@ -163,12 +161,7 @@ export default { ...@@ -163,12 +161,7 @@ export default {
}; };
}, },
showMappingBuilder() { showMappingBuilder() {
return ( return this.multiIntegrations && this.isHttp && this.alertFields?.length;
this.multiIntegrations &&
this.glFeatures.multipleHttpIntegrationsCustomMapping &&
this.isHttp &&
this.alertFields?.length
);
}, },
hasSamplePayload() { hasSamplePayload() {
return this.isValidNonEmptyJSON(this.currentIntegration?.payloadExample); return this.isValidNonEmptyJSON(this.currentIntegration?.payloadExample);
...@@ -234,12 +227,10 @@ export default { ...@@ -234,12 +227,10 @@ export default {
}, },
submit() { submit() {
const { name, apiUrl } = this.integrationForm; const { name, apiUrl } = this.integrationForm;
const customMappingVariables = this.glFeatures.multipleHttpIntegrationsCustomMapping const customMappingVariables = {
? {
payloadAttributeMappings: this.mapping, payloadAttributeMappings: this.mapping,
payloadExample: this.samplePayload.json || '{}', payloadExample: this.samplePayload.json || '{}',
} };
: {};
const variables = const variables =
this.selectedIntegration === typeSet.http this.selectedIntegration === typeSet.http
......
...@@ -63,10 +63,7 @@ export default (el) => { ...@@ -63,10 +63,7 @@ export default (el) => {
render(createElement) { render(createElement) {
return createElement('alert-settings-wrapper', { return createElement('alert-settings-wrapper', {
props: { props: {
alertFields: alertFields: parseBoolean(multiIntegrations) ? JSON.parse(alertFields) : null,
gon.features?.multipleHttpIntegrationsCustomMapping && parseBoolean(multiIntegrations)
? JSON.parse(alertFields)
: null,
}, },
}); });
}, },
......
...@@ -6,10 +6,6 @@ module Projects ...@@ -6,10 +6,6 @@ module Projects
before_action :authorize_admin_operations! before_action :authorize_admin_operations!
before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token] before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token]
before_action do
push_frontend_feature_flag(:multiple_http_integrations_custom_mapping, @project)
end
respond_to :json, only: [:reset_alerting_token, :reset_pagerduty_token] respond_to :json, only: [:reset_alerting_token, :reset_pagerduty_token]
helper_method :error_tracking_setting helper_method :error_tracking_setting
......
---
name: multiple_http_integrations_custom_mapping
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46437
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/273573
milestone: '13.6'
type: development
group: group::monitor
default_enabled: false
---
title: Custom mapping for HTTP endpoints
merge_request: 56021
author:
type: added
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
module Gitlab module Gitlab
module AlertManagement module AlertManagement
def self.custom_mapping_available?(project) def self.custom_mapping_available?(project)
::Feature.enabled?(:multiple_http_integrations_custom_mapping, project) &&
project.feature_available?(:multiple_alert_http_integrations) project.feature_available?(:multiple_alert_http_integrations)
end end
......
...@@ -85,11 +85,6 @@ RSpec.describe OperationsHelper, :routing do ...@@ -85,11 +85,6 @@ RSpec.describe OperationsHelper, :routing do
it { is_expected.to include('multi_integrations' => 'true') } it { is_expected.to include('multi_integrations' => 'true') }
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: true)
end
it 'has the correct list of fields', :aggregate_failures do it 'has the correct list of fields', :aggregate_failures do
fields = Gitlab::Json.parse(alerts_settings_data['alert_fields']) fields = Gitlab::Json.parse(alerts_settings_data['alert_fields'])
...@@ -101,15 +96,6 @@ RSpec.describe OperationsHelper, :routing do ...@@ -101,15 +96,6 @@ RSpec.describe OperationsHelper, :routing do
end end
end end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it { is_expected.not_to have_key('alert_fields') }
end
end
context 'when not available' do context 'when not available' do
let(:multi_integrations) { false } let(:multi_integrations) { false }
......
...@@ -106,7 +106,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do ...@@ -106,7 +106,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do
stub_licensed_features(multiple_alert_http_integrations: project) stub_licensed_features(multiple_alert_http_integrations: project)
end end
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
let_it_be(:attribute_mapping) do let_it_be(:attribute_mapping) do
{ {
title: { path: %w(alert name), type: 'string' }, title: { path: %w(alert name), type: 'string' },
...@@ -124,10 +123,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do ...@@ -124,10 +123,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do
let(:parsed_payload) { described_class.new(project: project, payload: raw_payload, integration: integration) } let(:parsed_payload) { described_class.new(project: project, payload: raw_payload, integration: integration) }
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
context 'with defined custom mapping' do context 'with defined custom mapping' do
let_it_be(:integration) do let_it_be(:integration) do
create(:alert_management_http_integration, project: project, payload_attribute_mapping: attribute_mapping) create(:alert_management_http_integration, project: project, payload_attribute_mapping: attribute_mapping)
...@@ -271,15 +266,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do ...@@ -271,15 +266,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do
end end
end end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'parsing alert payload fields with default paths'
end
end
context 'with multiple HTTP integrations feature unavailable' do context 'with multiple HTTP integrations feature unavailable' do
before do before do
stub_licensed_features(multiple_alert_http_integrations: false) stub_licensed_features(multiple_alert_http_integrations: false)
......
...@@ -71,7 +71,6 @@ RSpec.describe 'Creating a new HTTP Integration' do ...@@ -71,7 +71,6 @@ RSpec.describe 'Creating a new HTTP Integration' do
project.add_maintainer(current_user) project.add_maintainer(current_user)
stub_licensed_features(multiple_alert_http_integrations: true) stub_licensed_features(multiple_alert_http_integrations: true)
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end end
it_behaves_like 'creating a new HTTP integration' it_behaves_like 'creating a new HTTP integration'
...@@ -108,14 +107,6 @@ RSpec.describe 'Creating a new HTTP Integration' do ...@@ -108,14 +107,6 @@ RSpec.describe 'Creating a new HTTP Integration' do
it_behaves_like 'ignoring the custom mapping' it_behaves_like 'ignoring the custom mapping'
end end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
it_behaves_like 'validating the payload_example' it_behaves_like 'validating the payload_example'
it_behaves_like 'validating the payload_attribute_mappings' it_behaves_like 'validating the payload_attribute_mappings'
end end
...@@ -61,7 +61,6 @@ RSpec.describe 'Updating an existing HTTP Integration' do ...@@ -61,7 +61,6 @@ RSpec.describe 'Updating an existing HTTP Integration' do
project.add_maintainer(current_user) project.add_maintainer(current_user)
stub_licensed_features(multiple_alert_http_integrations: true) stub_licensed_features(multiple_alert_http_integrations: true)
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end end
it_behaves_like 'updating an existing HTTP integration' it_behaves_like 'updating an existing HTTP integration'
...@@ -75,12 +74,4 @@ RSpec.describe 'Updating an existing HTTP Integration' do ...@@ -75,12 +74,4 @@ RSpec.describe 'Updating an existing HTTP Integration' do
it_behaves_like 'ignoring the custom mapping' it_behaves_like 'ignoring the custom mapping'
end end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
end end
...@@ -57,7 +57,6 @@ RSpec.describe 'getting Alert Management HTTP Integrations' do ...@@ -57,7 +57,6 @@ RSpec.describe 'getting Alert Management HTTP Integrations' do
before do before do
stub_licensed_features(multiple_alert_http_integrations: true) stub_licensed_features(multiple_alert_http_integrations: true)
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end end
before_all do before_all do
......
...@@ -47,7 +47,6 @@ RSpec.describe 'parse alert payload fields' do ...@@ -47,7 +47,6 @@ RSpec.describe 'parse alert payload fields' do
before do before do
stub_licensed_features(multiple_alert_http_integrations: license) stub_licensed_features(multiple_alert_http_integrations: license)
stub_feature_flags(multiple_http_integrations_custom_mapping: feature_flag)
post_graphql(query, current_user: current_user) post_graphql(query, current_user: current_user)
end end
...@@ -94,10 +93,4 @@ RSpec.describe 'parse alert payload fields' do ...@@ -94,10 +93,4 @@ RSpec.describe 'parse alert payload fields' do
it_behaves_like 'query with error', 'Failed to parse payload' it_behaves_like 'query with error', 'Failed to parse payload'
end end
context 'without feature flag' do
let(:feature_flag) { false }
it_behaves_like 'query with error', 'Feature not available'
end
end end
...@@ -22,11 +22,6 @@ RSpec.describe AlertManagement::ExtractAlertPayloadFieldsService do ...@@ -22,11 +22,6 @@ RSpec.describe AlertManagement::ExtractAlertPayloadFieldsService do
stub_licensed_features(multiple_alert_http_integrations: true) stub_licensed_features(multiple_alert_http_integrations: true)
end end
context 'with feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
context 'with permissions' do context 'with permissions' do
before do before do
project.add_maintainer(user_with_permissions) project.add_maintainer(user_with_permissions)
...@@ -83,16 +78,4 @@ RSpec.describe AlertManagement::ExtractAlertPayloadFieldsService do ...@@ -83,16 +78,4 @@ RSpec.describe AlertManagement::ExtractAlertPayloadFieldsService do
end end
end end
end end
context 'with feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it 'returns feature not available error' do
is_expected.to be_error
expect(response.message).to eq('Feature not available')
end
end
end
end end
...@@ -68,11 +68,6 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService do ...@@ -68,11 +68,6 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService do
end end
end end
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
it 'successfully creates a new integration with the custom mappings' do it 'successfully creates a new integration with the custom mappings' do
expect(response).to be_success expect(response).to be_success
...@@ -83,14 +78,5 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService do ...@@ -83,14 +78,5 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService do
expect(integration.payload_attribute_mapping).to eq(payload_attribute_mapping) expect(integration.payload_attribute_mapping).to eq(payload_attribute_mapping)
end end
end end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
end
end end
end end
...@@ -36,17 +36,6 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do ...@@ -36,17 +36,6 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do
end end
describe '#execute' do describe '#execute' do
shared_examples 'ignoring the custom mapping' do
it 'creates integration without the custom mapping params' do
expect(response).to be_success
integration = response.payload[:integration]
expect(integration).to be_a(::AlertManagement::HttpIntegration)
expect(integration.payload_example).to eq({})
expect(integration.payload_attribute_mapping).to eq({})
end
end
subject(:response) { service.execute } subject(:response) { service.execute }
context 'with multiple HTTP integrations feature available' do context 'with multiple HTTP integrations feature available' do
...@@ -54,11 +43,6 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do ...@@ -54,11 +43,6 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do
stub_licensed_features(multiple_alert_http_integrations: true) stub_licensed_features(multiple_alert_http_integrations: true)
end end
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
it 'successfully creates a new integration with the custom mappings' do it 'successfully creates a new integration with the custom mappings' do
expect(response).to be_success expect(response).to be_success
...@@ -69,16 +53,5 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do ...@@ -69,16 +53,5 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do
expect(integration.payload_attribute_mapping).to eq(payload_attribute_mapping) expect(integration.payload_attribute_mapping).to eq(payload_attribute_mapping)
end end
end end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
end
it_behaves_like 'ignoring the custom mapping'
end end
end end
...@@ -19,7 +19,6 @@ RSpec.describe 'Alert integrations settings form', :js do ...@@ -19,7 +19,6 @@ RSpec.describe 'Alert integrations settings form', :js do
describe 'when viewing alert integrations as a maintainer' do describe 'when viewing alert integrations as a maintainer' do
context 'with the default page permissions' do context 'with the default page permissions' do
before do before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
visit project_settings_operations_path(project, anchor: 'js-alert-management-settings') visit project_settings_operations_path(project, anchor: 'js-alert-management-settings')
wait_for_requests wait_for_requests
end end
......
...@@ -12,12 +12,7 @@ describe('AlertsSettingsForm', () => { ...@@ -12,12 +12,7 @@ describe('AlertsSettingsForm', () => {
let wrapper; let wrapper;
const mockToastShow = jest.fn(); const mockToastShow = jest.fn();
const createComponent = ({ const createComponent = ({ data = {}, props = {}, multiIntegrations = true } = {}) => {
data = {},
props = {},
multipleHttpIntegrationsCustomMapping = false,
multiIntegrations = true,
} = {}) => {
wrapper = mount(AlertsSettingsForm, { wrapper = mount(AlertsSettingsForm, {
data() { data() {
return { ...data }; return { ...data };
...@@ -29,7 +24,6 @@ describe('AlertsSettingsForm', () => { ...@@ -29,7 +24,6 @@ describe('AlertsSettingsForm', () => {
}, },
provide: { provide: {
...defaultAlertSettingsConfig, ...defaultAlertSettingsConfig,
glFeatures: { multipleHttpIntegrationsCustomMapping },
multiIntegrations, multiIntegrations,
}, },
mocks: { mocks: {
...@@ -142,27 +136,8 @@ describe('AlertsSettingsForm', () => { ...@@ -142,27 +136,8 @@ describe('AlertsSettingsForm', () => {
describe('submitting integration form', () => { describe('submitting integration form', () => {
describe('HTTP', () => { describe('HTTP', () => {
it('create', async () => {
createComponent();
const integrationName = 'Test integration';
await selectOptionAtIndex(1);
enableIntegration(0, integrationName);
const submitBtn = findSubmitButton();
expect(submitBtn.exists()).toBe(true);
expect(submitBtn.text()).toBe('Save integration');
findForm().trigger('submit');
expect(wrapper.emitted('create-new-integration')[0]).toEqual([
{ type: typeSet.http, variables: { name: integrationName, active: true } },
]);
});
it('create with custom mapping', async () => { it('create with custom mapping', async () => {
createComponent({ createComponent({
multipleHttpIntegrationsCustomMapping: true,
multiIntegrations: true, multiIntegrations: true,
props: { alertFields }, props: { alertFields },
}); });
...@@ -208,9 +183,19 @@ describe('AlertsSettingsForm', () => { ...@@ -208,9 +183,19 @@ describe('AlertsSettingsForm', () => {
findForm().trigger('submit'); findForm().trigger('submit');
expect(wrapper.emitted('update-integration')[0]).toEqual([ expect(wrapper.emitted('update-integration')[0]).toEqual(
{ type: typeSet.http, variables: { name: updatedIntegrationName, active: true } }, expect.arrayContaining([
]); {
type: typeSet.http,
variables: {
name: updatedIntegrationName,
active: true,
payloadAttributeMappings: [],
payloadExample: '{}',
},
},
]),
);
}); });
}); });
...@@ -301,7 +286,6 @@ describe('AlertsSettingsForm', () => { ...@@ -301,7 +286,6 @@ describe('AlertsSettingsForm', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
multipleHttpIntegrationsCustomMapping: true,
data: { data: {
currentIntegration: { currentIntegration: {
type: typeSet.http, type: typeSet.http,
...@@ -408,22 +392,18 @@ describe('AlertsSettingsForm', () => { ...@@ -408,22 +392,18 @@ describe('AlertsSettingsForm', () => {
describe('Mapping builder section', () => { describe('Mapping builder section', () => {
describe.each` describe.each`
alertFieldsProvided | multiIntegrations | featureFlag | integrationOption | visible alertFieldsProvided | multiIntegrations | integrationOption | visible
${true} | ${true} | ${true} | ${1} | ${true} ${true} | ${true} | ${1} | ${true}
${true} | ${true} | ${true} | ${2} | ${false} ${true} | ${true} | ${2} | ${false}
${true} | ${true} | ${false} | ${1} | ${false} ${true} | ${false} | ${1} | ${false}
${true} | ${true} | ${false} | ${2} | ${false} ${false} | ${true} | ${1} | ${false}
${true} | ${false} | ${true} | ${1} | ${false} `('', ({ alertFieldsProvided, multiIntegrations, integrationOption, visible }) => {
${false} | ${true} | ${true} | ${1} | ${false}
`('', ({ alertFieldsProvided, multiIntegrations, featureFlag, integrationOption, visible }) => {
const visibleMsg = visible ? 'is rendered' : 'is not rendered'; const visibleMsg = visible ? 'is rendered' : 'is not rendered';
const featureFlagMsg = featureFlag ? 'is enabled' : 'is disabled';
const alertFieldsMsg = alertFieldsProvided ? 'are provided' : 'are not provided'; const alertFieldsMsg = alertFieldsProvided ? 'are provided' : 'are not provided';
const integrationType = integrationOption === 1 ? typeSet.http : typeSet.prometheus; const integrationType = integrationOption === 1 ? typeSet.http : typeSet.prometheus;
it(`${visibleMsg} when multipleHttpIntegrationsCustomMapping feature flag ${featureFlagMsg} and integration type is ${integrationType} and alert fields ${alertFieldsMsg}`, async () => { it(`${visibleMsg} when integration type is ${integrationType} and alert fields ${alertFieldsMsg}`, async () => {
createComponent({ createComponent({
multipleHttpIntegrationsCustomMapping: featureFlag,
multiIntegrations, multiIntegrations,
props: { props: {
alertFields: alertFieldsProvided ? alertFields : [], alertFields: alertFieldsProvided ? alertFields : [],
......
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