Commit 57e3d49f authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 33185181
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
GlModalDirective, GlModalDirective,
GlTooltipDirective, GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { s__ } from '~/locale';
import createFlash from '~/flash'; import createFlash from '~/flash';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { getParameterValues, mergeUrlParams, redirectTo } from '~/lib/utils/url_utility'; import { getParameterValues, mergeUrlParams, redirectTo } from '~/lib/utils/url_utility';
...@@ -167,6 +167,7 @@ export default { ...@@ -167,6 +167,7 @@ export default {
formIsValid: null, formIsValid: null,
selectedTimeWindow: {}, selectedTimeWindow: {},
isRearrangingPanels: false, isRearrangingPanels: false,
hasValidDates: true,
}; };
}, },
computed: { computed: {
...@@ -185,7 +186,9 @@ export default { ...@@ -185,7 +186,9 @@ export default {
'additionalPanelTypesEnabled', 'additionalPanelTypesEnabled',
]), ]),
firstDashboard() { firstDashboard() {
return this.allDashboards[0] || {}; return this.environmentsEndpoint.length > 0 && this.allDashboards.length > 0
? this.allDashboards[0]
: {};
}, },
selectedDashboard() { selectedDashboard() {
return this.allDashboards.find(d => d.path === this.currentDashboard) || this.firstDashboard; return this.allDashboards.find(d => d.path === this.currentDashboard) || this.firstDashboard;
...@@ -199,9 +202,6 @@ export default { ...@@ -199,9 +202,6 @@ export default {
addingMetricsAvailable() { addingMetricsAvailable() {
return IS_EE && this.canAddMetrics && !this.showEmptyState; return IS_EE && this.canAddMetrics && !this.showEmptyState;
}, },
alertWidgetAvailable() {
return IS_EE && this.prometheusAlertsAvailable && this.alertsEndpoint;
},
hasHeaderButtons() { hasHeaderButtons() {
return ( return (
this.addingMetricsAvailable || this.addingMetricsAvailable ||
...@@ -237,8 +237,10 @@ export default { ...@@ -237,8 +237,10 @@ export default {
this.selectedTimeWindow = range; this.selectedTimeWindow = range;
if (!isValidDate(start) || !isValidDate(end)) { if (!isValidDate(start) || !isValidDate(end)) {
this.hasValidDates = false;
this.showInvalidDateError(); this.showInvalidDateError();
} else { } else {
this.hasValidDates = true;
this.fetchData(range); this.fetchData(range);
} }
} }
...@@ -248,44 +250,13 @@ export default { ...@@ -248,44 +250,13 @@ export default {
'fetchData', 'fetchData',
'setGettingStartedEmptyState', 'setGettingStartedEmptyState',
'setEndpoints', 'setEndpoints',
'setDashboardEnabled',
'setPanelGroupMetrics', 'setPanelGroupMetrics',
]), ]),
chartsWithData(charts) { chartsWithData(charts) {
if (!this.useDashboardEndpoint) {
return charts;
}
return charts.filter(chart => return charts.filter(chart =>
chart.metrics.some(metric => this.metricsWithData.includes(metric.metric_id)), chart.metrics.some(metric => this.metricsWithData.includes(metric.metric_id)),
); );
}, },
csvText(graphData) {
const chartData = graphData.queries[0].result[0].values;
const yLabel = graphData.y_label;
const header = `timestamp,${yLabel}\r\n`; // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
return chartData.reduce((csv, data) => {
const row = data.join(',');
return `${csv}${row}\r\n`;
}, header);
},
downloadCsv(graphData) {
const data = new Blob([this.csvText(graphData)], { type: 'text/plain' });
return window.URL.createObjectURL(data);
},
// TODO: BEGIN, Duplicated code with panel_type until feature flag is removed
// Issue number: https://gitlab.com/gitlab-org/gitlab-foss/issues/63845
getGraphAlerts(queries) {
if (!this.allAlerts) return {};
const metricIdsForChart = queries.map(q => q.metricId);
return _.pick(this.allAlerts, alert => metricIdsForChart.includes(alert.metricId));
},
getGraphAlertValues(queries) {
return Object.values(this.getGraphAlerts(queries));
},
showToast() {
this.$toast.show(__('Link copied'));
},
// TODO: END
updateMetrics(key, metrics) { updateMetrics(key, metrics) {
this.setPanelGroupMetrics({ this.setPanelGroupMetrics({
metrics, metrics,
...@@ -298,6 +269,11 @@ export default { ...@@ -298,6 +269,11 @@ export default {
key, key,
}); });
}, },
removeGraph(metrics, graphIndex) {
// At present graphs will not be removed, they should removed using the vuex store
// See https://gitlab.com/gitlab-org/gitlab/issues/27835
metrics.splice(graphIndex, 1);
},
showInvalidDateError() { showInvalidDateError() {
createFlash(s__('Metrics|Link contains an invalid time window.')); createFlash(s__('Metrics|Link contains an invalid time window.'));
}, },
...@@ -387,7 +363,7 @@ export default { ...@@ -387,7 +363,7 @@ export default {
</gl-form-group> </gl-form-group>
<gl-form-group <gl-form-group
v-if="!showEmptyState" v-if="hasValidDates"
:label="s__('Metrics|Show last')" :label="s__('Metrics|Show last')"
label-size="sm" label-size="sm"
label-for="monitor-time-window-dropdown" label-for="monitor-time-window-dropdown"
...@@ -480,109 +456,40 @@ export default { ...@@ -480,109 +456,40 @@ export default {
:show-panels="showPanels" :show-panels="showPanels"
:collapse-group="groupHasData(groupData)" :collapse-group="groupHasData(groupData)"
> >
<template v-if="additionalPanelTypesEnabled"> <vue-draggable
<vue-draggable :value="groupData.metrics"
:value="groupData.metrics" group="metrics-dashboard"
group="metrics-dashboard" :component-data="{ attrs: { class: 'row mx-0 w-100' } }"
:component-data="{ attrs: { class: 'row mx-0 w-100' } }" :disabled="!isRearrangingPanels"
:disabled="!isRearrangingPanels" @input="updateMetrics(groupData.key, $event)"
@input="updateMetrics(groupData.key, $event)" >
<div
v-for="(graphData, graphIndex) in groupData.metrics"
:key="`panel-type-${graphIndex}`"
class="col-12 col-lg-6 px-2 mb-2 draggable"
:class="{ 'draggable-enabled': isRearrangingPanels }"
> >
<div <div class="position-relative draggable-panel js-draggable-panel">
v-for="(graphData, graphIndex) in groupData.metrics" <div
:key="`panel-type-${graphIndex}`" v-if="isRearrangingPanels"
class="col-12 col-lg-6 px-2 mb-2 draggable" class="draggable-remove js-draggable-remove p-2 w-100 position-absolute d-flex justify-content-end"
:class="{ 'draggable-enabled': isRearrangingPanels }" @click="removeGraph(groupData.metrics, graphIndex)"
> >
<div class="position-relative draggable-panel js-draggable-panel"> <a class="mx-2 p-2 draggable-remove-link" :aria-label="__('Remove')"
<div ><icon name="close"
v-if="isRearrangingPanels" /></a>
class="draggable-remove js-draggable-remove p-2 w-100 position-absolute d-flex justify-content-end"
@click="removeMetric(groupData.key, groupData.metrics, graphIndex)"
>
<a class="mx-2 p-2 draggable-remove-link" :aria-label="__('Remove')"
><icon name="close"
/></a>
</div>
<panel-type
:clipboard-text="
generateLink(groupData.group, graphData.title, graphData.y_label)
"
:graph-data="graphData"
:alerts-endpoint="alertsEndpoint"
:prometheus-alerts-available="prometheusAlertsAvailable"
:index="`${index}-${graphIndex}`"
/>
</div> </div>
</div>
</vue-draggable> <panel-type
</template> :clipboard-text="generateLink(groupData.group, graphData.title, graphData.y_label)"
<template v-else> :graph-data="graphData"
<monitor-time-series-chart
v-for="(graphData, graphIndex) in chartsWithData(groupData.metrics)"
:key="graphIndex"
class="col-12 col-lg-6 pb-3"
:graph-data="graphData"
:deployment-data="deploymentData"
:thresholds="getGraphAlertValues(graphData.queries)"
:project-path="projectPath"
group-id="monitor-time-series-chart"
>
<div
class="d-flex align-items-center"
:class="alertWidgetAvailable ? 'justify-content-between' : 'justify-content-end'"
>
<alert-widget
v-if="alertWidgetAvailable && graphData"
:modal-id="`alert-modal-${index}-${graphIndex}`"
:alerts-endpoint="alertsEndpoint" :alerts-endpoint="alertsEndpoint"
:relevant-queries="graphData.queries" :prometheus-alerts-available="prometheusAlertsAvailable"
:alerts-to-manage="getGraphAlerts(graphData.queries)" :index="`${index}-${graphIndex}`"
@setAlerts="setAlerts"
/> />
<gl-dropdown
v-gl-tooltip
class="ml-2 mr-3"
toggle-class="btn btn-transparent border-0"
:right="true"
:no-caret="true"
:title="__('More actions')"
>
<template slot="button-content">
<icon name="ellipsis_v" class="text-secondary" />
</template>
<gl-dropdown-item
v-track-event="downloadCSVOptions(graphData.title)"
:href="downloadCsv(graphData)"
download="chart_metrics.csv"
>
{{ __('Download CSV') }}
</gl-dropdown-item>
<gl-dropdown-item
v-track-event="
generateLinkToChartOptions(
generateLink(groupData.group, graphData.title, graphData.y_label),
)
"
class="js-chart-link"
:data-clipboard-text="
generateLink(groupData.group, graphData.title, graphData.y_label)
"
@click="showToast"
>
{{ __('Generate link to chart') }}
</gl-dropdown-item>
<gl-dropdown-item
v-if="alertWidgetAvailable"
v-gl-modal="`alert-modal-${index}-${graphIndex}`"
>
{{ __('Alerts') }}
</gl-dropdown-item>
</gl-dropdown>
</div> </div>
</monitor-time-series-chart> </div>
</template> </vue-draggable>
</graph-group> </graph-group>
</div> </div>
<empty-state <empty-state
......
...@@ -56,16 +56,10 @@ export default { ...@@ -56,16 +56,10 @@ export default {
}, },
}, },
mounted() { mounted() {
const range = getTimeWindow(this.selectedTimeWindow); this.verifyTimeRange();
if (range) { },
this.selectedTimeWindowText = this.timeWindows[range]; updated() {
} else { this.verifyTimeRange();
this.customTime = {
from: truncateZerosInDateTime(ISODateToString(this.selectedTimeWindow.start)),
to: truncateZerosInDateTime(ISODateToString(this.selectedTimeWindow.end)),
};
this.selectedTimeWindowText = sprintf(s__('%{from} to %{to}'), this.customTime);
}
}, },
methods: { methods: {
activeTimeWindow(key) { activeTimeWindow(key) {
...@@ -87,6 +81,18 @@ export default { ...@@ -87,6 +81,18 @@ export default {
closeDropdown() { closeDropdown() {
this.$refs.dropdown.hide(); this.$refs.dropdown.hide();
}, },
verifyTimeRange() {
const range = getTimeWindow(this.selectedTimeWindow);
if (range) {
this.selectedTimeWindowText = this.timeWindows[range];
} else {
this.customTime = {
from: truncateZerosInDateTime(ISODateToString(this.selectedTimeWindow.start)),
to: truncateZerosInDateTime(ISODateToString(this.selectedTimeWindow.end)),
};
this.selectedTimeWindowText = sprintf(s__('%{from} to %{to}'), this.customTime);
}
},
}, },
}; };
</script> </script>
......
...@@ -78,9 +78,6 @@ export default { ...@@ -78,9 +78,6 @@ export default {
}, sidebarAnimationDuration); }, sidebarAnimationDuration);
}, },
setInitialState() { setInitialState() {
this.setFeatureFlags({
prometheusEndpointEnabled: true,
});
this.setEndpoints({ this.setEndpoints({
dashboardEndpoint: removeParams(['start', 'end'], this.dashboardUrl), dashboardEndpoint: removeParams(['start', 'end'], this.dashboardUrl),
}); });
......
...@@ -11,13 +11,6 @@ export default (props = {}) => { ...@@ -11,13 +11,6 @@ export default (props = {}) => {
const el = document.getElementById('prometheus-graphs'); const el = document.getElementById('prometheus-graphs');
if (el && el.dataset) { if (el && el.dataset) {
if (gon.features) {
store.dispatch('monitoringDashboard/setFeatureFlags', {
prometheusEndpointEnabled: gon.features.environmentMetricsUsePrometheusEndpoint,
additionalPanelTypesEnabled: gon.features.environmentMetricsAdditionalPanelTypes,
});
}
const [currentDashboard] = getParameterValues('dashboard'); const [currentDashboard] = getParameterValues('dashboard');
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
......
...@@ -35,14 +35,6 @@ export const setEndpoints = ({ commit }, endpoints) => { ...@@ -35,14 +35,6 @@ export const setEndpoints = ({ commit }, endpoints) => {
commit(types.SET_ENDPOINTS, endpoints); commit(types.SET_ENDPOINTS, endpoints);
}; };
export const setFeatureFlags = (
{ commit },
{ prometheusEndpointEnabled, additionalPanelTypesEnabled },
) => {
commit(types.SET_DASHBOARD_ENABLED, prometheusEndpointEnabled);
commit(types.SET_ADDITIONAL_PANEL_TYPES_ENABLED, additionalPanelTypesEnabled);
};
export const setShowErrorBanner = ({ commit }, enabled) => { export const setShowErrorBanner = ({ commit }, enabled) => {
commit(types.SET_SHOW_ERROR_BANNER, enabled); commit(types.SET_SHOW_ERROR_BANNER, enabled);
}; };
...@@ -79,29 +71,7 @@ export const fetchData = ({ dispatch }, params) => { ...@@ -79,29 +71,7 @@ export const fetchData = ({ dispatch }, params) => {
dispatch('fetchEnvironmentsData'); dispatch('fetchEnvironmentsData');
}; };
export const fetchMetricsData = ({ state, dispatch }, params) => { export const fetchMetricsData = ({ dispatch }, params) => dispatch('fetchDashboard', params);
if (state.useDashboardEndpoint) {
return dispatch('fetchDashboard', params);
}
dispatch('requestMetricsData');
return backOffRequest(() => axios.get(state.metricsEndpoint, { params }))
.then(resp => resp.data)
.then(response => {
if (!response || !response.data || !response.success) {
dispatch('receiveMetricsDataFailure', null);
createFlash(s__('Metrics|Unexpected metrics data response from prometheus endpoint'));
}
dispatch('receiveMetricsDataSuccess', response.data);
})
.catch(error => {
dispatch('receiveMetricsDataFailure', error);
if (state.setShowErrorBanner) {
createFlash(s__('Metrics|There was an error while retrieving metrics'));
}
});
};
export const fetchDashboard = ({ state, dispatch }, params) => { export const fetchDashboard = ({ state, dispatch }, params) => {
dispatch('requestMetricsDashboard'); dispatch('requestMetricsDashboard');
......
...@@ -9,8 +9,6 @@ export const RECEIVE_ENVIRONMENTS_DATA_SUCCESS = 'RECEIVE_ENVIRONMENTS_DATA_SUCC ...@@ -9,8 +9,6 @@ export const RECEIVE_ENVIRONMENTS_DATA_SUCCESS = 'RECEIVE_ENVIRONMENTS_DATA_SUCC
export const RECEIVE_ENVIRONMENTS_DATA_FAILURE = 'RECEIVE_ENVIRONMENTS_DATA_FAILURE'; export const RECEIVE_ENVIRONMENTS_DATA_FAILURE = 'RECEIVE_ENVIRONMENTS_DATA_FAILURE';
export const SET_QUERY_RESULT = 'SET_QUERY_RESULT'; export const SET_QUERY_RESULT = 'SET_QUERY_RESULT';
export const SET_TIME_WINDOW = 'SET_TIME_WINDOW'; export const SET_TIME_WINDOW = 'SET_TIME_WINDOW';
export const SET_DASHBOARD_ENABLED = 'SET_DASHBOARD_ENABLED';
export const SET_ADDITIONAL_PANEL_TYPES_ENABLED = 'SET_ADDITIONAL_PANEL_TYPES_ENABLED';
export const SET_ALL_DASHBOARDS = 'SET_ALL_DASHBOARDS'; export const SET_ALL_DASHBOARDS = 'SET_ALL_DASHBOARDS';
export const SET_ENDPOINTS = 'SET_ENDPOINTS'; export const SET_ENDPOINTS = 'SET_ENDPOINTS';
export const SET_GETTING_STARTED_EMPTY_STATE = 'SET_GETTING_STARTED_EMPTY_STATE'; export const SET_GETTING_STARTED_EMPTY_STATE = 'SET_GETTING_STARTED_EMPTY_STATE';
......
...@@ -25,12 +25,10 @@ export default { ...@@ -25,12 +25,10 @@ export default {
// for backwards compatibility, and to limit Vue template changes: // for backwards compatibility, and to limit Vue template changes:
// for each group alias panels to metrics // for each group alias panels to metrics
// for each panel alias metrics to queries // for each panel alias metrics to queries
if (state.useDashboardEndpoint) { metrics = panels.map(panel => ({
metrics = panels.map(panel => ({ ...panel,
...panel, queries: panel.metrics,
queries: panel.metrics, }));
}));
}
return { return {
...group, ...group,
...@@ -42,8 +40,6 @@ export default { ...@@ -42,8 +40,6 @@ export default {
if (!state.dashboard.panel_groups.length) { if (!state.dashboard.panel_groups.length) {
state.emptyState = 'noData'; state.emptyState = 'noData';
} else {
state.showEmptyState = false;
} }
}, },
[types.RECEIVE_METRICS_DATA_FAILURE](state, error) { [types.RECEIVE_METRICS_DATA_FAILURE](state, error) {
...@@ -90,9 +86,6 @@ export default { ...@@ -90,9 +86,6 @@ export default {
state.currentDashboard = endpoints.currentDashboard; state.currentDashboard = endpoints.currentDashboard;
state.projectPath = endpoints.projectPath; state.projectPath = endpoints.projectPath;
}, },
[types.SET_DASHBOARD_ENABLED](state, enabled) {
state.useDashboardEndpoint = enabled;
},
[types.SET_GETTING_STARTED_EMPTY_STATE](state) { [types.SET_GETTING_STARTED_EMPTY_STATE](state) {
state.emptyState = 'gettingStarted'; state.emptyState = 'gettingStarted';
}, },
...@@ -103,9 +96,6 @@ export default { ...@@ -103,9 +96,6 @@ export default {
[types.SET_ALL_DASHBOARDS](state, dashboards) { [types.SET_ALL_DASHBOARDS](state, dashboards) {
state.allDashboards = dashboards; state.allDashboards = dashboards;
}, },
[types.SET_ADDITIONAL_PANEL_TYPES_ENABLED](state, enabled) {
state.additionalPanelTypesEnabled = enabled;
},
[types.SET_SHOW_ERROR_BANNER](state, enabled) { [types.SET_SHOW_ERROR_BANNER](state, enabled) {
state.showErrorBanner = enabled; state.showErrorBanner = enabled;
}, },
......
...@@ -7,8 +7,6 @@ export default () => ({ ...@@ -7,8 +7,6 @@ export default () => ({
environmentsEndpoint: null, environmentsEndpoint: null,
deploymentsEndpoint: null, deploymentsEndpoint: null,
dashboardEndpoint: invalidUrl, dashboardEndpoint: invalidUrl,
useDashboardEndpoint: false,
additionalPanelTypesEnabled: false,
emptyState: 'gettingStarted', emptyState: 'gettingStarted',
showEmptyState: true, showEmptyState: true,
showErrorBanner: true, showErrorBanner: true,
......
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
:title="tooltipText" :title="tooltipText"
:class="cssClass" :class="cssClass"
:disabled="isDisabled" :disabled="isDisabled"
class="js-ci-action btn btn-blank btn-transparent ci-action-icon-container ci-action-icon-wrapper" class="js-ci-action btn btn-blank btn-transparent ci-action-icon-container ci-action-icon-wrapper d-flex align-items-center justify-content-center"
@click="onClickAction" @click="onClickAction"
> >
<gl-loading-icon v-if="isLoading" class="js-action-icon-loading" /> <gl-loading-icon v-if="isLoading" class="js-action-icon-loading" />
......
...@@ -871,7 +871,7 @@ button.mini-pipeline-graph-dropdown-toggle { ...@@ -871,7 +871,7 @@ button.mini-pipeline-graph-dropdown-toggle {
height: $ci-action-dropdown-svg-size; height: $ci-action-dropdown-svg-size;
fill: $gl-text-color-secondary; fill: $gl-text-color-secondary;
position: relative; position: relative;
top: 1px; top: auto;
vertical-align: initial; vertical-align: initial;
} }
} }
......
...@@ -13,8 +13,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -13,8 +13,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
before_action :verify_api_request!, only: :terminal_websocket_authorize before_action :verify_api_request!, only: :terminal_websocket_authorize
before_action :expire_etag_cache, only: [:index] before_action :expire_etag_cache, only: [:index]
before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do
push_frontend_feature_flag(:environment_metrics_use_prometheus_endpoint, default_enabled: true)
push_frontend_feature_flag(:environment_metrics_additional_panel_types)
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
end end
......
...@@ -16,6 +16,8 @@ class GrafanaIntegration < ApplicationRecord ...@@ -16,6 +16,8 @@ class GrafanaIntegration < ApplicationRecord
validates :enabled, inclusion: { in: [true, false] } validates :enabled, inclusion: { in: [true, false] }
scope :enabled, -> { where(enabled: true) }
def client def client
return unless enabled? return unless enabled?
......
...@@ -16,7 +16,7 @@ In addition to this page, the following resources can help you craft and contrib ...@@ -16,7 +16,7 @@ In addition to this page, the following resources can help you craft and contrib
## Source files and rendered web locations ## Source files and rendered web locations
Documentation for GitLab, GitLab Runner, Omnibus GitLab and Charts are published to <https://docs.gitlab.com>. Documentation for GitLab is also published within the application at `/help` on the domain of the GitLab instance. Documentation for GitLab, GitLab Runner, Omnibus GitLab and Charts is published to <https://docs.gitlab.com>. Documentation for GitLab is also published within the application at `/help` on the domain of the GitLab instance.
At `/help`, only help for your current edition and version is included. Help for other versions is available at <https://docs.gitlab.com/archives/>. At `/help`, only help for your current edition and version is included. Help for other versions is available at <https://docs.gitlab.com/archives/>.
The source of the documentation exists within the codebase of each GitLab application in the following repository locations: The source of the documentation exists within the codebase of each GitLab application in the following repository locations:
......
...@@ -588,7 +588,7 @@ You can specify a different Git repository by providing it as an extra parameter ...@@ -588,7 +588,7 @@ You can specify a different Git repository by providing it as an extra parameter
sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse,https://example.com/gitlab-workhorse.git]" RAILS_ENV=production sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse,https://example.com/gitlab-workhorse.git]" RAILS_ENV=production
``` ```
### Install GitLab-Elasticsearch-indexer` ### Install GitLab-Elasticsearch-indexer
GitLab-Elasticsearch-Indexer uses [GNU Make](https://www.gnu.org/software/make/). The GitLab-Elasticsearch-Indexer uses [GNU Make](https://www.gnu.org/software/make/). The
following command-line will install GitLab-Elasticsearch-Indexer in `/home/git/gitlab-elasticsearch-indexer` following command-line will install GitLab-Elasticsearch-Indexer in `/home/git/gitlab-elasticsearch-indexer`
......
...@@ -123,7 +123,7 @@ For more details on creating groups, watch the video [GitLab Namespaces (users, ...@@ -123,7 +123,7 @@ For more details on creating groups, watch the video [GitLab Namespaces (users,
## Add users to a group ## Add users to a group
A benefit of putting multiple projects in one group is that you can A benefit of putting multiple projects in one group is that you can
give a user to access to all projects in the group with one action. give a user access to all projects in the group with one action.
Add members to a group by navigating to the group's dashboard and clicking **Members**. Add members to a group by navigating to the group's dashboard and clicking **Members**.
...@@ -135,14 +135,14 @@ Consider a group with two projects: ...@@ -135,14 +135,14 @@ Consider a group with two projects:
- On the **Group Members** page, you can now add a new user to the group. - On the **Group Members** page, you can now add a new user to the group.
- Now, because this user is a **Developer** member of the group, they automatically - Now, because this user is a **Developer** member of the group, they automatically
gets **Developer** access to **all projects** within that group. get **Developer** access to **all projects** within that group.
To increase the access level of an existing user for a specific project, To increase the access level of an existing user for a specific project,
add them again as a new member to the project with the desired permission level. add them again as a new member to the project with the desired permission level.
## Request access to a group ## Request access to a group
As a group owner, you can enable or disable the ability for non members to request access to As a group owner, you can enable or disable the ability for non-members to request access to
your group. Go to the group settings, and click **Allow users to request access**. your group. Go to the group settings, and click **Allow users to request access**.
As a user, you can request to be a member of a group, if that setting is enabled. Go to the group for which you'd like to be a member, and click the **Request Access** button on the right As a user, you can request to be a member of a group, if that setting is enabled. Go to the group for which you'd like to be a member, and click the **Request Access** button on the right
...@@ -356,7 +356,7 @@ Restriction currently applies to: ...@@ -356,7 +356,7 @@ Restriction currently applies to:
- [From GitLab 12.3](https://gitlab.com/gitlab-org/gitlab/issues/12874), API access. - [From GitLab 12.3](https://gitlab.com/gitlab-org/gitlab/issues/12874), API access.
- [From GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/issues/32113), Git actions via SSH. - [From GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/issues/32113), Git actions via SSH.
To avoid accidental lock-out, admins and group owners are are able to access To avoid accidental lock-out, admins and group owners are able to access
the group regardless of the IP restriction. the group regardless of the IP restriction.
#### Allowed domain restriction **(PREMIUM)** #### Allowed domain restriction **(PREMIUM)**
...@@ -385,7 +385,7 @@ Some domains cannot be restricted. These are the most popular public email domai ...@@ -385,7 +385,7 @@ Some domains cannot be restricted. These are the most popular public email domai
To enable this feature: To enable this feature:
1. Navigate to the group's **Settings > General** page. 1. Navigate to the group's **Settings > General** page.
1. Expand the **Permissions, LFS, 2FA** section, and enter domain name into **Restrict membership by email** field. 1. Expand the **Permissions, LFS, 2FA** section, and enter the domain name into **Restrict membership by email** field.
1. Click **Save changes**. 1. Click **Save changes**.
This will enable the domain-checking for all new users added to the group from this moment on. This will enable the domain-checking for all new users added to the group from this moment on.
...@@ -445,7 +445,7 @@ To enable this feature: ...@@ -445,7 +445,7 @@ To enable this feature:
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/13294) in [GitLab Starter](https://about.gitlab.com/pricing/) 12.0. > [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/13294) in [GitLab Starter](https://about.gitlab.com/pricing/) 12.0.
A group owner can check the aggregated storage usage for all the project in a group, sub-groups included, in the **Storage** tab of the **Usage Quotas** page available to the group page settings list. A group owner can check the aggregated storage usage for all the projects in a group, sub-groups included, in the **Storage** tab of the **Usage Quotas** page available to the group page settings list.
![Group storage usage quota](img/group_storage_usage_quota.png) ![Group storage usage quota](img/group_storage_usage_quota.png)
......
...@@ -405,6 +405,7 @@ GFM will recognize the following: ...@@ -405,6 +405,7 @@ GFM will recognize the following:
| label by ID | `~123` | `namespace/project~123` | `project~123` | | label by ID | `~123` | `namespace/project~123` | `project~123` |
| one-word label by name | `~bug` | `namespace/project~bug` | `project~bug` | | one-word label by name | `~bug` | `namespace/project~bug` | `project~bug` |
| multi-word label by name | `~"feature request"` | `namespace/project~"feature request"` | `project~"feature request"` | | multi-word label by name | `~"feature request"` | `namespace/project~"feature request"` | `project~"feature request"` |
| scoped label by name | `~"priority::high"` | `namespace/project~"priority::high"` | `project~"priority::high"` |
| project milestone by ID | `%123` | `namespace/project%123` | `project%123` | | project milestone by ID | `%123` | `namespace/project%123` | `project%123` |
| one-word milestone by name | `%v1.23` | `namespace/project%v1.23` | `project%v1.23` | | one-word milestone by name | `%v1.23` | `namespace/project%v1.23` | `project%v1.23` |
| multi-word milestone by name | `%"release candidate"` | `namespace/project%"release candidate"` | `project%"release candidate"` | | multi-word milestone by name | `%"release candidate"` | `namespace/project%"release candidate"` | `project%"release candidate"` |
......
...@@ -32,13 +32,14 @@ on the search field on the top-right of your screen: ...@@ -32,13 +32,14 @@ on the search field on the top-right of your screen:
If you want to search for issues present in a specific project, navigate to If you want to search for issues present in a specific project, navigate to
a project's **Issues** tab, and click on the field **Search or filter results...**. It will a project's **Issues** tab, and click on the field **Search or filter results...**. It will
display a dropdown menu, from which you can add filters per author, assignee, milestone, display a dropdown menu, from which you can add filters per author, assignee, milestone,
label, weight, and 'my-reaction' (based on your emoji votes). When done, press **Enter** on your keyboard to filter the issues. release, label, weight, confidentiality, and "my-reaction" (based on your emoji votes).
When done, press **Enter** on your keyboard to filter the issues.
![filter issues in a project](img/issue_search_filter.png) ![filter issues in a project](img/issue_search_filter_v12_5.png)
The same process is valid for merge requests. Navigate to your project's **Merge Requests** tab, The same process is valid for merge requests. Navigate to your project's **Merge Requests** tab,
and click **Search or filter results...**. Merge requests can be filtered by author, assignee, and click **Search or filter results...**. Merge requests can be filtered by author, assignee,
milestone, and label. approver, milestone, release, label, "my-reaction", "work in progess" status, and target branch.
### Filtering by **None** / **Any** ### Filtering by **None** / **Any**
......
.auto-deploy: .dast-auto-deploy:
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.4.0" image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.4.0"
dast_environment_deploy: dast_environment_deploy:
extends: .auto-deploy extends: .dast-auto-deploy
stage: review stage: review
script: script:
- auto-deploy check_kube_domain - auto-deploy check_kube_domain
...@@ -31,7 +31,7 @@ dast_environment_deploy: ...@@ -31,7 +31,7 @@ dast_environment_deploy:
- $DAST_WEBSITE # we don't need to create a review app if a URL is already given - $DAST_WEBSITE # we don't need to create a review app if a URL is already given
stop_dast_environment: stop_dast_environment:
extends: .auto-deploy extends: .dast-auto-deploy
stage: cleanup stage: cleanup
variables: variables:
GIT_STRATEGY: none GIT_STRATEGY: none
......
...@@ -78,6 +78,7 @@ module Gitlab ...@@ -78,6 +78,7 @@ module Gitlab
clusters_applications_knative: count(::Clusters::Applications::Knative.available), clusters_applications_knative: count(::Clusters::Applications::Knative.available),
clusters_applications_elastic_stack: count(::Clusters::Applications::ElasticStack.available), clusters_applications_elastic_stack: count(::Clusters::Applications::ElasticStack.available),
in_review_folder: count(::Environment.in_review_folder), in_review_folder: count(::Environment.in_review_folder),
grafana_integrated_projects: count(GrafanaIntegration.enabled),
groups: count(Group), groups: count(Group),
issues: count(Issue), issues: count(Issue),
issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue), issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue),
......
...@@ -10810,9 +10810,6 @@ msgstr "" ...@@ -10810,9 +10810,6 @@ msgstr ""
msgid "Metrics|Unexpected deployment data response from prometheus endpoint" msgid "Metrics|Unexpected deployment data response from prometheus endpoint"
msgstr "" msgstr ""
msgid "Metrics|Unexpected metrics data response from prometheus endpoint"
msgstr ""
msgid "Metrics|Unit label" msgid "Metrics|Unit label"
msgstr "" msgstr ""
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { setTestTimeout } from 'helpers/timeout';
import { createStore } from '~/monitoring/stores'; import { createStore } from '~/monitoring/stores';
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import { shallowWrapperContainsSlotText } from 'helpers/vue_test_utils_helper'; import { shallowWrapperContainsSlotText } from 'helpers/vue_test_utils_helper';
import TimeSeries from '~/monitoring/components/charts/time_series.vue'; import TimeSeries from '~/monitoring/components/charts/time_series.vue';
import * as types from '~/monitoring/stores/mutation_types'; import * as types from '~/monitoring/stores/mutation_types';
import { TEST_HOST } from 'spec/test_constants'; import {
import MonitoringMock, {
deploymentData, deploymentData,
mockProjectPath, metricsGroupsAPIResponse,
} from '../../../javascripts/monitoring/mock_data'; mockedQueryResultPayload,
mockProjectDir,
mockHost,
} from '../mock_data';
import * as iconUtils from '~/lib/utils/icon_utils'; import * as iconUtils from '~/lib/utils/icon_utils';
const mockSvgPathContent = 'mockSvgPathContent'; const mockSvgPathContent = 'mockSvgPathContent';
const mockSha = 'mockSha';
const mockWidgets = 'mockWidgets'; const mockWidgets = 'mockWidgets';
const projectPath = `${TEST_HOST}${mockProjectPath}`;
const commitUrl = `${projectPath}/commit/${mockSha}`;
jest.mock('~/lib/utils/icon_utils', () => ({ jest.mock('~/lib/utils/icon_utils', () => ({
getSvgIconPathContent: jest.fn().mockImplementation( getSvgIconPathContent: jest.fn().mockImplementation(
...@@ -33,32 +34,44 @@ describe('Time series component', () => { ...@@ -33,32 +34,44 @@ describe('Time series component', () => {
let store; let store;
beforeEach(() => { beforeEach(() => {
setTestTimeout(1000);
store = createStore(); store = createStore();
store.commit(`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`, MonitoringMock.data);
store.commit(
`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`,
metricsGroupsAPIResponse,
);
store.commit(`monitoringDashboard/${types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS}`, deploymentData); store.commit(`monitoringDashboard/${types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS}`, deploymentData);
[, mockGraphData] = store.state.monitoringDashboard.dashboard.panel_groups[0].metrics;
// Mock data contains 2 panels, pick the first one
store.commit(`monitoringDashboard/${types.SET_QUERY_RESULT}`, mockedQueryResultPayload);
[mockGraphData] = store.state.monitoringDashboard.dashboard.panel_groups[0].metrics;
makeTimeSeriesChart = (graphData, type) => makeTimeSeriesChart = (graphData, type) =>
shallowMount(TimeSeries, { shallowMount(TimeSeries, {
attachToDocument: true,
propsData: { propsData: {
graphData: { ...graphData, type }, graphData: { ...graphData, type },
deploymentData: store.state.monitoringDashboard.deploymentData, deploymentData: store.state.monitoringDashboard.deploymentData,
projectPath, projectPath: `${mockHost}${mockProjectDir}`,
}, },
slots: { slots: {
default: mockWidgets, default: mockWidgets,
}, },
sync: false, sync: false,
store, store,
attachToDocument: true,
}); });
}); });
describe('general functions', () => { describe('general functions', () => {
let timeSeriesChart; let timeSeriesChart;
beforeEach(() => { beforeEach(done => {
timeSeriesChart = makeTimeSeriesChart(mockGraphData, 'area-chart'); timeSeriesChart = makeTimeSeriesChart(mockGraphData, 'area-chart');
timeSeriesChart.vm.$nextTick(done);
}); });
it('renders chart title', () => { it('renders chart title', () => {
...@@ -83,18 +96,24 @@ describe('Time series component', () => { ...@@ -83,18 +96,24 @@ describe('Time series component', () => {
describe('methods', () => { describe('methods', () => {
describe('formatTooltipText', () => { describe('formatTooltipText', () => {
const mockDate = deploymentData[0].created_at; let mockDate;
const mockCommitUrl = deploymentData[0].commitUrl; let mockCommitUrl;
const generateSeriesData = type => ({ let generateSeriesData;
seriesData: [
{ beforeEach(() => {
seriesName: timeSeriesChart.vm.chartData[0].name, mockDate = deploymentData[0].created_at;
componentSubType: type, mockCommitUrl = deploymentData[0].commitUrl;
value: [mockDate, 5.55555], generateSeriesData = type => ({
dataIndex: 0, seriesData: [
}, {
], seriesName: timeSeriesChart.vm.chartData[0].name,
value: mockDate, componentSubType: type,
value: [mockDate, 5.55555],
dataIndex: 0,
},
],
value: mockDate,
});
}); });
describe('when series is of line type', () => { describe('when series is of line type', () => {
...@@ -104,11 +123,11 @@ describe('Time series component', () => { ...@@ -104,11 +123,11 @@ describe('Time series component', () => {
}); });
it('formats tooltip title', () => { it('formats tooltip title', () => {
expect(timeSeriesChart.vm.tooltip.title).toBe('31 May 2017, 9:23PM'); expect(timeSeriesChart.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM');
}); });
it('formats tooltip content', () => { it('formats tooltip content', () => {
const name = 'Core Usage'; const name = 'Pod average';
const value = '5.556'; const value = '5.556';
const dataIndex = 0; const dataIndex = 0;
const seriesLabel = timeSeriesChart.find(GlChartSeriesLabel); const seriesLabel = timeSeriesChart.find(GlChartSeriesLabel);
...@@ -129,13 +148,13 @@ describe('Time series component', () => { ...@@ -129,13 +148,13 @@ describe('Time series component', () => {
}); });
}); });
describe('when series is of scatter type', () => { describe('when series is of scatter type, for deployments', () => {
beforeEach(() => { beforeEach(() => {
timeSeriesChart.vm.formatTooltipText(generateSeriesData('scatter')); timeSeriesChart.vm.formatTooltipText(generateSeriesData('scatter'));
}); });
it('formats tooltip title', () => { it('formats tooltip title', () => {
expect(timeSeriesChart.vm.tooltip.title).toBe('31 May 2017, 9:23PM'); expect(timeSeriesChart.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM');
}); });
it('formats tooltip sha', () => { it('formats tooltip sha', () => {
...@@ -274,9 +293,9 @@ describe('Time series component', () => { ...@@ -274,9 +293,9 @@ describe('Time series component', () => {
describe('scatterSeries', () => { describe('scatterSeries', () => {
it('utilizes deployment data', () => { it('utilizes deployment data', () => {
expect(timeSeriesChart.vm.scatterSeries.data).toEqual([ expect(timeSeriesChart.vm.scatterSeries.data).toEqual([
['2017-05-31T21:23:37.881Z', 0], ['2019-07-16T10:14:25.589Z', 0],
['2017-05-30T20:08:04.629Z', 0], ['2019-07-16T11:14:25.589Z', 0],
['2017-05-30T17:42:38.409Z', 0], ['2019-07-16T12:14:25.589Z', 0],
]); ]);
expect(timeSeriesChart.vm.scatterSeries.symbolSize).toBe(14); expect(timeSeriesChart.vm.scatterSeries.symbolSize).toBe(14);
...@@ -285,7 +304,7 @@ describe('Time series component', () => { ...@@ -285,7 +304,7 @@ describe('Time series component', () => {
describe('yAxisLabel', () => { describe('yAxisLabel', () => {
it('constructs a label for the chart y-axis', () => { it('constructs a label for the chart y-axis', () => {
expect(timeSeriesChart.vm.yAxisLabel).toBe('CPU'); expect(timeSeriesChart.vm.yAxisLabel).toBe('Memory Used per Pod');
}); });
}); });
}); });
...@@ -318,6 +337,10 @@ describe('Time series component', () => { ...@@ -318,6 +337,10 @@ describe('Time series component', () => {
timeSeriesAreaChart.vm.$nextTick(done); timeSeriesAreaChart.vm.$nextTick(done);
}); });
afterEach(() => {
timeSeriesAreaChart.destroy();
});
it('is a Vue instance', () => { it('is a Vue instance', () => {
expect(glChart.exists()).toBe(true); expect(glChart.exists()).toBe(true);
expect(glChart.isVueInstance()).toBe(true); expect(glChart.isVueInstance()).toBe(true);
...@@ -343,6 +366,9 @@ describe('Time series component', () => { ...@@ -343,6 +366,9 @@ describe('Time series component', () => {
}); });
describe('when tooltip is showing deployment data', () => { describe('when tooltip is showing deployment data', () => {
const mockSha = 'mockSha';
const commitUrl = `${mockProjectDir}/commit/${mockSha}`;
beforeEach(done => { beforeEach(done => {
timeSeriesAreaChart.vm.tooltip.isDeployment = true; timeSeriesAreaChart.vm.tooltip.isDeployment = true;
timeSeriesAreaChart.vm.$nextTick(done); timeSeriesAreaChart.vm.$nextTick(done);
......
export const mockHost = 'http://test.host';
export const mockProjectDir = '/frontend-fixtures/environments-project'; export const mockProjectDir = '/frontend-fixtures/environments-project';
export const anomalyDeploymentData = [ export const anomalyDeploymentData = [
...@@ -159,3 +160,171 @@ export const anomalyMockGraphData = { ...@@ -159,3 +160,171 @@ export const anomalyMockGraphData = {
}, },
], ],
}; };
export const deploymentData = [
{
id: 111,
iid: 3,
sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187',
commitUrl:
'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187',
ref: {
name: 'master',
},
created_at: '2019-07-16T10:14:25.589Z',
tag: false,
tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false',
'last?': true,
},
{
id: 110,
iid: 2,
sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187',
commitUrl:
'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187',
ref: {
name: 'master',
},
created_at: '2019-07-16T11:14:25.589Z',
tag: false,
tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false',
'last?': false,
},
{
id: 109,
iid: 1,
sha: '6511e58faafaa7ad2228990ec57f19d66f7db7c2',
commitUrl:
'http://test.host/frontend-fixtures/environments-project/commit/6511e58faafaa7ad2228990ec57f19d66f7db7c2',
ref: {
name: 'update2-readme',
},
created_at: '2019-07-16T12:14:25.589Z',
tag: false,
tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false',
'last?': false,
},
];
export const metricsNewGroupsAPIResponse = [
{
group: 'System metrics (Kubernetes)',
priority: 5,
panels: [
{
title: 'Memory Usage (Pod average)',
type: 'area-chart',
y_label: 'Memory Used per Pod',
weight: 2,
metrics: [
{
id: 'system_metrics_kubernetes_container_memory_average',
query_range:
'avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^%{ci_environment_slug}-([^c].*|c([^a]|a([^n]|n([^a]|a([^r]|r[^y])))).*|)-(.*)",namespace="%{kube_namespace}"}) by (job)) without (job) / count(avg(container_memory_usage_bytes{container_name!="POD",pod_name=~"^%{ci_environment_slug}-([^c].*|c([^a]|a([^n]|n([^a]|a([^r]|r[^y])))).*|)-(.*)",namespace="%{kube_namespace}"}) without (job)) /1024/1024',
label: 'Pod average',
unit: 'MB',
metric_id: 17,
prometheus_endpoint_path:
'/root/autodevops-deploy/environments/32/prometheus/api/v1/query_range?query=avg%28sum%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+by+%28job%29%29+without+%28job%29+%2F+count%28avg%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+without+%28job%29%29+%2F1024%2F1024',
appearance: {
line: {
width: 2,
},
},
},
],
},
],
},
];
export const mockedQueryResultPayload = {
metricId: '17_system_metrics_kubernetes_container_memory_average',
result: [
{
metric: {},
values: [
[1563272065.589, '10.396484375'],
[1563272125.589, '10.333984375'],
[1563272185.589, '10.333984375'],
[1563272245.589, '10.333984375'],
[1563272305.589, '10.333984375'],
[1563272365.589, '10.333984375'],
[1563272425.589, '10.38671875'],
[1563272485.589, '10.333984375'],
[1563272545.589, '10.333984375'],
[1563272605.589, '10.333984375'],
[1563272665.589, '10.333984375'],
[1563272725.589, '10.333984375'],
[1563272785.589, '10.396484375'],
[1563272845.589, '10.333984375'],
[1563272905.589, '10.333984375'],
[1563272965.589, '10.3984375'],
[1563273025.589, '10.337890625'],
[1563273085.589, '10.34765625'],
[1563273145.589, '10.337890625'],
[1563273205.589, '10.337890625'],
[1563273265.589, '10.337890625'],
[1563273325.589, '10.337890625'],
[1563273385.589, '10.337890625'],
[1563273445.589, '10.337890625'],
[1563273505.589, '10.337890625'],
[1563273565.589, '10.337890625'],
[1563273625.589, '10.337890625'],
[1563273685.589, '10.337890625'],
[1563273745.589, '10.337890625'],
[1563273805.589, '10.337890625'],
[1563273865.589, '10.390625'],
[1563273925.589, '10.390625'],
],
},
],
};
export const metricsGroupsAPIResponse = [
{
group: 'System metrics (Kubernetes)',
priority: 5,
panels: [
{
title: 'Memory Usage (Pod average)',
type: 'area-chart',
y_label: 'Memory Used per Pod',
weight: 2,
metrics: [
{
id: 'system_metrics_kubernetes_container_memory_average',
query_range:
'avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^%{ci_environment_slug}-([^c].*|c([^a]|a([^n]|n([^a]|a([^r]|r[^y])))).*|)-(.*)",namespace="%{kube_namespace}"}) by (job)) without (job) / count(avg(container_memory_usage_bytes{container_name!="POD",pod_name=~"^%{ci_environment_slug}-([^c].*|c([^a]|a([^n]|n([^a]|a([^r]|r[^y])))).*|)-(.*)",namespace="%{kube_namespace}"}) without (job)) /1024/1024',
label: 'Pod average',
unit: 'MB',
metric_id: 17,
prometheus_endpoint_path:
'/root/autodevops-deploy/environments/32/prometheus/api/v1/query_range?query=avg%28sum%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+by+%28job%29%29+without+%28job%29+%2F+count%28avg%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+without+%28job%29%29+%2F1024%2F1024',
appearance: {
line: {
width: 2,
},
},
},
],
},
{
title: 'Core Usage (Total)',
type: 'area-chart',
y_label: 'Total Cores',
weight: 3,
metrics: [
{
id: 'system_metrics_kubernetes_container_cores_total',
query_range:
'avg(sum(rate(container_cpu_usage_seconds_total{container_name!="POD",pod_name=~"^%{ci_environment_slug}-(.*)",namespace="%{kube_namespace}"}[15m])) by (job)) without (job)',
label: 'Total',
unit: 'cores',
metric_id: 13,
},
],
},
],
},
];
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import { setTestTimeout } from 'helpers/timeout';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import PanelType from '~/monitoring/components/panel_type.vue'; import PanelType from '~/monitoring/components/panel_type.vue';
import EmptyChart from '~/monitoring/components/charts/empty_chart.vue'; import EmptyChart from '~/monitoring/components/charts/empty_chart.vue';
...@@ -10,15 +11,17 @@ import { anomalyMockGraphData } from '../../frontend/monitoring/mock_data'; ...@@ -10,15 +11,17 @@ import { anomalyMockGraphData } from '../../frontend/monitoring/mock_data';
import { createStore } from '~/monitoring/stores'; import { createStore } from '~/monitoring/stores';
global.IS_EE = true; global.IS_EE = true;
global.URL.createObjectURL = jest.fn(() => {}); global.URL.createObjectURL = jest.fn();
describe('Panel Type component', () => { describe('Panel Type component', () => {
let axiosMock; let axiosMock;
let store; let store;
let panelType; let panelType;
const dashboardWidth = 100; const dashboardWidth = 100;
const exampleText = 'example_text';
beforeEach(() => { beforeEach(() => {
setTestTimeout(1000);
axiosMock = new AxiosMockAdapter(axios); axiosMock = new AxiosMockAdapter(axios);
}); });
...@@ -40,6 +43,7 @@ describe('Panel Type component', () => { ...@@ -40,6 +43,7 @@ describe('Panel Type component', () => {
graphData: graphDataNoResult, graphData: graphDataNoResult,
}, },
sync: false, sync: false,
attachToDocument: true,
}); });
}); });
...@@ -65,14 +69,13 @@ describe('Panel Type component', () => { ...@@ -65,14 +69,13 @@ describe('Panel Type component', () => {
}); });
describe('when Graph data is available', () => { describe('when Graph data is available', () => {
const exampleText = 'example_text';
const propsData = { const propsData = {
clipboardText: exampleText, clipboardText: exampleText,
dashboardWidth, dashboardWidth,
graphData: graphDataPrometheusQueryRange, graphData: graphDataPrometheusQueryRange,
}; };
beforeEach(() => { beforeEach(done => {
store = createStore(); store = createStore();
panelType = shallowMount(PanelType, { panelType = shallowMount(PanelType, {
propsData, propsData,
...@@ -80,6 +83,11 @@ describe('Panel Type component', () => { ...@@ -80,6 +83,11 @@ describe('Panel Type component', () => {
sync: false, sync: false,
attachToDocument: true, attachToDocument: true,
}); });
panelType.vm.$nextTick(done);
});
afterEach(() => {
panelType.destroy();
}); });
describe('Time Series Chart panel type', () => { describe('Time Series Chart panel type', () => {
...@@ -110,4 +118,49 @@ describe('Panel Type component', () => { ...@@ -110,4 +118,49 @@ describe('Panel Type component', () => {
}); });
}); });
}); });
describe('when downloading metrics data as CSV', () => {
beforeEach(done => {
graphDataPrometheusQueryRange.y_label = 'metric';
store = createStore();
panelType = shallowMount(PanelType, {
propsData: {
clipboardText: exampleText,
dashboardWidth,
graphData: graphDataPrometheusQueryRange,
},
store,
sync: false,
attachToDocument: true,
});
panelType.vm.$nextTick(done);
});
afterEach(() => {
panelType.destroy();
});
describe('csvText', () => {
it('converts metrics data from json to csv', () => {
const header = `timestamp,${graphDataPrometheusQueryRange.y_label}`;
const data = graphDataPrometheusQueryRange.queries[0].result[0].values;
const firstRow = `${data[0][0]},${data[0][1]}`;
const secondRow = `${data[1][0]},${data[1][1]}`;
expect(panelType.vm.csvText).toBe(`${header}\r\n${firstRow}\r\n${secondRow}\r\n`);
});
});
describe('downloadCsv', () => {
it('produces a link with a Blob', () => {
expect(global.URL.createObjectURL).toHaveBeenLastCalledWith(expect.any(Blob));
expect(global.URL.createObjectURL).toHaveBeenLastCalledWith(
expect.objectContaining({
size: panelType.vm.csvText.length,
type: 'text/plain',
}),
);
});
});
});
}); });
This diff is collapsed.
...@@ -317,7 +317,7 @@ describe('Monitoring store actions', () => { ...@@ -317,7 +317,7 @@ describe('Monitoring store actions', () => {
const metric = metricsDashboardResponse.dashboard.panel_groups[0].panels[0].metrics[0]; const metric = metricsDashboardResponse.dashboard.panel_groups[0].panels[0].metrics[0];
const state = storeState(); const state = storeState();
const data = metricsGroupsAPIResponse.data[0].metrics[0].queries[0]; const data = metricsGroupsAPIResponse[0].panels[0].metrics[0];
const response = { data }; const response = { data };
mock.onGet('http://test').reply(200, response); mock.onGet('http://test').reply(200, response);
......
...@@ -21,79 +21,46 @@ describe('Monitoring mutations', () => { ...@@ -21,79 +21,46 @@ describe('Monitoring mutations', () => {
beforeEach(() => { beforeEach(() => {
stateCopy.dashboard.panel_groups = []; stateCopy.dashboard.panel_groups = [];
groups = metricsGroupsAPIResponse.data; groups = metricsGroupsAPIResponse;
}); });
it('adds a key to the group', () => { it('adds a key to the group', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups); mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
expect(stateCopy.dashboard.panel_groups[0].key).toBe('kubernetes-0'); expect(stateCopy.dashboard.panel_groups[0].key).toBe('system-metrics-kubernetes--0');
expect(stateCopy.dashboard.panel_groups[1].key).toBe('nginx-1');
}); });
it('normalizes values', () => { it('normalizes values', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups); mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
const expectedTimestamp = '2017-05-25T08:22:34.925Z'; const expectedLabel = 'Pod average';
const expectedValue = 8.0390625; const { label, query_range } = stateCopy.dashboard.panel_groups[0].metrics[0].metrics[0];
const [
timestamp,
value,
] = stateCopy.dashboard.panel_groups[0].metrics[0].queries[0].result[0].values[0];
expect(timestamp).toEqual(expectedTimestamp); expect(label).toEqual(expectedLabel);
expect(value).toEqual(expectedValue); expect(query_range.length).toBeGreaterThan(0);
}); });
it('contains two groups that contains, one of which has two queries sorted by priority', () => { it('contains one group, which it has two panels and one metrics property', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups); mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
expect(stateCopy.dashboard.panel_groups).toBeDefined(); expect(stateCopy.dashboard.panel_groups).toBeDefined();
expect(stateCopy.dashboard.panel_groups.length).toEqual(2); expect(stateCopy.dashboard.panel_groups.length).toEqual(1);
expect(stateCopy.dashboard.panel_groups[0].metrics.length).toEqual(2); expect(stateCopy.dashboard.panel_groups[0].panels.length).toEqual(2);
expect(stateCopy.dashboard.panel_groups[0].panels[0].metrics.length).toEqual(1);
expect(stateCopy.dashboard.panel_groups[0].panels[1].metrics.length).toEqual(1);
}); });
it('assigns queries a metric id', () => { it('assigns queries a metric id', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups); mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
expect(stateCopy.dashboard.panel_groups[1].metrics[0].queries[0].metricId).toEqual('100'); expect(stateCopy.dashboard.panel_groups[0].metrics[0].queries[0].metricId).toEqual(
'17_system_metrics_kubernetes_container_memory_average',
);
}); });
it('removes the data if all the values from a query are not defined', () => { describe('dashboard endpoint', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
expect(stateCopy.dashboard.panel_groups[1].metrics[0].queries[0].result.length).toEqual(0);
});
it('assigns metric id of null if metric has no id', () => {
stateCopy.dashboard.panel_groups = [];
const noId = groups.map(group => ({
...group,
...{
metrics: group.metrics.map(metric => {
const { id, ...metricWithoutId } = metric;
return metricWithoutId;
}),
},
}));
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, noId);
stateCopy.dashboard.panel_groups.forEach(group => {
group.metrics.forEach(metric => {
expect(metric.queries.every(query => query.metricId === null)).toBe(true);
});
});
});
describe('dashboard endpoint enabled', () => {
const dashboardGroups = metricsDashboardResponse.dashboard.panel_groups; const dashboardGroups = metricsDashboardResponse.dashboard.panel_groups;
beforeEach(() => {
stateCopy.useDashboardEndpoint = true;
});
it('aliases group panels to metrics for backwards compatibility', () => { it('aliases group panels to metrics for backwards compatibility', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, dashboardGroups); mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, dashboardGroups);
...@@ -143,7 +110,6 @@ describe('Monitoring mutations', () => { ...@@ -143,7 +110,6 @@ describe('Monitoring mutations', () => {
const result = [{ values: [[0, 1], [1, 1], [1, 3]] }]; const result = [{ values: [[0, 1], [1, 1], [1, 3]] }];
beforeEach(() => { beforeEach(() => {
stateCopy.useDashboardEndpoint = true;
const dashboardGroups = metricsDashboardResponse.dashboard.panel_groups; const dashboardGroups = metricsDashboardResponse.dashboard.panel_groups;
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, dashboardGroups); mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, dashboardGroups);
}); });
......
...@@ -48,6 +48,10 @@ describe Gitlab::UsageData do ...@@ -48,6 +48,10 @@ describe Gitlab::UsageData do
create(:clusters_applications_knative, :installed, cluster: gcp_cluster) create(:clusters_applications_knative, :installed, cluster: gcp_cluster)
create(:clusters_applications_elastic_stack, :installed, cluster: gcp_cluster) create(:clusters_applications_elastic_stack, :installed, cluster: gcp_cluster)
create(:grafana_integration, project: projects[0], enabled: true)
create(:grafana_integration, project: projects[1], enabled: true)
create(:grafana_integration, project: projects[2], enabled: false)
ProjectFeature.first.update_attribute('repository_access_level', 0) ProjectFeature.first.update_attribute('repository_access_level', 0)
end end
...@@ -140,6 +144,7 @@ describe Gitlab::UsageData do ...@@ -140,6 +144,7 @@ describe Gitlab::UsageData do
clusters_applications_knative clusters_applications_knative
clusters_applications_elastic_stack clusters_applications_elastic_stack
in_review_folder in_review_folder
grafana_integrated_projects
groups groups
issues issues
issues_with_associated_zoom_link issues_with_associated_zoom_link
...@@ -221,6 +226,7 @@ describe Gitlab::UsageData do ...@@ -221,6 +226,7 @@ describe Gitlab::UsageData do
expect(count_data[:clusters_applications_runner]).to eq(1) expect(count_data[:clusters_applications_runner]).to eq(1)
expect(count_data[:clusters_applications_knative]).to eq(1) expect(count_data[:clusters_applications_knative]).to eq(1)
expect(count_data[:clusters_applications_elastic_stack]).to eq(1) expect(count_data[:clusters_applications_elastic_stack]).to eq(1)
expect(count_data[:grafana_integrated_projects]).to eq(2)
end end
it 'works when queries time out' do it 'works when queries time out' do
......
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