Commit de2fb5b8 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent c6a33b29
......@@ -409,7 +409,6 @@ linters:
- 'ee/app/views/projects/push_rules/_index.html.haml'
- 'ee/app/views/projects/services/gitlab_slack_application/_help.html.haml'
- 'ee/app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml'
- 'ee/app/views/projects/services/prometheus/_metrics.html.haml'
- 'ee/app/views/projects/settings/slacks/edit.html.haml'
- 'ee/app/views/shared/_additional_email_text.html.haml'
- 'ee/app/views/shared/_mirror_update_button.html.haml'
......
<script>
import getJiraProjects from '../queries/getJiraProjects.query.graphql';
import JiraImportForm from './jira_import_form.vue';
import JiraImportSetup from './jira_import_setup.vue';
export default {
name: 'JiraImportApp',
components: {
JiraImportForm,
JiraImportSetup,
},
props: {
......@@ -41,6 +43,6 @@ export default {
<template>
<div>
<jira-import-setup v-if="!isJiraConfigured" :illustration="setupIllustration" />
<div v-else></div>
<jira-import-form v-else />
</div>
</template>
<script>
import { GlAvatar, GlNewButton, GlFormGroup, GlFormSelect, GlLabel } from '@gitlab/ui';
export default {
name: 'JiraImportForm',
components: {
GlAvatar,
GlNewButton,
GlFormGroup,
GlFormSelect,
GlLabel,
},
currentUserAvatarUrl: gon.current_user_avatar_url,
currentUsername: gon.current_username,
};
</script>
<template>
<div>
<h3 class="page-title">{{ __('New Jira import') }}</h3>
<hr />
<form>
<gl-form-group
class="row align-items-center"
:label="__('Import from')"
label-cols-sm="2"
label-for="jira-project-select"
>
<gl-form-select id="jira-project-select" class="mb-2" />
</gl-form-group>
<gl-form-group
class="row align-items-center"
:label="__('Issue label')"
label-cols-sm="2"
label-for="jira-project-label"
>
<gl-label
id="jira-project-label"
class="mb-2"
background-color="#428BCA"
title="jira-import::KEY-1"
scoped
/>
</gl-form-group>
<hr />
<p class="offset-md-1">
{{
__(
"For each Jira issue successfully imported, we'll create a new GitLab issue with the following data:",
)
}}
</p>
<gl-form-group
class="row align-items-center mb-1"
:label="__('Title')"
label-cols-sm="2"
label-for="jira-project-title"
>
<p id="jira-project-title" class="mb-2">{{ __('jira.issue.summary') }}</p>
</gl-form-group>
<gl-form-group
class="row align-items-center mb-1"
:label="__('Reporter')"
label-cols-sm="2"
label-for="jira-project-reporter"
>
<gl-avatar
id="jira-project-reporter"
class="mb-2"
:src="$options.currentUserAvatarUrl"
:size="24"
:aria-label="$options.currentUsername"
/>
</gl-form-group>
<gl-form-group
class="row align-items-center mb-1"
:label="__('Description')"
label-cols-sm="2"
label-for="jira-project-description"
>
<p id="jira-project-description" class="mb-2">{{ __('jira.issue.description.content') }}</p>
</gl-form-group>
<div class="footer-block row-content-block d-flex justify-content-between">
<gl-new-button category="primary" variant="success">{{ __('Next') }}</gl-new-button>
<gl-new-button>{{ __('Cancel') }}</gl-new-button>
</div>
</form>
</div>
</template>
import IntegrationSettingsForm from '~/integrations/integration_settings_form';
import PrometheusMetrics from 'ee_else_ce/prometheus_metrics/prometheus_metrics';
import PrometheusMetrics from '~/prometheus_metrics/custom_metrics';
import PrometheusAlerts from '~/prometheus_alerts';
import initAlertsSettings from '~/alerts_service_settings';
......
......@@ -2,4 +2,5 @@ export default {
EMPTY: 'empty',
LOADING: 'loading',
LIST: 'list',
NO_INTEGRATION: 'no-integration',
};
import $ from 'jquery';
import { escape, sortBy } from 'lodash';
import PrometheusMetrics from './prometheus_metrics';
import PANEL_STATE from './constants';
import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
export default class CustomMetrics extends PrometheusMetrics {
constructor(wrapperSelector) {
super(wrapperSelector);
this.customMetrics = [];
this.environmentsData = [];
this.$els = [];
this.$wrapperCustomMetrics = $(wrapperSelector);
this.$monitoredCustomMetricsPanel = this.$wrapperCustomMetrics.find(
'.js-panel-custom-monitored-metrics',
);
this.$monitoredCustomMetricsCount = this.$monitoredCustomMetricsPanel.find(
'.js-custom-monitored-count',
);
this.$monitoredCustomMetricsLoading = this.$monitoredCustomMetricsPanel.find(
'.js-loading-custom-metrics',
);
this.$monitoredCustomMetricsEmpty = this.$monitoredCustomMetricsPanel.find(
'.js-empty-custom-metrics',
);
this.$monitoredCustomMetricsList = this.$monitoredCustomMetricsPanel.find(
'.js-custom-metrics-list',
);
this.$monitoredCustomMetricsNoIntegrationText = this.$monitoredCustomMetricsPanel.find(
'.js-no-active-integration-text',
);
this.$newCustomMetricButton = this.$monitoredCustomMetricsPanel.find('.js-new-metric-button');
this.$newCustomMetricText = this.$monitoredCustomMetricsPanel.find('.js-new-metric-text');
this.$flashCustomMetricsContainer = this.$wrapperCustomMetrics.find('.flash-container');
this.$els = [
this.$monitoredCustomMetricsLoading,
this.$monitoredCustomMetricsList,
this.$newCustomMetricButton,
this.$newCustomMetricText,
this.$monitoredCustomMetricsNoIntegrationText,
this.$monitoredCustomMetricsEmpty,
];
this.activeCustomMetricsEndpoint = this.$monitoredCustomMetricsPanel.data(
'active-custom-metrics',
);
this.environmentsDataEndpoint = this.$monitoredCustomMetricsPanel.data(
'environments-data-endpoint',
);
this.isServiceActive = this.$monitoredCustomMetricsPanel.data('service-active');
}
init() {
if (this.isServiceActive) {
this.loadActiveCustomMetrics();
} else {
this.setNoIntegrationActiveState();
}
}
// eslint-disable-next-line class-methods-use-this
setHidden(els) {
els.forEach(el => el.addClass('hidden'));
}
setVisible(...els) {
this.setHidden(this.$els.filter(el => !els.includes(el)));
els.forEach(el => el.removeClass('hidden'));
}
showMonitoringCustomMetricsPanelState(stateName) {
switch (stateName) {
case PANEL_STATE.LOADING:
this.setVisible(this.$monitoredCustomMetricsLoading);
break;
case PANEL_STATE.LIST:
this.setVisible(this.$newCustomMetricButton, this.$monitoredCustomMetricsList);
break;
case PANEL_STATE.NO_INTEGRATION:
this.setVisible(
this.$monitoredCustomMetricsNoIntegrationText,
this.$monitoredCustomMetricsEmpty,
);
break;
default:
this.setVisible(
this.$monitoredCustomMetricsEmpty,
this.$newCustomMetricButton,
this.$newCustomMetricText,
);
break;
}
}
populateCustomMetrics() {
const capitalizeGroup = metric => ({
...metric,
group: capitalizeFirstCharacter(metric.group),
});
const sortedMetrics = sortBy(this.customMetrics.map(capitalizeGroup), ['group', 'title']);
sortedMetrics.forEach(metric => {
this.$monitoredCustomMetricsList.append(CustomMetrics.customMetricTemplate(metric));
});
this.$monitoredCustomMetricsCount.text(this.customMetrics.length);
this.showMonitoringCustomMetricsPanelState(PANEL_STATE.LIST);
if (!this.environmentsData) {
this.showFlashMessage(
s__(
'PrometheusService|These metrics will only be monitored after your first deployment to an environment',
),
);
}
}
showFlashMessage(message) {
this.$flashCustomMetricsContainer.removeClass('hidden');
this.$flashCustomMetricsContainer.find('.flash-text').text(message);
}
setNoIntegrationActiveState() {
this.showMonitoringCustomMetricsPanelState(PANEL_STATE.NO_INTEGRATION);
this.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY);
}
loadActiveCustomMetrics() {
super.loadActiveMetrics();
Promise.all([
axios.get(this.activeCustomMetricsEndpoint),
axios.get(this.environmentsDataEndpoint),
])
.then(([customMetrics, environmentsData]) => {
this.environmentsData = environmentsData.data.environments;
if (!customMetrics.data || !customMetrics.data.metrics) {
this.showMonitoringCustomMetricsPanelState(PANEL_STATE.EMPTY);
} else {
this.customMetrics = customMetrics.data.metrics;
this.populateCustomMetrics(customMetrics.data.metrics);
}
})
.catch(customMetricError => {
this.showFlashMessage(customMetricError);
this.showMonitoringCustomMetricsPanelState(PANEL_STATE.EMPTY);
});
}
static customMetricTemplate(metric) {
return `
<li class="custom-metric">
<a href="${escape(metric.edit_path)}" class="custom-metric-link-bold">
${escape(metric.group)} / ${escape(metric.title)} (${escape(metric.unit)})
</a>
</li>
`;
}
}
......@@ -41,6 +41,23 @@ module ClustersHelper
end
end
def cluster_type_label(cluster_type)
case cluster_type
when 'project_type'
s_('ClusterIntegration|Project cluster')
when 'group_type'
s_('ClusterIntegration|Group cluster')
when 'instance_type'
s_('ClusterIntegration|Instance cluster')
else
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(
ArgumentError.new('Cluster Type Missing'),
cluster_error: { error: 'Cluster Type Missing', cluster_type: cluster_type }
)
_('Cluster')
end
end
def has_rbac_enabled?(cluster)
return cluster.platform_kubernetes_rbac? if cluster.platform_kubernetes
......
......@@ -4,7 +4,7 @@ module PerformanceMonitoring
class PrometheusPanel
include ActiveModel::Model
attr_accessor :type, :title, :y_label, :weight, :metrics
attr_accessor :type, :title, :y_label, :weight, :metrics, :y_axis
validates :title, presence: true
validates :metrics, presence: true
......@@ -20,5 +20,9 @@ module PerformanceMonitoring
panel.tap(&:validate!)
end
def id(group_title)
Digest::SHA2.hexdigest([group_title, type, title].join)
end
end
end
......@@ -11,6 +11,7 @@ module Metrics
SEQUENCE = [
STAGES::CommonMetricsInserter,
STAGES::EndpointInserter,
STAGES::PanelIdsInserter,
STAGES::Sorter
].freeze
......
......@@ -10,7 +10,10 @@ module Metrics
class GitlabAlertEmbedService < ::Metrics::Dashboard::BaseEmbedService
include Gitlab::Utils::StrongMemoize
SEQUENCE = [STAGES::EndpointInserter].freeze
SEQUENCE = [
STAGES::EndpointInserter,
STAGES::PanelIdsInserter
].freeze
class << self
# Determines whether the provided params are sufficient
......
......@@ -10,7 +10,8 @@ module Metrics
include ReactiveCaching
SEQUENCE = [
::Gitlab::Metrics::Dashboard::Stages::GrafanaFormatter
::Gitlab::Metrics::Dashboard::Stages::GrafanaFormatter,
::Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter
].freeze
self.reactive_cache_key = ->(service) { service.cache_key }
......
......@@ -11,6 +11,7 @@ module Metrics
SEQUENCE = [
STAGES::EndpointInserter,
STAGES::PanelIdsInserter,
STAGES::Sorter
].freeze
......
......@@ -11,6 +11,7 @@ module Metrics
SEQUENCE = [
STAGES::CustomMetricsInserter,
STAGES::EndpointInserter,
STAGES::PanelIdsInserter,
STAGES::Sorter
].freeze
......
......@@ -13,6 +13,7 @@ module Metrics
STAGES::CustomMetricsInserter,
STAGES::CustomMetricsDetailsInserter,
STAGES::EndpointInserter,
STAGES::PanelIdsInserter,
STAGES::Sorter
].freeze
......
......@@ -4,7 +4,7 @@ module Tags
class CreateService < BaseService
def execute(tag_name, target, message)
valid_tag = Gitlab::GitRefValidator.validate(tag_name)
return error('Tag name invalid') unless valid_tag
return error('Tag name invalid', 400) unless valid_tag
repository = project.repository
message = message&.strip
......@@ -14,7 +14,7 @@ module Tags
begin
new_tag = repository.add_tag(current_user, tag_name, target, message)
rescue Gitlab::Git::Repository::TagExistsError
return error("Tag #{tag_name} already exists")
return error("Tag #{tag_name} already exists", 409)
rescue Gitlab::Git::PreReceiveError => ex
return error(ex.message)
end
......@@ -24,7 +24,7 @@ module Tags
success.merge(tag: new_tag)
else
error("Target #{target} is invalid")
error("Target #{target} is invalid", 400)
end
end
end
......
......@@ -41,7 +41,12 @@
.js-serverless-survey-banner{ data: { user_name: current_user.name, user_email: current_user.email } }
%h4= @cluster.name
.d-flex.my-3
%p.badge.badge-light.p-2.mr-2
= cluster_type_label(@cluster.cluster_type)
%h4.m-0
= @cluster.name
= render 'banner'
- if cluster_created?(@cluster)
......@@ -56,7 +61,3 @@
.tab-content.py-3
.tab-pane.active{ role: 'tabpanel' }
= render_cluster_info_tab_content(params[:tab], expanded_by_default?)
- project = local_assigns.fetch(:project)
.col-lg-3
%p
= s_('PrometheusService|Custom metrics require Prometheus installed on a cluster with environment scope "*" OR a manually configured Prometheus to be available.')
= link_to s_('PrometheusService|More information'), help_page_path('user/project/integrations/prometheus', anchor: 'adding-custom-metrics'), target: '_blank', rel: "noopener noreferrer"
.col-lg-9
.card.custom-monitored-metrics.js-panel-custom-monitored-metrics{ data: { active_custom_metrics: project_prometheus_metrics_path(project), environments_data: environments_list_data, service_active: "#{@service.active}" } }
.card-header
%strong
= s_('PrometheusService|Custom metrics')
-# haml-lint:disable NoPlainNodes
%span.badge.badge-pill.js-custom-monitored-count 0
-# haml-lint:enable NoPlainNodes
= link_to s_('PrometheusService|New metric'), new_project_prometheus_metric_path(project), class: 'btn btn-success js-new-metric-button hidden'
.card-body
.flash-container.hidden
.flash-warning
.flash-text
.loading-metrics.js-loading-custom-metrics
%p.m-3
= icon('spinner spin', class: 'metrics-load-spinner')
= s_('PrometheusService|Finding custom metrics...')
.empty-metrics.hidden.js-empty-custom-metrics
%p.text-tertiary.m-3.js-no-active-integration-text.hidden
= s_('PrometheusService|Enable Prometheus to define custom metrics, using either option above')
%p.text-tertiary.m-3.js-new-metric-text.hidden
= s_('PrometheusService|No custom metrics have been created. Create one using the button above')
%ul.list-unstyled.metrics-list.hidden.js-custom-metrics-list
- project = local_assigns.fetch(:project)
= render 'projects/services/prometheus/custom_metrics', project: project
.col-lg-3
%p
= s_('PrometheusService|Common metrics are automatically monitored based on a library of metrics from popular exporters.')
......
---
title: Fix 500 error on create release API when providing an invalid tag_name
merge_request: 28969
author: Sashi Kumar
type: fixed
---
title: Automatically assign id to each panel within dashboard to support panel scoped annotations
merge_request: 28341
author:
type: added
---
title: Display cluster type in cluster info page
merge_request: 27366
author:
type: added
This diff is collapsed.
......@@ -113,4 +113,4 @@ Validating file hooks from /plugins directory
[system hooks]: ../system_hooks/system_hooks.md
[webhooks]: ../user/project/integrations/webhooks.md
[highly available]: ./high_availability/README.md
[highly available]: ./availability/index.md
......@@ -129,7 +129,7 @@ To configure the connection to the external read-replica database and enable Log
database to keep track of replication status and automatically recover from
potential replication issues. Omnibus automatically configures a tracking database
when `roles ['geo_secondary_role']` is set. For high availability,
refer to [Geo High Availability](../../high_availability/README.md).
refer to [Geo High Availability](../../availability/index.md).
If you want to run this database external to Omnibus, please follow the instructions below.
The tracking database requires an [FDW](https://www.postgresql.org/docs/9.6/postgres-fdw.html)
......
......@@ -47,12 +47,12 @@ It is possible to use cloud hosted services for PostgreSQL and Redis, but this i
## Prerequisites: Two working GitLab HA clusters
One cluster will serve as the **primary** node. Use the
[GitLab HA documentation](../../high_availability/README.md) to set this up. If
[GitLab HA documentation](../../availability/index.md) to set this up. If
you already have a working GitLab instance that is in-use, it can be used as a
**primary**.
The second cluster will serve as the **secondary** node. Again, use the
[GitLab HA documentation](../../high_availability/README.md) to set this up.
[GitLab HA documentation](../../availability/index.md) to set this up.
It's a good idea to log in and test it, however, note that its data will be
wiped out as part of the process of replicating from the **primary**.
......@@ -371,7 +371,7 @@ more information.
The minimal reference architecture diagram above shows all application services
running together on the same machines. However, for high availability we
[strongly recommend running all services separately](../../high_availability/README.md).
[strongly recommend running all services separately](../../availability/index.md).
For example, a Sidekiq server could be configured similarly to the frontend
application servers above, with some changes to run only the `sidekiq` service:
......
......@@ -2,7 +2,7 @@
> - Introduced in GitLab Enterprise Edition 8.9.
> - Using Geo in combination with
> [High Availability](../../high_availability/README.md)
> [High Availability](../../availability/index.md)
> is considered **Generally Available** (GA) in
> [GitLab Premium](https://about.gitlab.com/pricing/) 10.4.
......
......@@ -24,7 +24,7 @@ If you use a cloud-managed service, or provide your own PostgreSQL:
## PostgreSQL in a Scaled and Highly Available Environment
This section is relevant for [Scalable and Highly Available Setups](README.md).
This section is relevant for [Scalable and Highly Available Setups](../scaling/index.md).
### Provide your own PostgreSQL instance **(CORE ONLY)**
......
......@@ -11,7 +11,7 @@ should consider using Gitaly on a separate node.
See the [Gitaly HA Epic](https://gitlab.com/groups/gitlab-org/-/epics/289) to
track plans and progress toward high availability support.
This document is relevant for [Scalable and Highly Available Setups](README.md).
This document is relevant for [Scalable and Highly Available Setups](../scaling/index.md).
## Running Gitaly on its own server
......@@ -19,7 +19,7 @@ See [Running Gitaly on its own server](../gitaly/index.md#running-gitaly-on-its-
in Gitaly documentation.
Continue configuration of other components by going back to the
[Scaling and High Availability](README.md#gitlab-components-and-configuration-instructions) page.
[High Availability](../availability/index.md#gitlab-components-and-configuration-instructions) page.
## Enable Monitoring
......
......@@ -11,7 +11,7 @@ You can configure a Prometheus node to monitor GitLab.
## Standalone Monitoring node using GitLab Omnibus
The GitLab Omnibus package can be used to configure a standalone Monitoring node running [Prometheus](../monitoring/prometheus/index.md) and [Grafana](../monitoring/performance/grafana_configuration.md).
The monitoring node is not highly available. See [Scaling and High Availability](README.md)
The monitoring node is not highly available. See [Scaling and High Availability](../scaling/index.md)
for an overview of GitLab scaling and high availability options.
The steps below are the minimum necessary to configure a Monitoring node running Prometheus and Grafana with
......
......@@ -22,7 +22,7 @@ These will be necessary when configuring the GitLab application servers later.
## Redis in a Scaled and Highly Available Environment
This section is relevant for [Scalable and Highly Available Setups](README.md).
This section is relevant for [Scalable and Highly Available Setups](../scaling/index.md).
### Provide your own Redis instance **(CORE ONLY)**
......@@ -38,7 +38,7 @@ In this configuration Redis is not highly available, and represents a single
point of failure. However, in a scaled environment the objective is to allow
the environment to handle more users or to increase throughput. Redis itself
is generally stable and can handle many requests so it is an acceptable
trade off to have only a single instance. See [Scaling and High Availability](README.md)
trade off to have only a single instance. See [High Availability](../availability/index.md)
for an overview of GitLab scaling and high availability options.
The steps below are the minimum necessary to configure a Redis server with
......@@ -84,7 +84,7 @@ Advanced configuration options are supported and can be added if
needed.
Continue configuration of other components by going back to the
[Scaling and High Availability](README.md#gitlab-components-and-configuration-instructions) page.
[High Availability](../availability/index.md#gitlab-components-and-configuration-instructions) page.
### High Availability with GitLab Omnibus **(PREMIUM ONLY)**
......
......@@ -34,7 +34,7 @@ Learn how to install, configure, update, and maintain your GitLab instance.
- [Install](../install/README.md): Requirements, directory structures, and installation methods.
- [Database load balancing](database_load_balancing.md): Distribute database queries among multiple database servers. **(STARTER ONLY)**
- [Omnibus support for log forwarding](https://docs.gitlab.com/omnibus/settings/logs.html#udp-log-shipping-gitlab-enterprise-edition-only) **(STARTER ONLY)**
- [High Availability](high_availability/README.md): Configure multiple servers for scaling or high availability.
- [High Availability](availability/index.md): Configure multiple servers for scaling or high availability.
- [Installing GitLab HA on Amazon Web Services (AWS)](../install/aws/index.md): Set up GitLab High Availability on Amazon AWS.
- [Geo](geo/replication/index.md): Replicate your GitLab instance to other geographic locations as a read-only fully operational version. **(PREMIUM ONLY)**
- [Disaster Recovery](geo/disaster_recovery/index.md): Quickly fail-over to a different site with minimal effort in a disaster situation. **(PREMIUM ONLY)**
......
......@@ -77,9 +77,8 @@ with the Fog library that GitLab uses. Symptoms include:
### GitLab Pages requires NFS
If you're working to add more GitLab servers for [scaling](scaling/index.md) or
[fault tolerance](high_availability/README.md) and one of your requirements
is [GitLab Pages](../user/project/pages/index.md) this currently requires
If you're working to add more GitLab servers for [scaling or fault tolerance](scaling/index.md)
and one of your requirements is [GitLab Pages](../user/project/pages/index.md) this currently requires
NFS. There is [work in progress](https://gitlab.com/gitlab-org/gitlab-pages/issues/196)
to remove this dependency. In the future, GitLab Pages may use
[object storage](https://gitlab.com/gitlab-org/gitlab/-/issues/208135).
......
......@@ -8,7 +8,7 @@ GitLab supports a number of scaling options to ensure that your self-managed
instance is able to scale out to meet your organization's needs when scaling up
a single-box GitLab installation is no longer practical or feasible.
Please consult our [high availability documentation](../high_availability/README.md)
Please consult our [high availability documentation](../availability/index.md)
if your organization requires fault tolerance and redundancy features, such as
automatic database system failover.
......
......@@ -22,7 +22,7 @@ There are many ways you can install GitLab depending on your platform:
TIP: **If in doubt, choose Omnibus:**
The Omnibus GitLab packages are mature, scalable, support
[high availability](../administration/high_availability/README.md) and are used
[high availability](../administration/availability/index.md) and are used
today on GitLab.com. The Helm charts are recommended for those who are familiar
with Kubernetes.
......@@ -36,7 +36,7 @@ The Omnibus GitLab package uses our official deb/rpm repositories. This is
recommended for most users.
If you need additional flexibility and resilience, we recommend deploying
GitLab as described in our [High Availability documentation](../administration/high_availability/README.md).
GitLab as described in our [High Availability documentation](../administration/availability/index.md).
[**> Install GitLab using the Omnibus GitLab package.**](https://about.gitlab.com/install/)
......
......@@ -719,7 +719,7 @@ Have a read through these other resources and feel free to
[open an issue](https://gitlab.com/gitlab-org/gitlab/issues/new)
to request additional material:
- [GitLab High Availability](../../administration/high_availability/README.md):
- [Scaling GitLab](../../administration/scaling/index.md):
GitLab supports several different types of clustering and high-availability.
- [Geo replication](../../administration/geo/replication/index.md):
Geo is the solution for widely distributed development teams.
......
......@@ -37,10 +37,8 @@ module Gitlab
def for_metrics
missing_panel_groups! unless dashboard[:panel_groups].is_a?(Array)
dashboard[:panel_groups].each do |panel_group|
missing_panels! unless panel_group[:panels].is_a?(Array)
panel_group[:panels].each do |panel|
for_panel_groups do |panel_group|
for_panels_in(panel_group) do |panel|
missing_metrics! unless panel[:metrics].is_a?(Array)
panel[:metrics].each do |metric|
......@@ -49,6 +47,20 @@ module Gitlab
end
end
end
def for_panel_groups
dashboard[:panel_groups].each do |panel_group|
yield panel_group
end
end
def for_panels_in(panel_group)
missing_panels! unless panel_group[:panels].is_a?(Array)
panel_group[:panels].each do |panel|
yield panel
end
end
end
end
end
......
# frozen_string_literal: true
module Gitlab
module Metrics
module Dashboard
module Stages
class PanelIdsInserter < BaseStage
# For each panel within given dashboard inserts panel_id unique in scope of the dashboard
def transform!
missing_panel_groups! unless dashboard[:panel_groups]
for_panels_group_with_panels do |panel_group, panel|
id = generate_panel_id(panel_group, panel)
remove_panel_ids! && break if duplicated_panel_id?(id)
insert_panel_id(id, panel)
end
end
private
def generate_panel_id(group, panel)
::PerformanceMonitoring::PrometheusPanel.new(panel.with_indifferent_access).id(group[:group])
end
def insert_panel_id(id, panel)
track_inserted_panel_ids(id, panel)
panel[:id] = id
end
def track_inserted_panel_ids(id, panel)
panel_ids[id] = panel
end
def duplicated_panel_id?(id)
panel_ids.key?(id)
end
def remove_panel_ids!
panel_ids.each_value { |panel| panel.delete(:id) }
end
def panel_ids
@_panel_ids ||= {}
end
def for_panels_group_with_panels
for_panel_groups do |panel_group|
for_panels_in(panel_group) do |panel|
yield panel_group, panel
end
end
end
end
end
end
end
end
......@@ -4135,6 +4135,9 @@ msgstr ""
msgid "Closes this %{quick_action_target}."
msgstr ""
msgid "Cluster"
msgstr ""
msgid "Cluster Health"
msgstr ""
......@@ -9168,6 +9171,9 @@ msgstr ""
msgid "Footer message"
msgstr ""
msgid "For each Jira issue successfully imported, we'll create a new GitLab issue with the following data:"
msgstr ""
msgid "For internal projects, any logged in user can view pipelines and access job details (output logs and artifacts)"
msgstr ""
......@@ -10897,6 +10903,9 @@ msgstr ""
msgid "Import an exported GitLab project"
msgstr ""
msgid "Import from"
msgstr ""
msgid "Import from Jira"
msgstr ""
......@@ -11304,6 +11313,9 @@ msgstr ""
msgid "Issue first depoloyed to production"
msgstr ""
msgid "Issue label"
msgstr ""
msgid "Issue or Merge Request ID is required"
msgstr ""
......@@ -13311,6 +13323,9 @@ msgid_plural "New Issues"
msgstr[0] ""
msgstr[1] ""
msgid "New Jira import"
msgstr ""
msgid "New Label"
msgstr ""
......@@ -17004,6 +17019,9 @@ msgstr ""
msgid "Reported %{timeAgo} by %{reportedBy}"
msgstr ""
msgid "Reporter"
msgstr ""
msgid "Reporting"
msgstr ""
......@@ -24491,6 +24509,12 @@ msgstr ""
msgid "jigsaw is not defined"
msgstr ""
msgid "jira.issue.description.content"
msgstr ""
msgid "jira.issue.summary"
msgstr ""
msgid "latest"
msgstr ""
......
......@@ -14,6 +14,12 @@ describe 'Clusterable > Show page' do
end
shared_examples 'show page' do
it 'displays cluster type label' do
visit cluster_path
expect(page).to have_content(cluster_type_label)
end
it 'allow the user to set domain' do
visit cluster_path
......@@ -125,7 +131,9 @@ describe 'Clusterable > Show page' do
clusterable.add_maintainer(current_user)
end
it_behaves_like 'show page'
it_behaves_like 'show page' do
let(:cluster_type_label) { 'Project cluster' }
end
it_behaves_like 'editing a GCP cluster'
......@@ -143,7 +151,9 @@ describe 'Clusterable > Show page' do
clusterable.add_maintainer(current_user)
end
it_behaves_like 'show page'
it_behaves_like 'show page' do
let(:cluster_type_label) { 'Group cluster' }
end
it_behaves_like 'editing a GCP cluster'
......@@ -157,7 +167,9 @@ describe 'Clusterable > Show page' do
let(:cluster_path) { admin_cluster_path(cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
it_behaves_like 'show page'
it_behaves_like 'show page' do
let(:cluster_type_label) { 'Instance cluster' }
end
it_behaves_like 'editing a GCP cluster'
......
......@@ -7,6 +7,7 @@
],
"properties": {
"title": { "type": "string" },
"id": { "type": "string" },
"type": { "type": "string" },
"y_label": { "type": "string" },
"y_axis": { "$ref": "axis.json" },
......
import { GlAvatar, GlNewButton, GlFormSelect, GlLabel } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import JiraImportForm from '~/jira_import/components/jira_import_form.vue';
describe('JiraImportForm', () => {
let wrapper;
beforeEach(() => {
wrapper = shallowMount(JiraImportForm);
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('shows a dropdown to choose the Jira project to import from', () => {
expect(wrapper.find(GlFormSelect).exists()).toBe(true);
});
it('shows a label which will be applied to imported Jira projects', () => {
expect(wrapper.find(GlLabel).attributes('title')).toBe('jira-import::KEY-1');
});
it('shows information to the user', () => {
expect(wrapper.find('p').text()).toBe(
"For each Jira issue successfully imported, we'll create a new GitLab issue with the following data:",
);
});
it('shows jira.issue.summary for the Title', () => {
expect(wrapper.find('[id="jira-project-title"]').text()).toBe('jira.issue.summary');
});
it('shows an avatar for the Reporter', () => {
expect(wrapper.find(GlAvatar).exists()).toBe(true);
});
it('shows jira.issue.description.content for the Description', () => {
expect(wrapper.find('[id="jira-project-description"]').text()).toBe(
'jira.issue.description.content',
);
});
it('shows a Next button', () => {
const nextButton = wrapper
.findAll(GlNewButton)
.at(0)
.text();
expect(nextButton).toBe('Next');
});
it('shows a Cancel button', () => {
const cancelButton = wrapper
.findAll(GlNewButton)
.at(1)
.text();
expect(cancelButton).toBe('Cancel');
});
});
import MockAdapter from 'axios-mock-adapter';
import PrometheusMetrics from '~/prometheus_metrics/custom_metrics';
import axios from '~/lib/utils/axios_utils';
import PANEL_STATE from '~/prometheus_metrics/constants';
import metrics from './mock_data';
describe('PrometheusMetrics', () => {
const FIXTURE = 'services/prometheus/prometheus_service.html';
const customMetricsEndpoint =
'http://test.host/frontend-fixtures/services-project/prometheus/metrics';
let mock;
preloadFixtures(FIXTURE);
beforeEach(() => {
mock = new MockAdapter(axios);
mock.onGet(customMetricsEndpoint).reply(200, {
metrics,
});
loadFixtures(FIXTURE);
});
afterEach(() => {
mock.restore();
});
describe('Custom Metrics', () => {
let prometheusMetrics;
beforeEach(() => {
prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring');
});
it('should initialize wrapper element refs on the class object', () => {
expect(prometheusMetrics.$wrapperCustomMetrics).not.toBeNull();
expect(prometheusMetrics.$monitoredCustomMetricsPanel).not.toBeNull();
expect(prometheusMetrics.$monitoredCustomMetricsCount).not.toBeNull();
expect(prometheusMetrics.$monitoredCustomMetricsLoading).not.toBeNull();
expect(prometheusMetrics.$monitoredCustomMetricsEmpty).not.toBeNull();
expect(prometheusMetrics.$monitoredCustomMetricsList).not.toBeNull();
expect(prometheusMetrics.$newCustomMetricButton).not.toBeNull();
expect(prometheusMetrics.$flashCustomMetricsContainer).not.toBeNull();
});
it('should contain api endpoints', () => {
expect(prometheusMetrics.activeCustomMetricsEndpoint).toEqual(customMetricsEndpoint);
});
it('should show loading state when called with `loading`', () => {
prometheusMetrics.showMonitoringCustomMetricsPanelState(PANEL_STATE.LOADING);
expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toEqual(false);
expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toBeTruthy();
expect(
prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'),
).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy();
});
it('should show metrics list when called with `list`', () => {
prometheusMetrics.showMonitoringCustomMetricsPanelState(PANEL_STATE.LIST);
expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toEqual(false);
expect(
prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'),
).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toEqual(false);
expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy();
});
it('should show empty state when called with `empty`', () => {
prometheusMetrics.showMonitoringCustomMetricsPanelState(PANEL_STATE.EMPTY);
expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toEqual(false);
expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toBeTruthy();
expect(
prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'),
).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toEqual(false);
expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toEqual(false);
});
it('should show monitored metrics list', () => {
prometheusMetrics.customMetrics = metrics;
prometheusMetrics.populateCustomMetrics();
const $metricsListLi = prometheusMetrics.$monitoredCustomMetricsList.find('li');
expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toEqual(false);
expect(
prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'),
).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toEqual(false);
expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy();
expect($metricsListLi.length).toEqual(metrics.length);
});
it('should show the NO-INTEGRATION empty state', () => {
prometheusMetrics.setNoIntegrationActiveState();
expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toEqual(false);
expect(prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden')).toEqual(
false,
);
expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toBeTruthy();
expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy();
});
});
});
const metrics = [
{
edit_path: '/root/prometheus-test/prometheus/metrics/3/edit',
id: 3,
title: 'Requests',
group: 'Business',
},
{
edit_path: '/root/prometheus-test/prometheus/metrics/2/edit',
id: 2,
title: 'Sales by the hour',
group: 'Business',
},
{
edit_path: '/root/prometheus-test/prometheus/metrics/1/edit',
id: 1,
title: 'Requests',
group: 'Business',
},
];
export default metrics;
......@@ -58,4 +58,39 @@ describe ClustersHelper do
it { is_expected.to eq('Create new cluster') }
end
end
describe '#cluster_type_label' do
subject { helper.cluster_type_label(cluster_type) }
context 'project cluster' do
let(:cluster_type) { 'project_type' }
it { is_expected.to eq('Project cluster') }
end
context 'group cluster' do
let(:cluster_type) { 'group_type' }
it { is_expected.to eq('Group cluster') }
end
context 'instance cluster' do
let(:cluster_type) { 'instance_type' }
it { is_expected.to eq('Instance cluster') }
end
context 'other values' do
let(:cluster_type) { 'not_supported' }
it 'Diplays generic cluster and reports error' do
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).with(
an_instance_of(ArgumentError),
cluster_error: { error: 'Cluster Type Missing', cluster_type: 'not_supported' }
)
is_expected.to eq('Cluster')
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter do
let(:project) { build_stubbed(:project) }
def fetch_panel_ids(dashboard_hash)
dashboard_hash[:panel_groups].flat_map { |group| group[:panels].flat_map { |panel| panel[:id] } }
end
describe '#transform!' do
subject(:transform!) { described_class.new(project, dashboard, nil).transform! }
let(:dashboard) { YAML.safe_load(fixture_file('lib/gitlab/metrics/dashboard/sample_dashboard.yml')).deep_symbolize_keys }
context 'when dashboard panels are present' do
it 'assigns unique ids to each panel using PerformanceMonitoring::PrometheusPanel', :aggregate_failures do
dashboard.fetch(:panel_groups).each do |group|
group.fetch(:panels).each do |panel|
panel_double = instance_double(::PerformanceMonitoring::PrometheusPanel)
expect(::PerformanceMonitoring::PrometheusPanel).to receive(:new).with(panel).and_return(panel_double)
expect(panel_double).to receive(:id).with(group[:group]).and_return(FFaker::Lorem.unique.characters(125))
end
end
transform!
expect(fetch_panel_ids(dashboard)).not_to include nil
end
end
context 'when dashboard panels has duplicated ids' do
it 'no panel has assigned id' do
panel_double = instance_double(::PerformanceMonitoring::PrometheusPanel)
allow(::PerformanceMonitoring::PrometheusPanel).to receive(:new).and_return(panel_double)
allow(panel_double).to receive(:id).and_return('duplicated id')
transform!
expect(fetch_panel_ids(dashboard)).to all be_nil
expect(fetch_panel_ids(dashboard)).not_to include 'duplicated id'
end
end
context 'when there are no panels in the dashboard' do
it 'raises a processing error' do
dashboard[:panel_groups][0].delete(:panels)
expect { transform! }.to(
raise_error(::Gitlab::Metrics::Dashboard::Errors::DashboardProcessingError)
)
end
end
context 'when there are no panel_groups in the dashboard' do
it 'raises a processing error' do
dashboard.delete(:panel_groups)
expect { transform! }.to(
raise_error(::Gitlab::Metrics::Dashboard::Errors::DashboardProcessingError)
)
end
end
end
end
......@@ -702,10 +702,10 @@ describe API::Releases do
context 'when tag name is HEAD' do
let(:tag_name) { 'HEAD' }
it 'returns an error as failure on tag creation' do
it 'returns a 400 error as failure on tag creation' do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Tag name invalid')
end
end
......@@ -713,10 +713,10 @@ describe API::Releases do
context 'when tag name is empty' do
let(:tag_name) { '' }
it 'returns an error as failure on tag creation' do
it 'returns a 400 error as failure on tag creation' do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Tag name invalid')
end
end
......
......@@ -21,8 +21,9 @@ describe Tags::CreateService do
it 'returns an error' do
response = service.execute('v1.1.0', 'foo', 'Foo')
expect(response).to eq(status: :error,
message: 'Target foo is invalid')
expect(response[:status]).to eq(:error)
expect(response[:http_status]).to eq(400)
expect(response[:message]).to eq('Target foo is invalid')
end
end
......@@ -34,8 +35,19 @@ describe Tags::CreateService do
response = service.execute('v1.1.0', 'master', 'Foo')
expect(response).to eq(status: :error,
message: 'Tag v1.1.0 already exists')
expect(response[:status]).to eq(:error)
expect(response[:http_status]).to eq(409)
expect(response[:message]).to eq('Tag v1.1.0 already exists')
end
end
context 'when tag name is invalid' do
it 'returns an error' do
response = service.execute('HEAD', 'master', 'Foo')
expect(response[:status]).to eq(:error)
expect(response[:http_status]).to eq(400)
expect(response[:message]).to eq('Tag name invalid')
end
end
......@@ -47,8 +59,8 @@ describe Tags::CreateService do
response = service.execute('v1.1.0', 'master', 'Foo')
expect(response).to eq(status: :error,
message: 'something went wrong')
expect(response[:status]).to eq(:error)
expect(response[:message]).to eq('something went wrong')
end
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