diff options
42 files changed, 277 insertions, 38 deletions
diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index d49fa4a49a0..63ac5a408bd 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -3,7 +3,7 @@ *.rake @ashmckenzie @ayufan @dbalexandre @DouweM @dzaporozhets @godfat @grzesiek @mkozono @mayra-cabrera @nick.thomas @rspeicher @rymai @reprazent @smcgivern @tkuah # Technical writing team are the default reviewers for everything in `doc/` -/doc/ @axil @marcia +/doc/ @axil @marcia @eread # Frontend maintainers should see everything in `app/assets/` app/assets/ @ClemMakesApps @fatihacet @filipa @iamphill @mikegreiling @timzallmann @kushalpandya diff --git a/app/assets/javascripts/pipelines/components/graph/job_name_component.vue b/app/assets/javascripts/pipelines/components/graph/job_name_component.vue index 02451839330..7125790ac3d 100644 --- a/app/assets/javascripts/pipelines/components/graph/job_name_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/job_name_component.vue @@ -25,7 +25,7 @@ export default { }; </script> <template> - <span class="ci-job-name-component"> + <span class="ci-job-name-component mw-100"> <ci-icon :status="status" /> <span class="ci-status-text text-truncate mw-70p gl-pl-1 d-inline-block align-bottom"> {{ name }} diff --git a/app/assets/javascripts/repository/components/table/index.vue b/app/assets/javascripts/repository/components/table/index.vue index d2198bcccfe..0357a0e44c3 100644 --- a/app/assets/javascripts/repository/components/table/index.vue +++ b/app/assets/javascripts/repository/components/table/index.vue @@ -135,6 +135,7 @@ export default { :path="entry.flatPath" :type="entry.type" :url="entry.webUrl" + :lfs-oid="entry.lfsOid" /> </template> </tbody> diff --git a/app/assets/javascripts/repository/components/table/row.vue b/app/assets/javascripts/repository/components/table/row.vue index 764882a7936..e24a5e2c447 100644 --- a/app/assets/javascripts/repository/components/table/row.vue +++ b/app/assets/javascripts/repository/components/table/row.vue @@ -1,8 +1,12 @@ <script> +import { GlBadge } from '@gitlab/ui'; import { getIconName } from '../../utils/icon'; import getRefMixin from '../../mixins/get_ref'; export default { + components: { + GlBadge, + }, mixins: [getRefMixin], props: { id: { @@ -26,6 +30,11 @@ export default { required: false, default: null, }, + lfsOid: { + type: String, + required: false, + default: null, + }, }, computed: { routerLinkTo() { @@ -67,6 +76,9 @@ export default { <component :is="linkComponent" :to="routerLinkTo" :href="url" class="str-truncated"> {{ fullPath }} </component> + <gl-badge v-if="lfsOid" variant="default" class="label-lfs ml-1"> + LFS + </gl-badge> <template v-if="isSubmodule"> @ <a href="#" class="commit-sha">{{ shortSha }}</a> </template> diff --git a/app/assets/javascripts/repository/queries/getFiles.graphql b/app/assets/javascripts/repository/queries/getFiles.graphql index 7d92bc46455..ef924fde556 100644 --- a/app/assets/javascripts/repository/queries/getFiles.graphql +++ b/app/assets/javascripts/repository/queries/getFiles.graphql @@ -45,6 +45,7 @@ query getFiles( node { ...TreeEntry webUrl + lfsOid } } pageInfo { diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss index 69dd583bc5b..5cacd42bf0d 100644 --- a/app/assets/stylesheets/pages/notes.scss +++ b/app/assets/stylesheets/pages/notes.scss @@ -431,7 +431,7 @@ $note-form-margin-left: 72px; .notes > .note-discussion li.note.system-note { border-bottom: 0; - padding: 0 $gl-padding; + padding: 0; } } diff --git a/app/controllers/projects/environments/prometheus_api_controller.rb b/app/controllers/projects/environments/prometheus_api_controller.rb index f8ef23cd83e..9c6c6513a78 100644 --- a/app/controllers/projects/environments/prometheus_api_controller.rb +++ b/app/controllers/projects/environments/prometheus_api_controller.rb @@ -13,7 +13,7 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon ).execute if result.nil? - return render status: :accepted, json: { + return render status: :no_content, json: { status: _('processing'), message: _('Not ready yet. Try again later.') } diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb index f2b7d5df2b2..ba191b59132 100644 --- a/app/graphql/types/tree/blob_type.rb +++ b/app/graphql/types/tree/blob_type.rb @@ -9,6 +9,9 @@ module Types graphql_name 'Blob' field :web_url, GraphQL::STRING_TYPE, null: true + field :lfs_oid, GraphQL::STRING_TYPE, null: true, resolve: -> (blob, args, ctx) do + Gitlab::Graphql::Loaders::BatchCommitLoader.new(blob.repository, blob.id).find + end end end end diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index e1d6b2a802b..ccc877fb924 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -8,7 +8,6 @@ module Clusters include ReactiveCaching self.table_name = 'clusters' - self.reactive_cache_key = -> (cluster) { [cluster.class.model_name.singular, cluster.id] } PROJECT_ONLY_APPLICATIONS = { Applications::Jupyter.application_name => Applications::Jupyter, diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index 9b951578aee..8e06156c73d 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -11,7 +11,6 @@ module Clusters RESERVED_NAMESPACES = %w(gitlab-managed-apps).freeze self.table_name = 'cluster_platforms_kubernetes' - self.reactive_cache_key = ->(kubernetes) { [kubernetes.class.model_name.singular, kubernetes.id] } belongs_to :cluster, inverse_of: :platform_kubernetes, class_name: 'Clusters::Cluster' diff --git a/app/models/concerns/prometheus_adapter.rb b/app/models/concerns/prometheus_adapter.rb index 258c819f243..c2542dbe743 100644 --- a/app/models/concerns/prometheus_adapter.rb +++ b/app/models/concerns/prometheus_adapter.rb @@ -6,7 +6,6 @@ module PrometheusAdapter included do include ReactiveCaching - self.reactive_cache_key = ->(adapter) { [adapter.class.model_name.singular, adapter.id] } self.reactive_cache_lease_timeout = 30.seconds self.reactive_cache_refresh_interval = 30.seconds self.reactive_cache_lifetime = 1.minute diff --git a/app/models/concerns/reactive_caching.rb b/app/models/concerns/reactive_caching.rb index 1e09cd89550..6c3962b4c4f 100644 --- a/app/models/concerns/reactive_caching.rb +++ b/app/models/concerns/reactive_caching.rb @@ -10,8 +10,6 @@ # class Foo < ApplicationRecord # include ReactiveCaching # -# self.reactive_cache_key = ->(thing) { ["foo", thing.id] } -# # after_save :clear_reactive_cache! # # def calculate_reactive_cache @@ -89,6 +87,8 @@ module ReactiveCaching class_attribute :reactive_cache_worker_finder # defaults + self.reactive_cache_key = -> (record) { [model_name.singular, record.id] } + self.reactive_cache_lease_timeout = 2.minutes self.reactive_cache_refresh_interval = 1.minute diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb index c5675ef3ea3..91c9abe750b 100644 --- a/app/presenters/blob_presenter.rb +++ b/app/presenters/blob_presenter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class BlobPresenter < Gitlab::View::Presenter::Simple +class BlobPresenter < Gitlab::View::Presenter::Delegated presents :blob def highlight(plain: nil) diff --git a/changelogs/unreleased/add-lfs-blob-ids-to-tree-type.yml b/changelogs/unreleased/add-lfs-blob-ids-to-tree-type.yml new file mode 100644 index 00000000000..14a5ef1cef3 --- /dev/null +++ b/changelogs/unreleased/add-lfs-blob-ids-to-tree-type.yml @@ -0,0 +1,5 @@ +--- +title: Add LFS oid to GraphQL blob type +merge_request: 28666 +author: +type: added diff --git a/changelogs/unreleased/ignore-artifact-attirbutes-in-project-import-export.yml b/changelogs/unreleased/ignore-artifact-attirbutes-in-project-import-export.yml new file mode 100644 index 00000000000..536aae03f59 --- /dev/null +++ b/changelogs/unreleased/ignore-artifact-attirbutes-in-project-import-export.yml @@ -0,0 +1,5 @@ +--- +title: Ignore legacy artifact columns in Project Import/Export +merge_request: 29427 +author: +type: fixed diff --git a/config/routes/project.rb b/config/routes/project.rb index d44ff62bc2a..a1e769f6ca3 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -330,7 +330,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do get :metrics_dashboard get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil } - get '/prometheus/api/v1/*proxy_path', to: 'environments/prometheus_api#proxy' + get '/prometheus/api/v1/*proxy_path', to: 'environments/prometheus_api#proxy', as: :prometheus_api end collection do diff --git a/db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb b/db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb new file mode 100644 index 00000000000..c200208e4c3 --- /dev/null +++ b/db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class AddTargetProjectIdToMergeTrains < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + # rubocop: disable Rails/NotNullColumn + add_reference :merge_trains, :target_project, null: false, index: true, foreign_key: { on_delete: :cascade, to_table: :projects }, type: :integer + add_column :merge_trains, :target_branch, :text, null: false + # rubocop: enable Rails/NotNullColumn + end +end diff --git a/db/schema.rb b/db/schema.rb index 22d0cddb7a0..1755730bb72 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190530154715) do +ActiveRecord::Schema.define(version: 20190611161641) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1387,8 +1387,11 @@ ActiveRecord::Schema.define(version: 20190530154715) do t.integer "pipeline_id" t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false + t.integer "target_project_id", null: false + t.text "target_branch", null: false t.index ["merge_request_id"], name: "index_merge_trains_on_merge_request_id", unique: true, using: :btree t.index ["pipeline_id"], name: "index_merge_trains_on_pipeline_id", using: :btree + t.index ["target_project_id"], name: "index_merge_trains_on_target_project_id", using: :btree t.index ["user_id"], name: "index_merge_trains_on_user_id", using: :btree end @@ -2570,6 +2573,7 @@ ActiveRecord::Schema.define(version: 20190530154715) do add_foreign_key "merge_requests_closing_issues", "merge_requests", on_delete: :cascade add_foreign_key "merge_trains", "ci_pipelines", column: "pipeline_id", on_delete: :nullify add_foreign_key "merge_trains", "merge_requests", on_delete: :cascade + add_foreign_key "merge_trains", "projects", column: "target_project_id", on_delete: :cascade add_foreign_key "merge_trains", "users", on_delete: :cascade add_foreign_key "milestones", "namespaces", column: "group_id", name: "fk_95650a40d4", on_delete: :cascade add_foreign_key "milestones", "projects", name: "fk_9bd0a0c791", on_delete: :cascade diff --git a/doc/install/installation.md b/doc/install/installation.md index 10436a15a9e..eb484dde545 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -250,11 +250,11 @@ page](https://golang.org/dl). # Remove former Go installation folder sudo rm -rf /usr/local/go -curl --remote-name --progress https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz -echo 'fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035 go1.10.3.linux-amd64.tar.gz' | shasum -a256 -c - && \ - sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz +curl --remote-name --progress https://dl.google.com/go/go1.11.10.linux-amd64.tar.gz +echo 'aefaa228b68641e266d1f23f1d95dba33f17552ba132878b65bb798ffa37e6d0 go1.11.10.linux-amd64.tar.gz' | shasum -a256 -c - && \ + sudo tar -C /usr/local -xzf go1.11.10.linux-amd64.tar.gz sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/ -rm go1.10.3.linux-amd64.tar.gz +rm go1.11.10.linux-amd64.tar.gz ``` ## 4. Node diff --git a/doc/subscriptions/index.md b/doc/subscriptions/index.md index dfd80f8882e..9b0aa5aa272 100644 --- a/doc/subscriptions/index.md +++ b/doc/subscriptions/index.md @@ -87,6 +87,14 @@ plan - in the included table: | Subscription start date | The date your subscription started. If this is for a Free plan, this is the date you transitioned off your group's paid plan. | | Subscription end date | The date your current subscription will end. This does not apply to Free plans. | +### Subscription changes and your data + +When your subscription or trial expires, GitLab does not delete your data, however, depending on the tier and feature, it may become inaccessible. Please note that some features may not behave as expected if a graceful fallback is not currently implemented, such as [environment specific variables not being passed](https://gitlab.com/gitlab-org/gitlab-ce/issues/52825). + +If you renew or upgrade, your data will again be accessible. + +For self-managed customers, there is a two-week grace period when your features will continue to work as-is, after which the entire instance will become read only. However, if you remove the license, you will immediately revert to Core features. + ## Need help? [GitLab's Documentation](https://docs.gitlab.com/) offers a wide range of topics covering the use and administration of GitLab. diff --git a/doc/update/upgrading_from_source.md b/doc/update/upgrading_from_source.md index f82d666c7be..bc8e5fed774 100644 --- a/doc/update/upgrading_from_source.md +++ b/doc/update/upgrading_from_source.md @@ -107,11 +107,11 @@ Download and install Go: # Remove former Go installation folder sudo rm -rf /usr/local/go -curl --remote-name --progress https://dl.google.com/go/go1.10.5.linux-amd64.tar.gz -echo 'a035d9beda8341b645d3f45a1b620cf2d8fb0c5eb409be36b389c0fd384ecc3a go1.10.5.linux-amd64.tar.gz' | shasum -a256 -c - && \ - sudo tar -C /usr/local -xzf go1.10.5.linux-amd64.tar.gz +curl --remote-name --progress https://dl.google.com/go/go1.11.10.linux-amd64.tar.gz +echo 'aefaa228b68641e266d1f23f1d95dba33f17552ba132878b65bb798ffa37e6d0 go1.11.10.linux-amd64.tar.gz' | shasum -a256 -c - && \ + sudo tar -C /usr/local -xzf go1.11.10.linux-amd64.tar.gz sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/ -rm go1.10.5.linux-amd64.tar.gz +rm go1.11.10.linux-amd64.tar.gz ``` ### 6. Update git diff --git a/doc/user/project/issues/moving_issues.md b/doc/user/project/issues/moving_issues.md index 211a651b89e..8aac2c01444 100644 --- a/doc/user/project/issues/moving_issues.md +++ b/doc/user/project/issues/moving_issues.md @@ -8,3 +8,28 @@ There will also be a system note added to both issues indicating where it came f You can move an issue with the "Move issue" button at the bottom of the right-sidebar when viewing the issue. ![move issue - button](img/sidebar_move_issue.png) + +## Troubleshooting + +### Moving Issues in Bulk + +If you have advanced technical skills you can also bulk move all the issues from one project to another in the rails console. The below script will move all the issues from one project to another that are not in status **closed**. + +To access rails console run `sudo gitlab-rails console` on the GitLab server and run the below script. Please be sure to change **project**, **admin_user** and **target_project** to your values. We do also recommend [creating a backup](https://docs.gitlab.com/ee/raketasks/backup_restore.html#creating-a-backup-of-the-gitlab-system) before attempting any changes in the console. + +```ruby +project = Project.find_by_full_path('full path of the project where issues are moved from') +issues = project.issues +admin_user = User.find_by_username('username of admin user') # make sure user has permissions to move the issues +target_project = Project.find_by_full_path('full path of target project where issues moved to') + +issues.each do |issue| + if issue.state != "closed" && issue.moved_to.nil? + Issues::MoveService.new(project, admin_user).execute(issue, target_project) + else + puts "issue with id: #{issue.id} and title: #{issue.title} was not moved" + end +end; nil + +``` + diff --git a/lib/gitlab/graphql/loaders/batch_commit_loader.rb b/lib/gitlab/graphql/loaders/batch_commit_loader.rb new file mode 100644 index 00000000000..f410c3195f8 --- /dev/null +++ b/lib/gitlab/graphql/loaders/batch_commit_loader.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Gitlab + module Graphql + module Loaders + class BatchCommitLoader + def initialize(repository, blob_id) + @repository, @blob_id = repository, blob_id + end + + def find + BatchLoader.for(blob_id).batch(key: repository) do |blob_ids, loader, batch_args| + Gitlab::Git::Blob.batch_lfs_pointers(batch_args[:key], blob_ids).each do |loaded_blob| + loader.call(loaded_blob.id, loaded_blob.lfs_oid) + end + end + end + + private + + attr_reader :repository, :blob_id + end + end + end +end diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 7bbcb53f016..71c44af9254 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -156,6 +156,9 @@ excluded_attributes: - :when - :artifacts_file - :artifacts_metadata + - :artifacts_file_store + - :artifacts_metadata_store + - :artifacts_size - :commands push_event_payload: - :event_id diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb index e1e70a008d9..efd3f550a22 100644 --- a/lib/gitlab/import_export/relation_factory.rb +++ b/lib/gitlab/import_export/relation_factory.rb @@ -153,6 +153,9 @@ module Gitlab @relation_hash.delete('trace') # old export files have trace @relation_hash.delete('token') @relation_hash.delete('commands') + @relation_hash.delete('artifacts_file_store') + @relation_hash.delete('artifacts_metadata_store') + @relation_hash.delete('artifacts_size') imported_object elsif @relation_name == :merge_requests diff --git a/lib/gitlab/metrics/dashboard/base_service.rb b/lib/gitlab/metrics/dashboard/base_service.rb index 94aabd0466c..4664aee71f6 100644 --- a/lib/gitlab/metrics/dashboard/base_service.rb +++ b/lib/gitlab/metrics/dashboard/base_service.rb @@ -6,13 +6,13 @@ module Gitlab module Metrics module Dashboard class BaseService < ::BaseService - DASHBOARD_LAYOUT_ERROR = Gitlab::Metrics::Dashboard::Stages::BaseStage::DashboardLayoutError + PROCESSING_ERROR = Gitlab::Metrics::Dashboard::Stages::BaseStage::DashboardProcessingError def get_dashboard return error("#{dashboard_path} could not be found.", :not_found) unless path_available? success(dashboard: process_dashboard) - rescue DASHBOARD_LAYOUT_ERROR => e + rescue PROCESSING_ERROR => e error(e.message, :unprocessable_entity) end diff --git a/lib/gitlab/metrics/dashboard/processor.rb b/lib/gitlab/metrics/dashboard/processor.rb index dd986020693..a33a010ad97 100644 --- a/lib/gitlab/metrics/dashboard/processor.rb +++ b/lib/gitlab/metrics/dashboard/processor.rb @@ -11,11 +11,13 @@ module Gitlab SYSTEM_SEQUENCE = [ Stages::CommonMetricsInserter, Stages::ProjectMetricsInserter, + Stages::EndpointInserter, Stages::Sorter ].freeze PROJECT_SEQUENCE = [ Stages::CommonMetricsInserter, + Stages::EndpointInserter, Stages::Sorter ].freeze diff --git a/lib/gitlab/metrics/dashboard/stages/base_stage.rb b/lib/gitlab/metrics/dashboard/stages/base_stage.rb index a6d1f974556..0db7b176e8d 100644 --- a/lib/gitlab/metrics/dashboard/stages/base_stage.rb +++ b/lib/gitlab/metrics/dashboard/stages/base_stage.rb @@ -5,7 +5,8 @@ module Gitlab module Dashboard module Stages class BaseStage - DashboardLayoutError = Class.new(StandardError) + DashboardProcessingError = Class.new(StandardError) + LayoutError = Class.new(DashboardProcessingError) DEFAULT_PANEL_TYPE = 'area-chart' @@ -25,15 +26,15 @@ module Gitlab protected def missing_panel_groups! - raise DashboardLayoutError.new('Top-level key :panel_groups must be an array') + raise LayoutError.new('Top-level key :panel_groups must be an array') end def missing_panels! - raise DashboardLayoutError.new('Each "panel_group" must define an array :panels') + raise LayoutError.new('Each "panel_group" must define an array :panels') end def missing_metrics! - raise DashboardLayoutError.new('Each "panel" must define an array :metrics') + raise LayoutError.new('Each "panel" must define an array :metrics') end def for_metrics diff --git a/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb b/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb new file mode 100644 index 00000000000..2a959854be0 --- /dev/null +++ b/lib/gitlab/metrics/dashboard/stages/endpoint_inserter.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Gitlab + module Metrics + module Dashboard + module Stages + class EndpointInserter < BaseStage + MissingQueryError = Class.new(DashboardProcessingError) + + def transform! + for_metrics do |metric| + metric[:prometheus_endpoint_path] = endpoint_for_metric(metric) + end + end + + private + + def endpoint_for_metric(metric) + Gitlab::Routing.url_helpers.prometheus_api_project_environment_path( + project, + environment, + proxy_path: query_type(metric), + query: query_for_metric(metric) + ) + end + + def query_type(metric) + metric[:query] ? :query : :query_range + end + + def query_for_metric(metric) + query = metric[query_type(metric)] + + raise MissingQueryError.new('Each "metric" must define one of :query or :query_range') unless query + + query + end + end + end + end + end +end diff --git a/spec/controllers/projects/environments/prometheus_api_controller_spec.rb b/spec/controllers/projects/environments/prometheus_api_controller_spec.rb index d232408b775..fdef9bc5638 100644 --- a/spec/controllers/projects/environments/prometheus_api_controller_spec.rb +++ b/spec/controllers/projects/environments/prometheus_api_controller_spec.rb @@ -85,12 +85,12 @@ describe Projects::Environments::PrometheusApiController do context 'with nil result' do let(:service_result) { nil } - it 'returns 202 accepted' do + it 'returns 204 no_content' do get :proxy, params: environment_params expect(json_response['status']).to eq('processing') expect(json_response['message']).to eq('Not ready yet. Try again later.') - expect(response).to have_gitlab_http_status(:accepted) + expect(response).to have_gitlab_http_status(:no_content) end end diff --git a/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/metrics.json b/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/metrics.json index 2d0af57ec2c..33393805464 100644 --- a/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/metrics.json +++ b/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/metrics.json @@ -2,7 +2,8 @@ "type": "object", "required": [ "unit", - "label" + "label", + "prometheus_endpoint_path" ], "oneOf": [ { "required": ["query"] }, @@ -14,7 +15,8 @@ "query": { "type": "string" }, "unit": { "type": "string" }, "label": { "type": "string" }, - "track": { "type": "string" } + "track": { "type": "string" }, + "prometheus_endpoint_path": { "type": "string" } }, "additionalProperties": false } diff --git a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap index 1b4564303e4..86bfde1a28c 100644 --- a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap +++ b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap @@ -22,6 +22,8 @@ exports[`Repository table row component renders table row 1`] = ` </a> <!----> + + <!----> </td> <td diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index a70dc7bb866..90a502966ad 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -1,4 +1,5 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; +import { GlBadge } from '@gitlab/ui'; import TableRow from '~/repository/components/table/row.vue'; let vm; @@ -98,4 +99,16 @@ describe('Repository table row component', () => { expect(vm.find('a').attributes('href')).toEqual('https://test.com'); }); + + it('renders LFS badge', () => { + factory({ + id: '1', + path: 'test', + type: 'commit', + currentPath: '/', + lfsOid: '1', + }); + + expect(vm.find(GlBadge).exists()).toBe(true); + }); }); diff --git a/spec/graphql/types/tree/blob_type_spec.rb b/spec/graphql/types/tree/blob_type_spec.rb index b12e214ca84..22c11aff90a 100644 --- a/spec/graphql/types/tree/blob_type_spec.rb +++ b/spec/graphql/types/tree/blob_type_spec.rb @@ -5,5 +5,5 @@ require 'spec_helper' describe Types::Tree::BlobType do it { expect(described_class.graphql_name).to eq('Blob') } - it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path, :web_url) } + it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path, :web_url, :lfs_oid) } end diff --git a/spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb b/spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb new file mode 100644 index 00000000000..0137b1029cd --- /dev/null +++ b/spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe Gitlab::Graphql::Loaders::BatchCommitLoader do + include GraphqlHelpers + + set(:project) { create(:project, :repository) } + let(:repository) { project.repository } + let(:blob) { Gitlab::Graphql::Representation::TreeEntry.new(repository.blob_at('master', 'files/lfs/lfs_object.iso'), repository) } + let(:otherblob) { Gitlab::Graphql::Representation::TreeEntry.new(repository.blob_at('master', 'README'), repository) } + + describe '#find' do + it 'batch-resolves LFS blob IDs' do + expect(Gitlab::Git::Blob).to receive(:batch_lfs_pointers).once.and_call_original + + result = batch do + [blob, otherblob].map { |b| described_class.new(repository, b.id).find } + end + + expect(result.first).to eq(blob.lfs_oid) + expect(result.last).to eq(nil) + end + end +end diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json index fb7bddb386c..6512fe80a3b 100644 --- a/spec/lib/gitlab/import_export/project.json +++ b/spec/lib/gitlab/import_export/project.json @@ -6223,7 +6223,10 @@ "erased_by_id": null, "erased_at": null, "type": "Ci::Build", - "token": "abcd" + "token": "abcd", + "artifacts_file_store": 1, + "artifacts_metadata_store": 1, + "artifacts_size": 10 }, { "id": 72, diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb index e88eb140b35..bdcb5914575 100644 --- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb @@ -6,7 +6,7 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi include MetricsDashboardHelpers set(:project) { build(:project) } - set(:environment) { build(:environment, project: project) } + set(:environment) { create(:environment, project: project) } let(:system_dashboard_path) { Gitlab::Metrics::Dashboard::SystemDashboardService::SYSTEM_DASHBOARD_PATH} describe '.find' do @@ -27,6 +27,13 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi it_behaves_like 'misconfigured dashboard service response', :unprocessable_entity end + context 'when the dashboard contains a metric without a query' do + let(:dashboard) { { 'panel_groups' => [{ 'panels' => [{ 'metrics' => [{ 'id' => 'mock' }] }] }] } } + let(:project) { project_with_dashboard(dashboard_path, dashboard.to_yaml) } + + it_behaves_like 'misconfigured dashboard service response', :unprocessable_entity + end + context 'when the system dashboard is specified' do let(:dashboard_path) { system_dashboard_path } diff --git a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb index be3c1095bd7..797d4daabe3 100644 --- a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb @@ -4,13 +4,19 @@ require 'spec_helper' describe Gitlab::Metrics::Dashboard::Processor do let(:project) { build(:project) } - let(:environment) { build(:environment, project: project) } + let(:environment) { create(:environment, project: project) } let(:dashboard_yml) { YAML.load_file('spec/fixtures/lib/gitlab/metrics/dashboard/sample_dashboard.yml') } describe 'process' do let(:process_params) { [project, environment, dashboard_yml] } let(:dashboard) { described_class.new(*process_params).process(insert_project_metrics: true) } + it 'includes a path for the prometheus endpoint with each metric' do + expect(all_metrics).to satisfy_all do |metric| + metric[:prometheus_endpoint_path] == prometheus_path(metric[:query_range]) + end + end + context 'when dashboard config corresponds to common metrics' do let!(:common_metric) { create(:prometheus_metric, :common, identifier: 'metric_a1') } @@ -61,7 +67,7 @@ describe Gitlab::Metrics::Dashboard::Processor do shared_examples_for 'errors with message' do |expected_message| it 'raises a DashboardLayoutError' do - error_class = Gitlab::Metrics::Dashboard::Stages::BaseStage::DashboardLayoutError + error_class = Gitlab::Metrics::Dashboard::Stages::BaseStage::DashboardProcessingError expect { dashboard }.to raise_error(error_class, expected_message) end @@ -84,6 +90,12 @@ describe Gitlab::Metrics::Dashboard::Processor do it_behaves_like 'errors with message', 'Each "panel" must define an array :metrics' end + + context 'when the dashboard contains a metric which is missing a query' do + let(:dashboard_yml) { { panel_groups: [{ panels: [{ metrics: [{}] }] }] } } + + it_behaves_like 'errors with message', 'Each "metric" must define one of :query or :query_range' + end end private @@ -99,7 +111,17 @@ describe Gitlab::Metrics::Dashboard::Processor do query_range: metric.query, unit: metric.unit, label: metric.legend, - metric_id: metric.id + metric_id: metric.id, + prometheus_endpoint_path: prometheus_path(metric.query) } end + + def prometheus_path(query) + Gitlab::Routing.url_helpers.prometheus_api_project_environment_path( + project, + environment, + proxy_path: :query_range, + query: query + ) + end end diff --git a/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb b/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb index 162beb0268a..794ac5f109b 100644 --- a/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb @@ -7,7 +7,7 @@ describe Gitlab::Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_m set(:user) { build(:user) } set(:project) { build(:project) } - set(:environment) { build(:environment, project: project) } + set(:environment) { create(:environment, project: project) } before do project.add_maintainer(user) diff --git a/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb b/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb index e71ce2481a3..2648fe990de 100644 --- a/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb @@ -6,7 +6,7 @@ describe Gitlab::Metrics::Dashboard::SystemDashboardService, :use_clean_rails_me include MetricsDashboardHelpers set(:project) { build(:project) } - set(:environment) { build(:environment, project: project) } + set(:environment) { create(:environment, project: project) } describe 'get_dashboard' do let(:dashboard_path) { described_class::SYSTEM_DASHBOARD_PATH } diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb index 53df9e0bc05..7faa196623f 100644 --- a/spec/models/concerns/reactive_caching_spec.rb +++ b/spec/models/concerns/reactive_caching_spec.rb @@ -232,4 +232,17 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do end end end + + describe 'default options' do + let(:cached_class) { Class.new { include ReactiveCaching } } + + subject { cached_class.new } + + it { expect(subject.reactive_cache_lease_timeout).to be_a(ActiveSupport::Duration) } + it { expect(subject.reactive_cache_refresh_interval).to be_a(ActiveSupport::Duration) } + it { expect(subject.reactive_cache_lifetime).to be_a(ActiveSupport::Duration) } + + it { expect(subject.reactive_cache_key).to respond_to(:call) } + it { expect(subject.reactive_cache_worker_finder).to respond_to(:call) } + end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 875a9a76e12..14ce3c32e77 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -42,6 +42,9 @@ Capybara.register_driver :chrome do |app| # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252 options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER'] + # Explicitly set user-data-dir to prevent crashes. See https://gitlab.com/gitlab-org/gitlab-ce/issues/58882#note_179811508 + options.add_argument("user-data-dir=/tmp/chrome") if ENV['CI'] || ENV['CI_SERVER'] + Capybara::Selenium::Driver.new( app, browser: :chrome, |