From 760822a53715549c2f115370ed24a19db1b7d63a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 9 Apr 2021 06:09:30 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- GITALY_SERVER_VERSION | 2 +- .../commit/pipelines/pipelines_table.vue | 16 ++-- .../edit/components/trigger_fields.vue | 2 +- .../components/pipeline_new_form.vue | 8 +- .../pipelines_list/nav_controls.vue | 28 +++--- app/controllers/chaos_controller.rb | 6 +- .../mutations/ci/ci_cd_settings_update.rb | 12 ++- app/models/project_services/slack_service.rb | 4 +- .../blob/viewers/_loading_auxiliary.html.haml | 2 +- app/views/projects/pipelines/new.html.haml | 8 +- app/views/projects/services/slack/_help.haml | 16 +--- app/workers/chaos/kill_worker.rb | 4 +- ...-and-update-buttons-on-projects-pipeli.yml | 6 ++ ...n-viewers-_loading_auxiliary-html-haml.yml | 5 ++ changelogs/unreleased/btn-confirm-geo.yml | 5 ++ changelogs/unreleased/mk-chaos-quit.yml | 5 ++ .../unreleased/ui-text-slack-integration.yml | 5 ++ config/routes.rb | 1 + doc/api/graphql/reference/index.md | 1 + doc/ci/merge_request_pipelines/index.md | 2 +- doc/ci/pipelines/index.md | 4 +- doc/development/chaos_endpoints.md | 28 +++++- doc/development/cicd/index.md | 2 +- doc/development/code_review.md | 2 +- .../documentation/site_architecture/index.md | 2 +- doc/topics/autodevops/stages.md | 2 +- .../project/merge_requests/code_quality.md | 2 +- lib/gitlab/chaos.rb | 6 +- lib/gitlab/usage_data.rb | 90 +++++-------------- lib/gitlab/usage_data_queries.rb | 6 ++ lib/gitlab/utils/usage_data.rb | 15 ++++ locale/gitlab.pot | 42 ++++----- qa/qa/page/project/pipeline/index.rb | 2 +- spec/controllers/chaos_controller_spec.rb | 22 ++++- .../merge_request/user_sees_pipelines_spec.rb | 12 +-- .../projects/pipelines/pipelines_spec.rb | 88 +++++++++--------- .../edit/components/trigger_fields_spec.js | 4 +- spec/frontend/pipelines/nav_controls_spec.js | 6 +- spec/frontend/pipelines/pipelines_spec.js | 18 ++-- spec/lib/gitlab/usage_data_queries_spec.rb | 20 +++++ spec/lib/gitlab/utils/usage_data_spec.rb | 18 ++++ 41 files changed, 300 insertions(+), 229 deletions(-) create mode 100644 changelogs/unreleased/273293-fy21q4-foundations-kr2-audit-and-update-buttons-on-projects-pipeli.yml create mode 100644 changelogs/unreleased/Externalise-strings-in-viewers-_loading_auxiliary-html-haml.yml create mode 100644 changelogs/unreleased/btn-confirm-geo.yml create mode 100644 changelogs/unreleased/mk-chaos-quit.yml create mode 100644 changelogs/unreleased/ui-text-slack-integration.yml diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index c422dc2d718..6481c6362c3 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -434d5055aa05cc40197bbffc4a3c6ce325fa7027 +2b9f2f35e178b8b56b5f657420aa72c6a77c62eb diff --git a/app/assets/javascripts/commit/pipelines/pipelines_table.vue b/app/assets/javascripts/commit/pipelines/pipelines_table.vue index 44499a86a3f..7cd63ac152c 100644 --- a/app/assets/javascripts/commit/pipelines/pipelines_table.vue +++ b/app/assets/javascripts/commit/pipelines/pipelines_table.vue @@ -81,7 +81,7 @@ export default { return this.hasError && !this.isLoading; }, /** - * The Run Pipeline button can only be rendered when: + * The "Run pipeline" button can only be rendered when: * - In MR view - we use `canCreatePipelineInTargetProject` for that purpose * - If the latest pipeline has the `detached_merge_request_pipeline` flag * @@ -148,7 +148,7 @@ export default { } }, /** - * When the user clicks on the Run Pipeline button + * When the user clicks on the "Run pipeline" button * we need to make a post request and * to update the table content once the request is finished. * @@ -177,7 +177,7 @@ export default {
@@ -197,12 +197,12 @@ export default { block class="gl-mt-3 gl-mb-3" :class="pipelineButtonClass" - variant="success" + variant="confirm" data-testid="run_pipeline_button_mobile" :loading="state.isRunningMergeRequestPipeline" @click="tryRunPipeline" > - {{ s__('Pipelines|Run Pipeline') }} + {{ s__('Pipeline|Run pipeline') }}
- {{ s__('Pipelines|Run Pipeline') }} + {{ s__('Pipeline|Run pipeline') }}
@@ -231,7 +231,7 @@ export default { ref="modal" :modal-id="modalId" :title="s__('Pipelines|Are you sure you want to run this pipeline?')" - :ok-title="s__('Pipelines|Run Pipeline')" + :ok-title="s__('Pipeline|Run pipeline')" ok-variant="danger" @ok="onClickRunPipeline" > diff --git a/app/assets/javascripts/integrations/edit/components/trigger_fields.vue b/app/assets/javascripts/integrations/edit/components/trigger_fields.vue index 2c02484d629..42bc9e4c8a1 100644 --- a/app/assets/javascripts/integrations/edit/components/trigger_fields.vue +++ b/app/assets/javascripts/integrations/edit/components/trigger_fields.vue @@ -10,7 +10,7 @@ const typeWithPlaceholder = { }; const placeholderForType = { - [typeWithPlaceholder.SLACK]: __('Slack channels (e.g. general, development)'), + [typeWithPlaceholder.SLACK]: __('general, development'), [typeWithPlaceholder.MATTERMOST]: __('my-channel'), }; diff --git a/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue b/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue index 1c5513efdd2..e44d80ee9d1 100644 --- a/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue +++ b/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue @@ -444,18 +444,16 @@ export default { -
+
{{ s__('Pipeline|Run Pipeline') }}{{ s__('Pipeline|Run pipeline') }} {{ __('Cancel') }}
diff --git a/app/assets/javascripts/pipelines/components/pipelines_list/nav_controls.vue b/app/assets/javascripts/pipelines/components/pipelines_list/nav_controls.vue index cf0849751df..235126fea0c 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_list/nav_controls.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_list/nav_controls.vue @@ -40,18 +40,6 @@ export default { diff --git a/app/controllers/chaos_controller.rb b/app/controllers/chaos_controller.rb index 0ec6a2cb38a..1cfcd2905f2 100644 --- a/app/controllers/chaos_controller.rb +++ b/app/controllers/chaos_controller.rb @@ -20,7 +20,11 @@ class ChaosController < ActionController::Base end def kill - do_chaos :kill, Chaos::KillWorker + do_chaos :kill, Chaos::KillWorker, 'KILL' + end + + def quit + do_chaos :kill, Chaos::KillWorker, 'QUIT' end def gc diff --git a/app/graphql/mutations/ci/ci_cd_settings_update.rb b/app/graphql/mutations/ci/ci_cd_settings_update.rb index 6b7750ee860..d7451babaea 100644 --- a/app/graphql/mutations/ci/ci_cd_settings_update.rb +++ b/app/graphql/mutations/ci/ci_cd_settings_update.rb @@ -17,13 +17,23 @@ module Mutations required: false, description: 'Indicates if the latest artifact should be kept for this project.' + field :ci_cd_settings, + Types::Ci::CiCdSettingType, + null: false, + description: 'The CI/CD settings after mutation.' + def resolve(full_path:, **args) project = authorized_find!(full_path) settings = project.ci_cd_settings settings.update(args) - { errors: errors_on_object(settings) } + { + ci_cd_settings: settings, + errors: errors_on_object(settings) + } end end end end + +Mutations::Ci::CiCdSettingsUpdate.prepend_if_ee('::EE::Mutations::Ci::CiCdSettingsUpdate') diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index f42b3de39d5..7badcc24870 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -16,7 +16,7 @@ class SlackService < ChatNotificationService end def description - 'Receive event notifications in Slack' + 'Send notifications about project events to Slack.' end def self.to_param @@ -24,7 +24,7 @@ class SlackService < ChatNotificationService end def default_channel_placeholder - _('Slack channels (e.g. general, development)') + _('general, development') end def webhook_placeholder diff --git a/app/views/projects/blob/viewers/_loading_auxiliary.html.haml b/app/views/projects/blob/viewers/_loading_auxiliary.html.haml index 5a6c1a493a5..5a2212e0b4e 100644 --- a/app/views/projects/blob/viewers/_loading_auxiliary.html.haml +++ b/app/views/projects/blob/viewers/_loading_auxiliary.html.haml @@ -1,2 +1,2 @@ = loading_icon(css_class: "gl-vertical-align-text-bottom") -Analyzing file… += _("Analyzing file…") diff --git a/app/views/projects/pipelines/new.html.haml b/app/views/projects/pipelines/new.html.haml index 7a3817fe87b..14de982e239 100644 --- a/app/views/projects/pipelines/new.html.haml +++ b/app/views/projects/pipelines/new.html.haml @@ -1,9 +1,9 @@ - breadcrumb_title _('Pipelines') -- page_title s_('Pipeline|Run Pipeline') +- page_title s_('Pipeline|Run pipeline') - settings_link = link_to _('CI/CD settings'), project_settings_ci_cd_path(@project) %h3.page-title - = s_('Pipeline|Run Pipeline') + = s_('Pipeline|Run pipeline') %hr - if Feature.enabled?(:new_pipeline_form, @project, default_enabled: :yaml) @@ -49,7 +49,7 @@ = (s_("Pipeline|Specify variable values to be used in this run. The values specified in %{settings_link} will be used by default.") % {settings_link: settings_link}).html_safe .form-actions - = f.submit s_('Pipeline|Run Pipeline'), class: 'btn btn-success js-variables-save-button' - = link_to _('Cancel'), project_pipelines_path(@project), class: 'btn btn-default float-right' + = f.submit s_('Pipeline|Run pipeline'), class: 'btn gl-button btn-confirm gl-mr-3 js-variables-save-button' + = link_to _('Cancel'), project_pipelines_path(@project), class: 'btn gl-button btn-default' %script#availableRefs{ type: "application/json" }= @project.repository.ref_names.to_json.html_safe diff --git a/app/views/projects/services/slack/_help.haml b/app/views/projects/services/slack/_help.haml index 1fd448020a0..c5fcd5ca5fe 100644 --- a/app/views/projects/services/slack/_help.haml +++ b/app/views/projects/services/slack/_help.haml @@ -1,16 +1,4 @@ -- webhooks_link_url = 'https://slack.com/apps/A0F7XDUAZ-incoming-webhooks' -- webhooks_link_start = ''.html_safe % { url: webhooks_link_url } - .info-well .well-segment - %p= s_('SlackIntegration|This service sends notifications about project events to Slack channels. To set up this service:') - %ol - %li - = html_escape(s_('SlackIntegration|%{webhooks_link_start}Add an incoming webhook%{webhooks_link_end} in your Slack team. The default channel can be overridden for each event.')) % { webhooks_link_start: webhooks_link_start.html_safe, webhooks_link_end: ''.html_safe } - %li - = html_escape(s_('SlackIntegration|Paste the %{strong_open}Webhook URL%{strong_close} into the field below.')) % { strong_open: ''.html_safe, strong_close: ''.html_safe } - %li - = html_escape(s_('SlackIntegration|Select events below to enable notifications. The %{strong_open}Slack channel names%{strong_close} and %{strong_open}Slack username%{strong_close} fields are optional.')) % { strong_open: ''.html_safe, strong_close: ''.html_safe } - %p.mt-3.mb-0 - = html_escape(s_('SlackIntegration|%{strong_open}Note:%{strong_close} Usernames and private channels are not supported.')) % { strong_open: ''.html_safe, strong_close: ''.html_safe } - = link_to _('Learn more'), help_page_path('user/project/integrations/slack') + %p= s_('SlackIntegration|Sends notifications about project events to Slack channels.') + = link_to _('How do I set up this service?'), help_page_path('user/project/integrations/slack') diff --git a/app/workers/chaos/kill_worker.rb b/app/workers/chaos/kill_worker.rb index 3dedd47a1f9..4148c139d42 100644 --- a/app/workers/chaos/kill_worker.rb +++ b/app/workers/chaos/kill_worker.rb @@ -7,8 +7,8 @@ module Chaos sidekiq_options retry: false - def perform - Gitlab::Chaos.kill + def perform(signal) + Gitlab::Chaos.kill(signal) end end end diff --git a/changelogs/unreleased/273293-fy21q4-foundations-kr2-audit-and-update-buttons-on-projects-pipeli.yml b/changelogs/unreleased/273293-fy21q4-foundations-kr2-audit-and-update-buttons-on-projects-pipeli.yml new file mode 100644 index 00000000000..0d8dfa4ab81 --- /dev/null +++ b/changelogs/unreleased/273293-fy21q4-foundations-kr2-audit-and-update-buttons-on-projects-pipeli.yml @@ -0,0 +1,6 @@ +--- +title: Updating success button to confirm variant and reordering buttons per Pajamas + Design System guidelines for buttons +merge_request: 58112 +author: +type: other diff --git a/changelogs/unreleased/Externalise-strings-in-viewers-_loading_auxiliary-html-haml.yml b/changelogs/unreleased/Externalise-strings-in-viewers-_loading_auxiliary-html-haml.yml new file mode 100644 index 00000000000..ef881d5a749 --- /dev/null +++ b/changelogs/unreleased/Externalise-strings-in-viewers-_loading_auxiliary-html-haml.yml @@ -0,0 +1,5 @@ +--- +title: Externalize strings in viewers/_loading_auxiliary.html.haml +merge_request: 58454 +author: nuwe1 +type: other diff --git a/changelogs/unreleased/btn-confirm-geo.yml b/changelogs/unreleased/btn-confirm-geo.yml new file mode 100644 index 00000000000..5a37e360da9 --- /dev/null +++ b/changelogs/unreleased/btn-confirm-geo.yml @@ -0,0 +1,5 @@ +--- +title: Move to btn-confirm from btn-success in geo directory +merge_request: 58031 +author: Yogi (@yo) +type: changed diff --git a/changelogs/unreleased/mk-chaos-quit.yml b/changelogs/unreleased/mk-chaos-quit.yml new file mode 100644 index 00000000000..3db35a10159 --- /dev/null +++ b/changelogs/unreleased/mk-chaos-quit.yml @@ -0,0 +1,5 @@ +--- +title: Add a chaos endpoint that signals QUIT +merge_request: 58755 +author: +type: changed diff --git a/changelogs/unreleased/ui-text-slack-integration.yml b/changelogs/unreleased/ui-text-slack-integration.yml new file mode 100644 index 00000000000..64e5c2d76ba --- /dev/null +++ b/changelogs/unreleased/ui-text-slack-integration.yml @@ -0,0 +1,5 @@ +--- +title: Update UI text for slack notifications integration +merge_request: 58845 +author: +type: other diff --git a/config/routes.rb b/config/routes.rb index c21c920117f..1258675df86 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -179,6 +179,7 @@ Rails.application.routes.draw do get :db_spin get :sleep get :kill + get :quit post :gc end end diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index d2b09f97515..56b5bcce3f1 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -1055,6 +1055,7 @@ Autogenerated return type of CiCdSettingsUpdate. | Field | Type | Description | | ----- | ---- | ----------- | +| `ciCdSettings` | [`ProjectCiCdSetting!`](#projectcicdsetting) | The CI/CD settings after mutation. | | `clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. | | `errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. | diff --git a/doc/ci/merge_request_pipelines/index.md b/doc/ci/merge_request_pipelines/index.md index 7e76efe8b50..024155bdde7 100644 --- a/doc/ci/merge_request_pipelines/index.md +++ b/doc/ci/merge_request_pipelines/index.md @@ -197,7 +197,7 @@ could mistakenly trust the merge request because it passed a faked pipeline. Parent project members with at least [Developer permissions](../../user/permissions.md) can create pipelines in the parent project for merge requests from a forked project. In the merge request, go to the **Pipelines** and click -**Run Pipeline** button. +**Run pipeline** button. WARNING: Fork merge requests could contain malicious code that tries to steal secrets in the diff --git a/doc/ci/pipelines/index.md b/doc/ci/pipelines/index.md index 7b3d59db4a1..6d013a43583 100644 --- a/doc/ci/pipelines/index.md +++ b/doc/ci/pipelines/index.md @@ -133,8 +133,8 @@ operation of the pipeline. To execute a pipeline manually: 1. Navigate to your project's **CI/CD > Pipelines**. -1. Select the **Run Pipeline** button. -1. On the **Run Pipeline** page: +1. Select the **Run pipeline** button. +1. On the **Run pipeline** page: 1. Select the branch or tag to run the pipeline for in the **Run for branch name or tag** field. 1. Enter any [environment variables](../variables/README.md) required for the pipeline run. You can set specific variables to have their [values prefilled in the form](#prefill-variables-in-manual-pipelines). diff --git a/doc/development/chaos_endpoints.md b/doc/development/chaos_endpoints.md index 85c93f521ac..56e91acbc4a 100644 --- a/doc/development/chaos_endpoints.md +++ b/doc/development/chaos_endpoints.md @@ -146,10 +146,10 @@ curl "http://localhost:3000/-/chaos/sleep?duration_s=60&token=secret" ## Kill -This endpoint simulates the unexpected death of a worker process using a `kill` signal. +This endpoint simulates the unexpected death of a worker process using the `KILL` signal. -Because this endpoint uses the `KILL` signal, the worker isn't given an -opportunity to cleanup or shutdown. +Because this endpoint uses the `KILL` signal, the process isn't given an +opportunity to clean up or shut down. ```plaintext GET /-/chaos/kill @@ -158,13 +158,33 @@ GET /-/chaos/kill?async=true | Attribute | Type | Required | Description | | ------------ | ------- | -------- | ---------------------------------------------------------------------- | -| `async` | boolean | no | Set to true to kill a Sidekiq background worker process | +| `async` | boolean | no | Set to true to signal a Sidekiq background worker process | ```shell curl "http://localhost:3000/-/chaos/kill" --header 'X-Chaos-Secret: secret' curl "http://localhost:3000/-/chaos/kill?token=secret" ``` +## Quit + +This endpoint simulates the unexpected death of a worker process using the `QUIT` signal. +Unlike `KILL`, the `QUIT` signal will also attempt to write a core dump. +See [core(5)](https://man7.org/linux/man-pages/man5/core.5.html) for more information. + +```plaintext +GET /-/chaos/quit +GET /-/chaos/quit?async=true +``` + +| Attribute | Type | Required | Description | +| ------------ | ------- | -------- | ---------------------------------------------------------------------- | +| `async` | boolean | no | Set to true to signal a Sidekiq background worker process | + +```shell +curl "http://localhost:3000/-/chaos/quit" --header 'X-Chaos-Secret: secret' +curl "http://localhost:3000/-/chaos/quit?token=secret" +``` + ## Run garbage collector This endpoint triggers a GC run on the worker handling the request and returns its worker ID diff --git a/doc/development/cicd/index.md b/doc/development/cicd/index.md index 242446590bb..35c4cc0694e 100644 --- a/doc/development/cicd/index.md +++ b/doc/development/cicd/index.md @@ -23,7 +23,7 @@ On the left side we have the events that can trigger a pipeline based on various - A `git push` is the most common event that triggers a pipeline. - The [Web API](../../api/pipelines.md#create-a-new-pipeline). -- A user clicking the "Run Pipeline" button in the UI. +- A user clicking the "Run pipeline" button in the UI. - When a [merge request is created or updated](../../ci/merge_request_pipelines/index.md#pipelines-for-merge-requests). - When an MR is added to a [Merge Train](../../ci/merge_request_pipelines/pipelines_for_merged_results/merge_trains/index.md#merge-trains). - A [scheduled pipeline](../../ci/pipelines/schedules.md#pipeline-schedules). diff --git a/doc/development/code_review.md b/doc/development/code_review.md index 7f730a23776..731fec98933 100644 --- a/doc/development/code_review.md +++ b/doc/development/code_review.md @@ -418,7 +418,7 @@ If the MR source branch is more than 100 commits behind the target branch, ask t Review links and images, especially in documentation MRs. When in doubt, ask someone from `@gitlab-com/gl-security/appsec` to review the merge request **before starting any merge request pipeline**. -- Start a new merge request pipeline with the `Run Pipeline` button in the merge +- Start a new merge request pipeline with the `Run pipeline` button in the merge request's "Pipelines" tab, and enable "Merge When Pipeline Succeeds" (MWPS). Note that: - If **[master is broken](https://about.gitlab.com/handbook/engineering/workflow/#broken-master), diff --git a/doc/development/documentation/site_architecture/index.md b/doc/development/documentation/site_architecture/index.md index c6413e64231..35e9ab5157b 100644 --- a/doc/development/documentation/site_architecture/index.md +++ b/doc/development/documentation/site_architecture/index.md @@ -119,7 +119,7 @@ pipeline in the main `gitlab` repository as well as in `gitlab-docs`. Create an a different name first and test it to ensure you do not break the pipelines. 1. In [`gitlab-docs`](https://gitlab.com/gitlab-org/gitlab-docs), go to **{rocket}** **CI/CD > Pipelines**. -1. Click the **Run Pipeline** button. +1. Click the **Run pipeline** button. 1. See that a new pipeline is running. The jobs that build the images are in the first stage, `build-images`. You can click the pipeline number to see the larger pipeline graph, or click the first (`build-images`) stage in the mini pipeline graph to diff --git a/doc/topics/autodevops/stages.md b/doc/topics/autodevops/stages.md index 64ff60dd756..97edc9adc06 100644 --- a/doc/topics/autodevops/stages.md +++ b/doc/topics/autodevops/stages.md @@ -732,7 +732,7 @@ To use Auto Monitoring: 1. [Install and configure the Auto DevOps requirements](requirements.md). 1. [Enable Auto DevOps](index.md#enable-or-disable-auto-devops), if you haven't done already. -1. Navigate to your project's **{rocket}** **CI/CD > Pipelines** and click **Run Pipeline**. +1. Navigate to your project's **{rocket}** **CI/CD > Pipelines** and click **Run pipeline**. 1. After the pipeline finishes successfully, open the [monitoring dashboard for a deployed environment](../../ci/environments/index.md#monitoring-environments) to view the metrics of your deployed application. To view the metrics of the diff --git a/doc/user/project/merge_requests/code_quality.md b/doc/user/project/merge_requests/code_quality.md index 9f6abe7a89f..bb6e9611483 100644 --- a/doc/user/project/merge_requests/code_quality.md +++ b/doc/user/project/merge_requests/code_quality.md @@ -246,7 +246,7 @@ This can be done: - For a single pipeline run: 1. Go to **CI/CD > Pipelines** - 1. Click **Run Pipeline** + 1. Click **Run pipeline** 1. Add `CODE_QUALITY_DISABLED` as the variable key, with any value. ### Using with merge request pipelines diff --git a/lib/gitlab/chaos.rb b/lib/gitlab/chaos.rb index 029a9210dc9..495f12882e5 100644 --- a/lib/gitlab/chaos.rb +++ b/lib/gitlab/chaos.rb @@ -43,9 +43,9 @@ module Gitlab Kernel.sleep(duration_s) end - # Kill will send a SIGKILL signal to the current process - def self.kill - Process.kill("KILL", Process.pid) + # Kill will send the given signal to the current process. + def self.kill(signal) + Process.kill(signal, Process.pid) end def self.run_gc diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 2b84789afc4..b36ca38cd64 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -87,7 +87,7 @@ module Gitlab # rubocop: disable Metrics/AbcSize # rubocop: disable CodeReuse/ActiveRecord def system_usage_data - issues_created_manually_from_alerts = count(Issue.with_alert_management_alerts.not_authored_by(::User.alert_bot), start: issue_minimum_id, finish: issue_maximum_id) + issues_created_manually_from_alerts = count(Issue.with_alert_management_alerts.not_authored_by(::User.alert_bot), start: minimum_id(Issue), finish: maximum_id(Issue)) { counts: { @@ -138,7 +138,7 @@ module Gitlab in_review_folder: count(::Environment.in_review_folder), grafana_integrated_projects: count(GrafanaIntegration.enabled), groups: count(Group), - issues: count(Issue, start: issue_minimum_id, finish: issue_maximum_id), + issues: count(Issue, start: minimum_id(Issue), finish: maximum_id(Issue)), issues_created_from_gitlab_error_tracking_ui: count(SentryIssue), issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue), issues_using_zoom_quick_actions: distinct_count(ZoomMeeting, :issue_id), @@ -146,9 +146,9 @@ module Gitlab issues_created_from_alerts: total_alert_issues, issues_created_gitlab_alerts: issues_created_manually_from_alerts, issues_created_manually_from_alerts: issues_created_manually_from_alerts, - incident_issues: count(::Issue.incident, start: issue_minimum_id, finish: issue_maximum_id), - alert_bot_incident_issues: count(::Issue.authored(::User.alert_bot), start: issue_minimum_id, finish: issue_maximum_id), - incident_labeled_issues: count(::Issue.with_label_attributes(::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES), start: issue_minimum_id, finish: issue_maximum_id), + incident_issues: count(::Issue.incident, start: minimum_id(Issue), finish: maximum_id(Issue)), + alert_bot_incident_issues: count(::Issue.authored(::User.alert_bot), start: minimum_id(Issue), finish: maximum_id(Issue)), + incident_labeled_issues: count(::Issue.with_label_attributes(::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES), start: minimum_id(Issue), finish: maximum_id(Issue)), keys: count(Key), label_lists: count(List.label), lfs_objects: count(LfsObject), @@ -389,8 +389,8 @@ module Gitlab # rubocop: disable CodeReuse/ActiveRecord def container_expiration_policies_usage results = {} - start = ::Project.minimum(:id) - finish = ::Project.maximum(:id) + start = minimum_id(Project) + finish = maximum_id(Project) results[:projects_with_expiration_policy_disabled] = distinct_count(::ContainerExpirationPolicy.where(enabled: false), :project_id, start: start, finish: finish) # rubocop: disable UsageData/LargeTable @@ -591,7 +591,7 @@ module Gitlab { events: distinct_count(::Event.where(time_period), :author_id), groups: distinct_count(::GroupMember.where(time_period), :user_id), - users_created: count(::User.where(time_period), start: user_minimum_id, finish: user_maximum_id), + users_created: count(::User.where(time_period), start: minimum_id(User), finish: maximum_id(User)), omniauth_providers: filtered_omniauth_provider_names.reject { |name| name == 'group_saml' }, user_auth_by_provider: distinct_count_user_auth_by_provider(time_period), unique_users_all_imports: unique_users_all_imports(time_period), @@ -636,8 +636,8 @@ module Gitlab clusters: distinct_count(::Clusters::Cluster.where(time_period), :user_id), clusters_applications_prometheus: cluster_applications_user_distinct_count(::Clusters::Applications::Prometheus, time_period), operations_dashboard_default_dashboard: count(::User.active.with_dashboard('operations').where(time_period), - start: user_minimum_id, - finish: user_maximum_id), + start: minimum_id(User), + finish: maximum_id(User)), projects_with_tracing_enabled: distinct_count(::Project.with_tracing_enabled.where(time_period), :creator_id), projects_with_error_tracking_enabled: distinct_count(::Project.with_enabled_error_tracking.where(time_period), :creator_id), projects_with_incidents: distinct_count(::Issue.incident.where(time_period), :project_id), @@ -691,12 +691,12 @@ module Gitlab def usage_activity_by_stage_verify(time_period) { ci_builds: distinct_count(::Ci::Build.where(time_period), :user_id), - ci_external_pipelines: distinct_count(::Ci::Pipeline.external.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id), - ci_internal_pipelines: distinct_count(::Ci::Pipeline.internal.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id), - ci_pipeline_config_auto_devops: distinct_count(::Ci::Pipeline.auto_devops_source.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id), - ci_pipeline_config_repository: distinct_count(::Ci::Pipeline.repository_source.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id), + ci_external_pipelines: distinct_count(::Ci::Pipeline.external.where(time_period), :user_id, start: minimum_id(User), finish: maximum_id(User)), + ci_internal_pipelines: distinct_count(::Ci::Pipeline.internal.where(time_period), :user_id, start: minimum_id(User), finish: maximum_id(User)), + ci_pipeline_config_auto_devops: distinct_count(::Ci::Pipeline.auto_devops_source.where(time_period), :user_id, start: minimum_id(User), finish: maximum_id(User)), + ci_pipeline_config_repository: distinct_count(::Ci::Pipeline.repository_source.where(time_period), :user_id, start: minimum_id(User), finish: maximum_id(User)), ci_pipeline_schedules: distinct_count(::Ci::PipelineSchedule.where(time_period), :owner_id), - ci_pipelines: distinct_count(::Ci::Pipeline.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id), + ci_pipelines: distinct_count(::Ci::Pipeline.where(time_period), :user_id, start: minimum_id(User), finish: maximum_id(User)), ci_triggers: distinct_count(::Ci::Trigger.where(time_period), :owner_id), clusters_applications_runner: cluster_applications_user_distinct_count(::Clusters::Applications::Runner, time_period) } @@ -801,8 +801,8 @@ module Gitlab end def distinct_count_service_desk_enabled_projects(time_period) - project_creator_id_start = user_minimum_id - project_creator_id_finish = user_maximum_id + project_creator_id_start = minimum_id(User) + project_creator_id_finish = maximum_id(User) distinct_count(::Project.service_desk_enabled.where(time_period), :creator_id, start: project_creator_id_start, finish: project_creator_id_finish) # rubocop: disable CodeReuse/ActiveRecord end @@ -834,57 +834,9 @@ module Gitlab def total_alert_issues # Remove prometheus table queries once they are deprecated # To be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/217407. - add count(Issue.with_alert_management_alerts, start: issue_minimum_id, finish: issue_maximum_id), - count(::Issue.with_self_managed_prometheus_alert_events, start: issue_minimum_id, finish: issue_maximum_id), - count(::Issue.with_prometheus_alert_events, start: issue_minimum_id, finish: issue_maximum_id) - end - - def user_minimum_id - strong_memoize(:user_minimum_id) do - ::User.minimum(:id) - end - end - - def user_maximum_id - strong_memoize(:user_maximum_id) do - ::User.maximum(:id) - end - end - - def issue_minimum_id - strong_memoize(:issue_minimum_id) do - ::Issue.minimum(:id) - end - end - - def issue_maximum_id - strong_memoize(:issue_maximum_id) do - ::Issue.maximum(:id) - end - end - - def deployment_minimum_id - strong_memoize(:deployment_minimum_id) do - ::Deployment.minimum(:id) - end - end - - def deployment_maximum_id - strong_memoize(:deployment_maximum_id) do - ::Deployment.maximum(:id) - end - end - - def project_minimum_id - strong_memoize(:project_minimum_id) do - ::Project.minimum(:id) - end - end - - def project_maximum_id - strong_memoize(:project_maximum_id) do - ::Project.maximum(:id) - end + add count(Issue.with_alert_management_alerts, start: minimum_id(Issue), finish: maximum_id(Issue)), + count(::Issue.with_self_managed_prometheus_alert_events, start: minimum_id(Issue), finish: maximum_id(Issue)), + count(::Issue.with_prometheus_alert_events, start: minimum_id(Issue), finish: maximum_id(Issue)) end def self_monitoring_project @@ -918,7 +870,7 @@ module Gitlab end def deployment_count(relation) - count relation, start: deployment_minimum_id, finish: deployment_maximum_id + count relation, start: minimum_id(Deployment), finish: maximum_id(Deployment) end def project_imports(time_period) diff --git a/lib/gitlab/usage_data_queries.rb b/lib/gitlab/usage_data_queries.rb index dc37e2fef1d..c0dfae88fc7 100644 --- a/lib/gitlab/usage_data_queries.rb +++ b/lib/gitlab/usage_data_queries.rb @@ -36,6 +36,12 @@ module Gitlab 'SELECT ' + args.map {|arg| "(#{arg})" }.join(' + ') end + def maximum_id(model) + end + + def minimum_id(model) + end + private def raw_sql(relation, column, distinct = nil) diff --git a/lib/gitlab/utils/usage_data.rb b/lib/gitlab/utils/usage_data.rb index 854fc5c917d..efa2f7a943f 100644 --- a/lib/gitlab/utils/usage_data.rb +++ b/lib/gitlab/utils/usage_data.rb @@ -36,6 +36,7 @@ module Gitlab module Utils module UsageData + include Gitlab::Utils::StrongMemoize extend self FALLBACK = -1 @@ -209,6 +210,20 @@ module Gitlab Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name.to_s, values: values) end + def maximum_id(model) + key = :"#{model.name.downcase}_maximum_id" + strong_memoize(key) do + model.maximum(:id) + end + end + + def minimum_id(model) + key = :"#{model.name.downcase}_minimum_id" + strong_memoize(key) do + model.minimum(:id) + end + end + private def prometheus_client(verify:) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 84de7d3bc1e..3054d7ede7c 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -3740,6 +3740,9 @@ msgstr "" msgid "Analyze your source code for known vulnerabilities." msgstr "" +msgid "Analyzing file…" +msgstr "" + msgid "Ancestors" msgstr "" @@ -15738,6 +15741,9 @@ msgstr "" msgid "How do I mirror repositories?" msgstr "" +msgid "How do I set up this service?" +msgstr "" + msgid "How does cleanup work?" msgstr "" @@ -22893,13 +22899,13 @@ msgstr "" msgid "Pipelines|By revoking a trigger you will break any processes making use of it. Are you sure?" msgstr "" -msgid "Pipelines|CI Lint" +msgid "Pipelines|CI lint" msgstr "" msgid "Pipelines|Child pipeline" msgstr "" -msgid "Pipelines|Clear Runner Caches" +msgid "Pipelines|Clear runner caches" msgstr "" msgid "Pipelines|Continuous deployment template to test and deploy your %{name} project." @@ -22947,6 +22953,9 @@ msgstr "" msgid "Pipelines|Loading Pipelines" msgstr "" +msgid "Pipelines|Loading pipelines" +msgstr "" + msgid "Pipelines|Merged YAML is view only" msgstr "" @@ -22968,9 +22977,6 @@ msgstr "" msgid "Pipelines|Revoke" msgstr "" -msgid "Pipelines|Run Pipeline" -msgstr "" - msgid "Pipelines|Something went wrong while cleaning runners cache." msgstr "" @@ -23124,15 +23130,15 @@ msgstr "" msgid "Pipeline|Raw text search is not currently supported. Please use the available search tokens." msgstr "" -msgid "Pipeline|Run Pipeline" -msgstr "" - msgid "Pipeline|Run for" msgstr "" msgid "Pipeline|Run for branch name or tag" msgstr "" +msgid "Pipeline|Run pipeline" +msgstr "" + msgid "Pipeline|Running" msgstr "" @@ -28738,25 +28744,10 @@ msgstr "" msgid "Slack application" msgstr "" -msgid "Slack channels (e.g. general, development)" -msgstr "" - msgid "Slack integration allows you to interact with GitLab via slash commands in a chat window." msgstr "" -msgid "SlackIntegration|%{strong_open}Note:%{strong_close} Usernames and private channels are not supported." -msgstr "" - -msgid "SlackIntegration|%{webhooks_link_start}Add an incoming webhook%{webhooks_link_end} in your Slack team. The default channel can be overridden for each event." -msgstr "" - -msgid "SlackIntegration|Paste the %{strong_open}Webhook URL%{strong_close} into the field below." -msgstr "" - -msgid "SlackIntegration|Select events below to enable notifications. The %{strong_open}Slack channel names%{strong_close} and %{strong_open}Slack username%{strong_close} fields are optional." -msgstr "" - -msgid "SlackIntegration|This service sends notifications about project events to Slack channels. To set up this service:" +msgid "SlackIntegration|Sends notifications about project events to Slack channels." msgstr "" msgid "SlackService|2. Paste the %{strong_open}Token%{strong_close} into the field below" @@ -36585,6 +36576,9 @@ msgid_plural "from %d jobs" msgstr[0] "" msgstr[1] "" +msgid "general, development" +msgstr "" + msgid "group" msgstr "" diff --git a/qa/qa/page/project/pipeline/index.rb b/qa/qa/page/project/pipeline/index.rb index 0f5a7e8c801..98c12a4086e 100644 --- a/qa/qa/page/project/pipeline/index.rb +++ b/qa/qa/page/project/pipeline/index.rb @@ -31,7 +31,7 @@ module QA end def wait_for_latest_pipeline_status - wait_until(max_duration: 30, reload: true, sleep_interval: 5) { has_pipeline? } + wait_until(max_duration: 90, reload: true, sleep_interval: 5) { has_pipeline? } wait_until(reload: false, max_duration: 360) do within_element_by_index(:pipeline_commit_status, 0) { yield } diff --git a/spec/controllers/chaos_controller_spec.rb b/spec/controllers/chaos_controller_spec.rb index cb4f12ff829..26ae4a6b693 100644 --- a/spec/controllers/chaos_controller_spec.rb +++ b/spec/controllers/chaos_controller_spec.rb @@ -109,7 +109,7 @@ RSpec.describe ChaosController do describe '#kill' do it 'calls synchronously' do - expect(Gitlab::Chaos).to receive(:kill).with(no_args) + expect(Gitlab::Chaos).to receive(:kill).with('KILL') get :kill @@ -117,7 +117,7 @@ RSpec.describe ChaosController do end it 'calls asynchronously' do - expect(Chaos::KillWorker).to receive(:perform_async).with(no_args) + expect(Chaos::KillWorker).to receive(:perform_async).with('KILL') get :kill, params: { async: 1 } @@ -125,6 +125,24 @@ RSpec.describe ChaosController do end end + describe '#quit' do + it 'calls synchronously' do + expect(Gitlab::Chaos).to receive(:kill).with('QUIT') + + get :quit + + expect(response).to have_gitlab_http_status(:ok) + end + + it 'calls asynchronously' do + expect(Chaos::KillWorker).to receive(:perform_async).with('QUIT') + + get :quit, params: { async: 1 } + + expect(response).to have_gitlab_http_status(:ok) + end + end + describe '#gc' do let(:gc_stat) { GC.stat.stringify_keys } diff --git a/spec/features/merge_request/user_sees_pipelines_spec.rb b/spec/features/merge_request/user_sees_pipelines_spec.rb index 77d2cb77ae3..a5047c8d550 100644 --- a/spec/features/merge_request/user_sees_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_pipelines_spec.rb @@ -41,7 +41,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do context 'with a detached merge request pipeline' do let(:merge_request) { create(:merge_request, :with_detached_merge_request_pipeline) } - it 'displays the Run Pipeline button' do + it 'displays the "Run pipeline" button' do visit project_merge_request_path(project, merge_request) page.within('.merge-request-tabs') do @@ -50,14 +50,14 @@ RSpec.describe 'Merge request > User sees pipelines', :js do wait_for_requests - expect(page.find('[data-testid="run_pipeline_button"]')).to have_text('Run Pipeline') + expect(page.find('[data-testid="run_pipeline_button"]')).to have_text('Run pipeline') end end context 'with a merged results pipeline' do let(:merge_request) { create(:merge_request, :with_merge_request_pipeline) } - it 'displays the Run Pipeline button' do + it 'displays the "Run pipeline" button' do visit project_merge_request_path(project, merge_request) page.within('.merge-request-tabs') do @@ -66,7 +66,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do wait_for_requests - expect(page.find('[data-testid="run_pipeline_button"]')).to have_text('Run Pipeline') + expect(page.find('[data-testid="run_pipeline_button"]')).to have_text('Run pipeline') end end end @@ -131,7 +131,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do visit project_merge_request_path(parent_project, merge_request) create_merge_request_pipeline - act_on_security_warning(action: 'Run Pipeline') + act_on_security_warning(action: 'Run pipeline') check_pipeline(expected_project: parent_project) check_head_pipeline(expected_project: parent_project) @@ -175,7 +175,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do def create_merge_request_pipeline page.within('.merge-request-tabs') { click_link('Pipelines') } - click_button('Run Pipeline') + click_button('Run pipeline') end def check_pipeline(expected_project:) diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index b441021161a..e375bc10dbf 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -93,12 +93,12 @@ RSpec.describe 'Pipelines', :js do wait_for_requests end - it 'renders run pipeline link' do - expect(page).to have_link('Run Pipeline') + it 'renders "CI lint" link' do + expect(page).to have_link('CI lint') end - it 'renders ci lint link' do - expect(page).to have_link('CI Lint') + it 'renders "Run pipeline" link' do + expect(page).to have_link('Run pipeline') end end @@ -676,7 +676,7 @@ RSpec.describe 'Pipelines', :js do end it 'creates a new pipeline' do - expect { click_on 'Run Pipeline' } + expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) expect(Ci::Pipeline.last).to be_web @@ -689,7 +689,7 @@ RSpec.describe 'Pipelines', :js do fill_in "Input variable value", with: "value" end - expect { click_on 'Run Pipeline' } + expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) expect(Ci::Pipeline.last.variables.map { |var| var.slice(:key, :secret_value) }) @@ -700,7 +700,7 @@ RSpec.describe 'Pipelines', :js do context 'without gitlab-ci.yml' do before do - click_on 'Run Pipeline' + click_on 'Run pipeline' end it { expect(page).to have_content('Missing CI config file') } @@ -713,13 +713,49 @@ RSpec.describe 'Pipelines', :js do click_link 'master' end - expect { click_on 'Run Pipeline' } + expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) end end end end + describe 'Reset runner caches' do + let(:project) { create(:project, :repository) } + + before do + create(:ci_empty_pipeline, status: 'success', project: project, sha: project.commit.id, ref: 'master') + project.add_maintainer(user) + visit project_pipelines_path(project) + end + + it 'has a clear caches button' do + expect(page).to have_button 'Clear runner caches' + end + + describe 'user clicks the button' do + context 'when project already has jobs_cache_index' do + before do + project.update!(jobs_cache_index: 1) + end + + it 'increments jobs_cache_index' do + click_button 'Clear runner caches' + wait_for_requests + expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.' + end + end + + context 'when project does not have jobs_cache_index' do + it 'sets jobs_cache_index to 1' do + click_button 'Clear runner caches' + wait_for_requests + expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.' + end + end + end + end + describe 'Run Pipelines' do let(:project) { create(:project, :repository) } @@ -751,42 +787,6 @@ RSpec.describe 'Pipelines', :js do end end - describe 'Reset runner caches' do - let(:project) { create(:project, :repository) } - - before do - create(:ci_empty_pipeline, status: 'success', project: project, sha: project.commit.id, ref: 'master') - project.add_maintainer(user) - visit project_pipelines_path(project) - end - - it 'has a clear caches button' do - expect(page).to have_button 'Clear Runner Caches' - end - - describe 'user clicks the button' do - context 'when project already has jobs_cache_index' do - before do - project.update!(jobs_cache_index: 1) - end - - it 'increments jobs_cache_index' do - click_button 'Clear Runner Caches' - wait_for_requests - expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.' - end - end - - context 'when project does not have jobs_cache_index' do - it 'sets jobs_cache_index to 1' do - click_button 'Clear Runner Caches' - wait_for_requests - expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.' - end - end - end - end - describe 'Empty State' do let(:project) { create(:project, :repository) } diff --git a/spec/frontend/integrations/edit/components/trigger_fields_spec.js b/spec/frontend/integrations/edit/components/trigger_fields_spec.js index 3e5326812b1..b9d16464e72 100644 --- a/spec/frontend/integrations/edit/components/trigger_fields_spec.js +++ b/spec/frontend/integrations/edit/components/trigger_fields_spec.js @@ -138,11 +138,11 @@ describe('TriggerFields', () => { const expectedResults = [ { name: 'service[push_channel]', - placeholder: 'Slack channels (e.g. general, development)', + placeholder: 'general, development', }, { name: 'service[merge_request_channel]', - placeholder: 'Slack channels (e.g. general, development)', + placeholder: 'general, development', }, ]; diff --git a/spec/frontend/pipelines/nav_controls_spec.js b/spec/frontend/pipelines/nav_controls_spec.js index 40cfd785a20..2c4740df174 100644 --- a/spec/frontend/pipelines/nav_controls_spec.js +++ b/spec/frontend/pipelines/nav_controls_spec.js @@ -29,7 +29,7 @@ describe('Pipelines Nav Controls', () => { createComponent(mockData); const runPipeline = findRunPipeline(); - expect(runPipeline.text()).toContain('Run Pipeline'); + expect(runPipeline.text()).toContain('Run pipeline'); expect(runPipeline.attributes('href')).toBe(mockData.newPipelinePath); }); @@ -55,7 +55,7 @@ describe('Pipelines Nav Controls', () => { createComponent(mockData); - expect(wrapper.find('.js-ci-lint').text().trim()).toContain('CI Lint'); + expect(wrapper.find('.js-ci-lint').text().trim()).toContain('CI lint'); expect(wrapper.find('.js-ci-lint').attributes('href')).toBe(mockData.ciLintPath); }); @@ -70,7 +70,7 @@ describe('Pipelines Nav Controls', () => { }); it('should render button for resetting runner caches', () => { - expect(wrapper.find('.js-clear-cache').text().trim()).toContain('Clear Runner Caches'); + expect(wrapper.find('.js-clear-cache').text().trim()).toContain('Clear runner caches'); }); it('should emit postAction event when reset runner cache button is clicked', async () => { diff --git a/spec/frontend/pipelines/pipelines_spec.js b/spec/frontend/pipelines/pipelines_spec.js index dd9f9e529d2..84a25f42201 100644 --- a/spec/frontend/pipelines/pipelines_spec.js +++ b/spec/frontend/pipelines/pipelines_spec.js @@ -191,16 +191,16 @@ describe('Pipelines', () => { expect(findNavigationControls().exists()).toBe(true); }); - it('renders Run Pipeline link', () => { + it('renders Run pipeline link', () => { expect(findRunPipelineButton().attributes('href')).toBe(paths.newPipelinePath); }); - it('renders CI Lint link', () => { + it('renders CI lint link', () => { expect(findCiLintButton().attributes('href')).toBe(paths.ciLintPath); }); - it('renders Clear Runner Cache button', () => { - expect(findCleanCacheButton().text()).toBe('Clear Runner Caches'); + it('renders Clear runner cache button', () => { + expect(findCleanCacheButton().text()).toBe('Clear runner caches'); }); it('renders pipelines in a table', () => { @@ -499,16 +499,16 @@ describe('Pipelines', () => { expect(findTab('all').text()).toMatchInterpolatedText('All 0'); }); - it('renders Run Pipeline link', () => { + it('renders Run pipeline link', () => { expect(findRunPipelineButton().attributes('href')).toBe(paths.newPipelinePath); }); - it('renders CI Lint link', () => { + it('renders CI lint link', () => { expect(findCiLintButton().attributes('href')).toBe(paths.ciLintPath); }); - it('renders Clear Runner Cache button', () => { - expect(findCleanCacheButton().text()).toBe('Clear Runner Caches'); + it('renders Clear runner cache button', () => { + expect(findCleanCacheButton().text()).toBe('Clear runner caches'); }); it('renders empty state', () => { @@ -714,7 +714,7 @@ describe('Pipelines', () => { expect(findRunPipelineButton().attributes('href')).toBe(paths.newPipelinePath); expect(findCiLintButton().attributes('href')).toBe(paths.ciLintPath); - expect(findCleanCacheButton().text()).toBe('Clear Runner Caches'); + expect(findCleanCacheButton().text()).toBe('Clear runner caches'); }); it('shows error state', () => { diff --git a/spec/lib/gitlab/usage_data_queries_spec.rb b/spec/lib/gitlab/usage_data_queries_spec.rb index 113df26cdca..718ab3b2d95 100644 --- a/spec/lib/gitlab/usage_data_queries_spec.rb +++ b/spec/lib/gitlab/usage_data_queries_spec.rb @@ -58,4 +58,24 @@ RSpec.describe Gitlab::UsageDataQueries do .to eq('SELECT (SELECT COUNT("users"."id") FROM "users") + (SELECT COUNT("issues"."id") FROM "issues")') end end + + describe 'min/max methods' do + it 'returns nil' do + # user min/max + expect(described_class.minimum_id(User)).to eq(nil) + expect(described_class.maximum_id(User)).to eq(nil) + + # issue min/max + expect(described_class.minimum_id(Issue)).to eq(nil) + expect(described_class.maximum_id(Issue)).to eq(nil) + + # deployment min/max + expect(described_class.minimum_id(Deployment)).to eq(nil) + expect(described_class.maximum_id(Deployment)).to eq(nil) + + # project min/max + expect(described_class.minimum_id(Project)).to eq(nil) + expect(described_class.maximum_id(Project)).to eq(nil) + end + end end diff --git a/spec/lib/gitlab/utils/usage_data_spec.rb b/spec/lib/gitlab/utils/usage_data_spec.rb index 8041a0cba63..11b2a12f228 100644 --- a/spec/lib/gitlab/utils/usage_data_spec.rb +++ b/spec/lib/gitlab/utils/usage_data_spec.rb @@ -479,4 +479,22 @@ RSpec.describe Gitlab::Utils::UsageData do expect { described_class.track_usage_event(unknown_event, value) }.to raise_error(Gitlab::UsageDataCounters::HLLRedisCounter::UnknownEvent) end end + + describe 'min/max' do + let(:model) { double(:relation) } + + it 'returns min from the model' do + allow(model).to receive(:minimum).and_return(2) + allow(model).to receive(:name).and_return('sample_min_model') + + expect(described_class.minimum_id(model)).to eq(2) + end + + it 'returns max from the model' do + allow(model).to receive(:maximum).and_return(100) + allow(model).to receive(:name).and_return('sample_max_model') + + expect(described_class.maximum_id(model)).to eq(100) + end + end end