Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-06-16 00:08:33 +00:00
parent ecfcccb684
commit 292d054661
43 changed files with 499 additions and 76 deletions

View File

@ -369,7 +369,7 @@ export const toggleStarredValue = ({ commit, state, getters }) => {
method,
})
.then(() => {
commit(types.RECEIVE_DASHBOARD_STARRING_SUCCESS, newStarredValue);
commit(types.RECEIVE_DASHBOARD_STARRING_SUCCESS, { selectedDashboard, newStarredValue });
})
.catch(() => {
commit(types.RECEIVE_DASHBOARD_STARRING_FAILURE);

View File

@ -1,7 +1,6 @@
import Vue from 'vue';
import { pick } from 'lodash';
import * as types from './mutation_types';
import { selectedDashboard } from './getters';
import { mapToDashboardViewModel, normalizeQueryResult } from './utils';
import { BACKOFF_TIMEOUT } from '../../lib/utils/common_utils';
import { endpointKeys, initialStateKeys, metricStates } from '../constants';
@ -82,15 +81,14 @@ export default {
[types.REQUEST_DASHBOARD_STARRING](state) {
state.isUpdatingStarredValue = true;
},
[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](state, newStarredValue) {
const dashboard = selectedDashboard(state);
const index = state.allDashboards.findIndex(d => d === dashboard);
[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](state, { selectedDashboard, newStarredValue }) {
const index = state.allDashboards.findIndex(d => d === selectedDashboard);
state.isUpdatingStarredValue = false;
// Trigger state updates in the reactivity system for this change
// https://vuejs.org/v2/guide/reactivity.html#For-Arrays
Vue.set(state.allDashboards, index, { ...dashboard, starred: newStarredValue });
Vue.set(state.allDashboards, index, { ...selectedDashboard, starred: newStarredValue });
},
[types.RECEIVE_DASHBOARD_STARRING_FAILURE](state) {
state.isUpdatingStarredValue = false;

View File

@ -1,10 +1,9 @@
<script>
import { mapState, mapActions } from 'vuex';
import { GlLink, GlFormGroup, GlFormInput } from '@gitlab/ui';
import { GlFormGroup, GlFormInput } from '@gitlab/ui';
export default {
components: {
GlLink,
GlFormGroup,
GlFormInput,
},
@ -36,7 +35,6 @@ export default {
'MetricsSettings|Add a button to the metrics dashboard linking directly to your existing external dashboard.',
)
}}
<gl-link :href="externalDashboard.helpPage">{{ __('Learn more') }}</gl-link>
</template>
<!-- placeholder with a url is a false positive -->
<!-- eslint-disable @gitlab/vue-require-i18n-attribute-strings -->

View File

@ -3,10 +3,8 @@ export default (initialState = {}) => ({
helpPage: initialState.helpPage,
externalDashboard: {
url: initialState.externalDashboardUrl,
helpPage: initialState.externalDashboardHelpPage,
},
dashboardTimezone: {
selected: initialState.dashboardTimezoneSetting,
helpPage: initialState.dashboardTimezoneHelpPage,
},
});

View File

@ -13,7 +13,8 @@ module Metrics
STAGES::EndpointInserter,
STAGES::PanelIdsInserter,
STAGES::Sorter,
STAGES::AlertsInserter
STAGES::AlertsInserter,
STAGES::UrlValidator
].freeze
def get_dashboard

View File

@ -1,5 +1,5 @@
.js-operation-settings{ data: { operations_settings_endpoint: project_settings_operations_path(@project),
help_page: help_page_path('user/project/integrations/prometheus'),
help_page: help_page_path('user/project/operations/dashboard_settings'),
external_dashboard: { url: metrics_external_dashboard_url,
help_page: help_page_path('user/project/operations/linking_to_an_external_dashboard') },
dashboard_timezone: { setting: metrics_dashboard_timezone.upcase } } }

View File

@ -0,0 +1,5 @@
---
title: Convert `:release` yaml to `release-cli` commands
merge_request: 34261
author:
type: added

View File

@ -0,0 +1,5 @@
---
title: Add validation step on backend for metrics dashboard links
merge_request: 34204
author:
type: added

View File

@ -0,0 +1,5 @@
---
title: Add API to schedule project repository storage moves
merge_request: 34119
author:
type: added

View File

@ -23,7 +23,7 @@ are [paginated](README.md#pagination).
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://primary.example.com/api/v4/project_repository_storage_moves'
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://gitlab.example.com/api/v4/project_repository_storage_moves'
```
Example response:
@ -61,12 +61,12 @@ Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `project_id` | integer | yes | The ID of the project |
| `project_id` | integer | yes | ID of the project |
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://primary.example.com/api/v4/project/1/repository_storage_moves'
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://gitlab.example.com/api/v4/projects/1/repository_storage_moves'
```
Example response:
@ -101,12 +101,12 @@ Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `repository_storage_id` | integer | yes | The ID of the project repository storage move |
| `repository_storage_id` | integer | yes | ID of the project repository storage move |
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://primary.example.com/api/v4/project_repository_storage_moves/1'
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://gitlab.example.com/api/v4/project_repository_storage_moves/1'
```
Example response:
@ -132,20 +132,60 @@ Example response:
## Get a single repository storage move for a project
```plaintext
GET /project/:project_id/repository_storage_moves/:repository_storage_id
GET /projects/:project_id/repository_storage_moves/:repository_storage_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `project_id` | integer | yes | The ID of the project |
| `repository_storage_id` | integer | yes | The ID of the project repository storage move |
| `project_id` | integer | yes | ID of the project |
| `repository_storage_id` | integer | yes | ID of the project repository storage move |
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://primary.example.com/api/v4/project/1/repository_storage_moves/1'
curl --header "PRIVATE-TOKEN: <your_access_token>" 'https://gitlab.example.com/api/v4/projects/1/repository_storage_moves/1'
```
Example response:
```json
{
"id": 1,
"created_at": "2020-05-07T04:27:17.234Z",
"state": "scheduled",
"source_storage_name": "default",
"destination_storage_name": "storage2",
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
```
## Schedule a repository storage move for a project
```plaintext
POST /projects/:project_id/repository_storage_moves
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `project_id` | integer | yes | ID of the project |
| `destination_storage_name` | string | yes | Name of the destination storage shard |
Example request:
```shell
curl --request POST --header "PRIVATE_TOKEN: <your_access_token>" --header "Content-Type: application/json" \
--data '{"destination_storage_name":"storage2"}' 'https://gitlab.example.com/api/v4/projects/1/repository_storage_moves'
```
Example response:

View File

@ -866,10 +866,6 @@ versions of the app, all without leaving GitLab.
![Monitoring dashboard](../img/environments_monitoring.png)
#### Linking to external dashboard
Add a [button to the Monitoring dashboard](../../user/project/operations/linking_to_an_external_dashboard.md) linking directly to your existing external dashboards.
#### Embedding metrics in GitLab Flavored Markdown
Metric charts can be embedded within GitLab Flavored Markdown. See [Embedding Metrics within GitLab Flavored Markdown](../../user/project/integrations/prometheus.md#embedding-metric-charts-within-gitlab-flavored-markdown) for more details.

View File

@ -28,7 +28,8 @@ More useful links:
## What is Usage Ping?
- GitLab sends a weekly payload containing usage data to GitLab Inc. Usage Ping provides high-level data to help our product, support, and sales teams. It does not send any project names, usernames, or any other specific data. The information from the usage ping is not anonymous, it is linked to the hostname of the instance. Sending usage ping is optional, and any instance can disable analytics.
- The usage data is primarily composed of row counts for different tables in the instances database. By comparing these counts month over month (or week over week), we can get a rough sense for how an instance is using the different features within the product.
- The usage data is primarily composed of row counts for different tables in the instances database. By comparing these counts month over month (or week over week), we can get a rough sense for how an instance is using the different features within the product. In addition to counts, other facts
that help us classify and understand GitLab installations are collected.
- Usage ping is important to GitLab as we use it to calculate our Stage Monthly Active Users (SMAU) which helps us measure the success of our stages and features.
- Once usage ping is enabled, GitLab will gather data from the other instances and will be able to show usage statistics of your instance to your users.
@ -120,7 +121,12 @@ sequenceDiagram
## Implementing Usage Ping
Usage Ping consists of four types of counters which are all found in `usage_data.rb`:
Usage Ping consists of two kinds of data, counters and observations. Counters track how often a certain event
happened over time, such as how many CI pipelines have run. They are monotonic and always trend up.
Observations are facts collected from one or more GitLab instances and can carry arbitrary data. There are no
general guidelines around how to collect those, due to the individual nature of that data.
There are four types of counters which are all found in `usage_data.rb`:
- **Ordinary Batch Counters:** Simple count of a given ActiveRecord_Relation
- **Distinct Batch Counters:** Distinct count of a given ActiveRecord_Relation on given column
@ -236,6 +242,29 @@ alt_usage_data { Gitlab::CurrentSettings.uuid }
alt_usage_data(999)
```
### Prometheus Queries
In those cases where operational metrics should be part of Usage Ping, a database or Redis query is unlikely
to provide useful data. Instead, Prometheus might be more appropriate, since most of GitLab's architectural
components publish metrics to it that can be queried back, aggregated, and included as usage data.
NOTE: **Note:**
Prometheus as a data source for Usage Ping is currently only available for single-node Omnibus installations
that are running the [bundled Prometheus](../../administration/monitoring/prometheus/index.md) instance.
In order to query Prometheus for metrics, a helper method is available that will `yield` a fully configured
`PrometheusClient`, given it is available as per the note above:
```ruby
with_prometheus_client do |client|
response = client.query('<your query>')
...
end
```
Please refer to [the `PrometheusClient` definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/prometheus_client.rb)
for how to use its API to query for data.
## Developing and testing Usage Ping
### 1. Use your Rails console to manually test counters
@ -297,6 +326,52 @@ When adding, changing, or updating metrics, please update the [Usage Statistics
On GitLab.com, we have DangerBot setup to monitor Telemetry related files and DangerBot will recommend a Telemetry review. Mention `@gitlab-org/growth/telemetry/engineers` in your MR for a review.
### Optional: Test Prometheus based Usage Ping
If the data submitted includes metrics [queried from Prometheus](#prometheus-queries) that you would like to inspect and verify,
then you need to ensure that a Prometheus server is running locally, and that furthermore the respective GitLab components
are exporting metrics to it. If you do not need to test data coming from Prometheus, no further action
is necessary, since Usage Ping should degrade gracefully in the absence of a running Prometheus server.
There are currently three kinds of components that may export data to Prometheus, and which are included in Usage Ping:
- [`node_exporter`](https://github.com/prometheus/node_exporter) - Exports node metrics from the host machine
- [`gitlab-exporter`](https://gitlab.com/gitlab-org/gitlab-exporter) - Exports process metrics from various GitLab components
- various GitLab services such as Sidekiq and the Rails server that export their own metrics
#### Test with an Omnibus container
This is the recommended approach to test Prometheus based Usage Ping.
The easiest way to verify your changes is to build a new Omnibus image from your code branch via CI, then download the image
and run a local container instance:
1. From your merge request, click on the `qa` stage, then trigger the `package-and-qa` job. This job will trigger an Omnibus
build in a [downstream pipeline of the `omnibus-gitlab-mirror` project](https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/-/pipelines).
1. In the downstream pipeline, wait for the `gitlab-docker` job to finish.
1. Open the job logs and locate the full container name including the version. It will take the following form: `registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:<VERSION>`.
1. On your local machine, make sure you are logged in to the GitLab Docker registry. You can find the instructions for this in
[Authenticating to the GitLab Container Registry](../../user/packages/container_registry/index.md#authenticating-to-the-gitlab-container-registry).
1. Once logged in, download the new image via `docker pull registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:<VERSION>`
1. For more information about working with and running Omnibus GitLab containers in Docker, please refer to [GitLab Docker images](https://docs.gitlab.com/omnibus/docker/README.html) in the Omnibus documentation.
#### Test with GitLab development toolkits
This is the less recommended approach, since it comes with a number of difficulties when emulating a real GitLab deployment.
The [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit) is not currently set up to run a Prometheus server or `node_exporter` alongside other GitLab components. If you would
like to do so, [Monitoring the GDK with Prometheus](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/master/doc/howto/prometheus/index.md#monitoring-the-gdk-with-prometheus) is a good start.
The [GCK](https://gitlab.com/gitlab-org/gitlab-compose-kit) has limited support for testing Prometheus based Usage Ping.
By default, it already comes with a fully configured Prometheus service that is set up to scrape a number of components,
but with the following limitations:
- It does not currently run a `gitlab-exporter` instance, so several `process_*` metrics from services such as Gitaly may be missing.
- While it runs a `node_exporter`, `docker-compose` services emulate hosts, meaning that it would normally report itself to not be associated
with any of the other services that are running. That is not how node metrics are reported in a production setup, where `node_exporter`
always runs as a process alongside other GitLab components on any given node. From Usage Ping's perspective none of the node data would therefore
appear to be associated to any of the services running, since they all appear to be running on different hosts. To alleviate this problem, the `node_exporter` in GCK was arbitrarily "assigned" to the `web` service, meaning only for this service `node_*` metrics will appear in Usage Ping.
## Usage Statistics definitions
| Statistic | Section | Stage | Tier | Description |
@ -555,6 +630,16 @@ On GitLab.com, we have DangerBot setup to monitor Telemetry related files and Da
| `ci_triggers` | `usage_activity_by_stage` | `verify` | | Triggers enabled |
| `clusters_applications_runner` | `usage_activity_by_stage` | `verify` | | Unique clusters with Runner enabled |
| `projects_reporting_ci_cd_back_to_github: 0` | `usage_activity_by_stage` | `verify` | | Unique projects with a GitHub pipeline enabled |
| `nodes` | `topology` | `enablement`| | The list of server nodes on which GitLab components are running |
| `duration_s` | `topology` | `enablement`| | Time it took to collect topology data |
| `node_memory_total_bytes` | `topology > nodes` | `enablement`| | The total available memory of this node |
| `node_cpus` | `topology > nodes` | `enablement`| | The number of CPU cores of this node |
| `node_services` | `topology > nodes` | `enablement`| | The list of GitLab services running on this node |
| `name` | `topology > nodes > node_services` | `enablement`| | The name of the GitLab service running on this node |
| `process_count` | `topology > nodes > node_services` | `enablement`| | The number of processes running for this service |
| `process_memory_rss` | `topology > nodes > node_services` | `enablement`| | The average Resident Set Size of a service process |
| `process_memory_uss` | `topology > nodes > node_services` | `enablement`| | The average Unique Set Size of a service process |
| `process_memory_pss` | `topology > nodes > node_services` | `enablement`| | The average Proportional Set Size of a service process |
## Example Usage Ping payload
@ -746,6 +831,34 @@ The following is example content of the Usage Ping payload.
"ci_builds": 999,
...
}
},
"topology": {
"nodes": [
{
"node_memory_total_bytes": 33269903360,
"node_cpus": 16,
"node_services": [
{
"name": "web",
"process_count": 16,
"process_memory_pss": 233349888,
"process_memory_rss": 788220927,
"process_memory_uss": 195295487
},
{
"name": "sidekiq",
"process_count": 1,
"process_memory_pss": 734080000,
"process_memory_rss": 750051328,
"process_memory_uss": 731533312
},
...
],
...
},
...
],
"duration_s": 0.013836685999194742
}
}
```

View File

@ -78,6 +78,7 @@ The following table shows which languages, package managers and frameworks are s
| Elixir (Phoenix) | [Sobelow](https://github.com/nccgroup/sobelow) | 11.10 |
| Go | [Gosec](https://github.com/securego/gosec) | 10.7 |
| Groovy ([Ant](https://ant.apache.org/), [Gradle](https://gradle.org/), [Maven](https://maven.apache.org/) and [SBT](https://www.scala-sbt.org/)) | [SpotBugs](https://spotbugs.github.io/) with the [find-sec-bugs](https://find-sec-bugs.github.io/) plugin | 11.3 (Gradle) & 11.9 (Ant, Maven, SBT) |
| Helm Charts | [Kubesec](https://github.com/controlplaneio/kubesec) | 13.1 |
| Java ([Ant](https://ant.apache.org/), [Gradle](https://gradle.org/), [Maven](https://maven.apache.org/) and [SBT](https://www.scala-sbt.org/)) | [SpotBugs](https://spotbugs.github.io/) with the [find-sec-bugs](https://find-sec-bugs.github.io/) plugin | 10.6 (Maven), 10.8 (Gradle) & 11.9 (Ant, SBT) |
| JavaScript | [ESLint security plugin](https://github.com/nodesecurity/eslint-plugin-security) | 11.8 |
| Kubernetes manifests | [Kubesec](https://github.com/controlplaneio/kubesec) | 12.6 |

View File

@ -129,6 +129,18 @@ GitLab currently only supports a single assignee per alert.
To remove an assignee, click **Edit** next to the **Assignee** dropdown menu and
deselect the user from the list of assignees, or click **Unassigned**.
### Alert system notes
> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3066) in GitLab 13.1.
NOTE: **Note:**
GitLab currently only supports creating system notes when assigning an Alert.
Assigning a user an Alert creates a system note, visible in the Alert Details view,
giving you a linear timeline of the alert's investigation and assignment history.
![Alert Management Details View System Notes](img/alert_detail_system_notes_v13_1.png)
## Use cases for assigning alerts
Consider a team formed by different sections of monitoring, collaborating on a
@ -136,7 +148,7 @@ single application. After an alert surfaces, it's extremely important to
route the alert to the team members who can address and resolve the alert.
Assigning Alerts to multiple assignees eases collaboration and delegation. All
assignees are shown in your team's workflows, and all assignees receive
assignees are shown in your team's work-flows, and all assignees receive
notifications, simplifying communication and ownership of the alert.
After completing their portion of investigating or fixing the alert, users can

View File

@ -0,0 +1,47 @@
---
stage: Monitor
group: APM
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
# Metrics dashboard settings
You can configure your [Monitoring dashboard](../integrations/prometheus.md) to
display the time zone of your choice, and the links of your choice.
## Change the dashboard time zone
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/214370) in GitLab 13.1.
By default, your monitoring dashboard displays dates and times in your local
time zone, but you can display dates and times in UTC format. To change the
time zone:
1. Navigate to **{settings}** **Settings > Operations**, and scroll to
**Metrics Dashboard**.
1. In the **Dashboard timezone** select box, select *User's local timezone*
or *UTC*:
![Dashboard timezone setting](img/dashboard_local_timezone_v13_1.png)
1. Click **Save changes**.
## Link to an external dashboard
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/57171) in GitLab 12.0.
You can add a button on your monitoring dashboard that links directly to your
existing external dashboards:
1. Navigate to **{settings}** **Settings > Operations**, and scroll to
**Metrics Dashboard**.
1. In **External dashboard URL**, provide the URL to your external dashboard:
![External Dashboard Setting](img/dashboard_external_link_v13_1.png)
1. Click **Save changes**.
GitLab displays a **View full dashboard** button in the top right corner of your
[monitoring dashboard](../../../ci/environments/index.md#monitoring-environments)
which opens the URL you provided:
![External Dashboard Link](img/external_dashboard_link.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

View File

@ -10,4 +10,4 @@ your applications:
- Discover and view errors generated by your applications with [Error Tracking](error_tracking.md).
- Create, toggle, and remove [Feature Flags](feature_flags.md). **(PREMIUM)**
- [Trace](tracing.md) the performance and health of a deployed application. **(ULTIMATE)**
- Add a [button to the Monitoring dashboard](linking_to_an_external_dashboard.md) linking directly to your existing external dashboards.
- Change the [settings of the Monitoring Dashboard](dashboard_settings.md).

View File

@ -1,19 +1,5 @@
# Linking to an external dashboard
---
redirect_to: 'dashboard_settings.md'
---
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/57171) in GitLab 12.0.
You can add a button to the Monitoring dashboard linking directly to your existing external dashboards.
## Enabling the external dashboard link
1. Go to **Settings > Operations** and scroll to the section titled **External dashboard**.
1. Fill in the URL to your external dashboard and click **Save changes**.
![External Dashboard Settings](img/external_dashboard_settings.png)
1. There should now be a button on your
[Monitoring dashboard](../../../ci/environments/index.md#monitoring-environments) which
will open the URL you entered in the above step.
![External Dashboard Link](img/external_dashboard_link.png)
This document was moved to [another location](dashboard_settings.md).

View File

@ -63,6 +63,25 @@ module API
present storage_move, with: Entities::ProjectRepositoryStorageMove, current_user: current_user
end
desc 'Schedule a project repository storage move' do
detail 'This feature was introduced in GitLab 13.1.'
success Entities::ProjectRepositoryStorageMove
end
params do
requires :destination_storage_name, type: String, desc: 'The destination storage shard'
end
post ':id/repository_storage_moves' do
storage_move = user_project.repository_storage_moves.build(
declared_params.merge(source_storage_name: user_project.repository_storage)
)
if storage_move.schedule
present storage_move, with: Entities::ProjectRepositoryStorageMove, current_user: current_user
else
render_validation_error!(storage_move)
end
end
end
end
end

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
module Gitlab
module Ci
module Build
class Releaser
BASE_COMMAND = 'release-cli create'
attr_reader :config
def initialize(config:)
@config = config
end
def script
command = BASE_COMMAND.dup
config.each { |k, v| command.concat(" --#{k.to_s.dasherize} \"#{v}\"") }
command
end
end
end
end
end

View File

@ -19,6 +19,7 @@ license_scanning:
entrypoint: [""]
variables:
LM_REPORT_FILE: gl-license-scanning-report.json
LM_REPORT_VERSION: '2.1'
SETUP_CMD: $LICENSE_MANAGEMENT_SETUP_CMD
allow_failure: true
script:

View File

@ -109,9 +109,18 @@ module Gitlab
remove_column(table_name, partition_column.name)
rename_column(table_name, tmp_column_name, partition_column.name)
change_column_default(table_name, primary_key, nil)
if column_of_type?(table_name, primary_key, :integer)
# Default to int8 primary keys to prevent overflow
change_column(table_name, primary_key, :bigint)
end
end
end
def column_of_type?(table_name, column, type)
find_column_definition(table_name, column).type == type
end
def create_daterange_partitions(table_name, column_name, min_date, max_date)
min_date = min_date.beginning_of_month.to_date
max_date = max_date.next_month.beginning_of_month.to_date

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
module Gitlab
module Metrics
module Dashboard
module Stages
class UrlValidator < BaseStage
def transform!
dashboard[:links]&.each do |link|
Gitlab::UrlBlocker.validate!(link[:url])
rescue Gitlab::UrlBlocker::BlockedUrlError
link[:url] = ''
end
end
end
end
end
end
end

View File

@ -361,7 +361,13 @@ describe('Monitoring store actions', () => {
return testAction(toggleStarredValue, null, state, [
{ type: types.REQUEST_DASHBOARD_STARRING },
{ type: types.RECEIVE_DASHBOARD_STARRING_SUCCESS, payload: true },
{
type: types.RECEIVE_DASHBOARD_STARRING_SUCCESS,
payload: {
newStarredValue: true,
selectedDashboard: unstarredDashboard,
},
},
]);
});

View File

@ -93,14 +93,20 @@ describe('Monitoring mutations', () => {
});
it('sets a dashboard as starred', () => {
mutations[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](stateCopy, true);
mutations[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](stateCopy, {
selectedDashboard: stateCopy.allDashboards[1],
newStarredValue: true,
});
expect(stateCopy.isUpdatingStarredValue).toBe(false);
expect(stateCopy.allDashboards[1].starred).toBe(true);
});
it('sets a dashboard as unstarred', () => {
mutations[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](stateCopy, false);
mutations[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](stateCopy, {
selectedDashboard: stateCopy.allDashboards[1],
newStarredValue: false,
});
expect(stateCopy.isUpdatingStarredValue).toBe(false);
expect(stateCopy.allDashboards[1].starred).toBe(false);

View File

@ -20,9 +20,7 @@ describe('operation settings external dashboard component', () => {
const operationsSettingsEndpoint = `${TEST_HOST}/mock/ops/settings/endpoint`;
const helpPage = `${TEST_HOST}/help/metrics/page/path`;
const externalDashboardUrl = `http://mock-external-domain.com/external/dashboard/url`;
const externalDashboardHelpPage = `${TEST_HOST}/help/external/page/path`;
const dashboardTimezoneSetting = timezones.LOCAL;
const dashboardTimezoneHelpPage = `${TEST_HOST}/help/timezone/page/path`;
const mountComponent = (shallow = true) => {
const config = [
@ -32,9 +30,7 @@ describe('operation settings external dashboard component', () => {
operationsSettingsEndpoint,
helpPage,
externalDashboardUrl,
externalDashboardHelpPage,
dashboardTimezoneSetting,
dashboardTimezoneHelpPage,
}),
stubs: {
ExternalDashboard,
@ -140,7 +136,7 @@ describe('operation settings external dashboard component', () => {
it('uses description text', () => {
const description = formGroup.find('small');
expect(description.find('a').attributes('href')).toBe(externalDashboardHelpPage);
expect(description.text()).not.toBeFalsy();
});
});

View File

@ -0,0 +1,51 @@
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Ci::Build::Releaser do
subject { described_class.new(config: config[:release]).script }
describe '#script' do
context 'all nodes' do
let(:config) do
{
release: {
name: 'Release $CI_COMMIT_SHA',
description: 'Created using the release-cli $EXTRA_DESCRIPTION',
tag_name: 'release-$CI_COMMIT_SHA',
ref: '$CI_COMMIT_SHA'
}
}
end
it 'generates the script' do
expect(subject).to eq('release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA"')
end
end
context 'individual nodes' do
using RSpec::Parameterized::TableSyntax
where(:node_name, :node_value, :result) do
'name' | 'Release $CI_COMMIT_SHA' | 'release-cli create --name "Release $CI_COMMIT_SHA"'
'description' | 'Release-cli $EXTRA_DESCRIPTION' | 'release-cli create --description "Release-cli $EXTRA_DESCRIPTION"'
'tag_name' | 'release-$CI_COMMIT_SHA' | 'release-cli create --tag-name "release-$CI_COMMIT_SHA"'
'ref' | '$CI_COMMIT_SHA' | 'release-cli create --ref "$CI_COMMIT_SHA"'
end
with_them do
let(:config) do
{
release: {
node_name => node_value
}
}
end
it 'generates the script' do
expect(subject).to eq(result)
end
end
end
end
end

View File

@ -111,6 +111,36 @@ describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
expect_table_partitioned_by(partitioned_table, [partition_column])
end
it 'changes the primary key datatype to bigint' do
migration.partition_table_by_date template_table, partition_column, min_date: min_date, max_date: max_date
pk_column = connection.columns(partitioned_table).find { |c| c.name == old_primary_key }
expect(pk_column.sql_type).to eq('bigint')
end
context 'with a non-integer primary key datatype' do
before do
connection.create_table :another_example, id: false do |t|
t.string :identifier, primary_key: true
t.timestamp :created_at
end
end
let(:template_table) { :another_example }
let(:old_primary_key) { 'identifier' }
it 'does not change the primary key datatype' do
migration.partition_table_by_date template_table, partition_column, min_date: min_date, max_date: max_date
original_pk_column = connection.columns(template_table).find { |c| c.name == old_primary_key }
pk_column = connection.columns(partitioned_table).find { |c| c.name == old_primary_key }
expect(pk_column).not_to be_nil
expect(pk_column).to eq(original_pk_column)
end
end
it 'removes the default from the primary key column' do
migration.partition_table_by_date template_table, partition_column, min_date: min_date, max_date: max_date

View File

@ -16,7 +16,8 @@ describe Gitlab::Metrics::Dashboard::Processor do
Gitlab::Metrics::Dashboard::Stages::EndpointInserter,
Gitlab::Metrics::Dashboard::Stages::Sorter,
Gitlab::Metrics::Dashboard::Stages::AlertsInserter,
Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter
Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter,
Gitlab::Metrics::Dashboard::Stages::UrlValidator
]
end
@ -201,6 +202,27 @@ describe Gitlab::Metrics::Dashboard::Processor do
it_behaves_like 'errors with message', 'Each "metric" must define one of :query or :query_range'
end
describe 'validating links' do
context 'when the links contain a blocked url' do
let(:dashboard_yml_links) do
[{ 'url' => 'http://1.1.1.1.1' }, { 'url' => 'https://gitlab.com' }]
end
let(:expected) do
[{ url: '' }, { url: 'https://gitlab.com' }]
end
before do
stub_env('RSPEC_ALLOW_INVALID_URLS', 'false')
dashboard_yml['links'] = dashboard_yml_links
end
it 'replaces the blocked url with an empty string' do
expect(dashboard[:links]).to eq(expected)
end
end
end
end
private

View File

@ -111,4 +111,45 @@ describe API::ProjectRepositoryStorageMoves do
let(:url) { "/projects/#{project.id}/repository_storage_moves/#{project_repository_storage_move_id}" }
end
end
describe 'POST /projects/:id/repository_storage_moves' do
let(:url) { "/projects/#{project.id}/repository_storage_moves" }
let(:destination_storage_name) { 'test_second_storage' }
def create_project_repository_storage_move
post api(url, user), params: { destination_storage_name: destination_storage_name }
end
before do
stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' })
end
it 'schedules a project repository storage move' do
create_project_repository_storage_move
storage_move = project.repository_storage_moves.last
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/project_repository_storage_move')
expect(json_response['id']).to eq(storage_move.id)
expect(json_response['state']).to eq('scheduled')
expect(json_response['source_storage_name']).to eq('default')
expect(json_response['destination_storage_name']).to eq(destination_storage_name)
end
describe 'permissions' do
it { expect { create_project_repository_storage_move }.to be_allowed_for(:admin) }
it { expect { create_project_repository_storage_move }.to be_denied_for(:user) }
end
context 'destination_storage_name is missing' do
let(:destination_storage_name) { nil }
it 'returns a validation error' do
create_project_repository_storage_move
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
end

View File

@ -1,12 +1,11 @@
# frozen_string_literal: true
require 'spec_helper'
require 'fast_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../rubocop/cop/filename_length'
require_relative '../../support/helpers/expect_offense'
describe RuboCop::Cop::FilenameLength do
describe RuboCop::Cop::FilenameLength, type: :rubocop do
subject(:cop) { described_class.new }
it 'does not flag files with names 100 characters long' do

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/performance/ar_count_each.rb'
describe RuboCop::Cop::Performance::ARCountEach do
describe RuboCop::Cop::Performance::ARCountEach, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/performance/ar_exists_and_present_blank.rb'
describe RuboCop::Cop::Performance::ARExistsAndPresentBlank do
describe RuboCop::Cop::Performance::ARExistsAndPresentBlank, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/performance/readlines_each'
describe RuboCop::Cop::Performance::ReadlinesEach do
describe RuboCop::Cop::Performance::ReadlinesEach, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -2,10 +2,9 @@
require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/rspec/modify_sidekiq_middleware'
describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware do
describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -2,10 +2,9 @@
require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/scalability/bulk_perform_with_context'
describe RuboCop::Cop::Scalability::BulkPerformWithContext do
describe RuboCop::Cop::Scalability::BulkPerformWithContext, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -2,10 +2,9 @@
require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/scalability/cron_worker_context'
describe RuboCop::Cop::Scalability::CronWorkerContext do
describe RuboCop::Cop::Scalability::CronWorkerContext, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -2,10 +2,9 @@
require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/scalability/file_uploads'
describe RuboCop::Cop::Scalability::FileUploads do
describe RuboCop::Cop::Scalability::FileUploads, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -2,10 +2,9 @@
require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../support/helpers/expect_offense'
require_relative '../../../../rubocop/cop/scalability/idempotent_worker'
describe RuboCop::Cop::Scalability::IdempotentWorker do
describe RuboCop::Cop::Scalability::IdempotentWorker, type: :rubocop do
include CopHelper
include ExpectOffense

View File

@ -4,6 +4,7 @@ require_relative "helpers/stub_configuration"
require_relative "helpers/stub_metrics"
require_relative "helpers/stub_object_storage"
require_relative "helpers/stub_env"
require_relative "helpers/expect_offense"
RSpec.configure do |config|
config.mock_with :rspec
@ -13,4 +14,6 @@ RSpec.configure do |config|
config.include StubMetrics
config.include StubObjectStorage
config.include StubENV
config.include ExpectOffense, type: :rubocop
end