Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-08 12:06:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-08 12:06:09 +0300
commit77a7772c3bdb03d92cbc154f6b1a762953cc7c19 (patch)
treeb841c2233afb01d1b6cc7dd4023f2b677ec19eb3
parentf7234a0894db99c7ade3cf29c1b467aa4807cc41 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--PROCESS.md145
-rw-r--r--app/assets/javascripts/registry/components/collapsible_container.vue2
-rw-r--r--app/assets/javascripts/registry/components/table_registry.vue4
-rw-r--r--app/controllers/projects/pipelines_controller.rb23
-rw-r--r--app/controllers/projects/registry/repositories_controller.rb2
-rw-r--r--app/controllers/projects/registry/tags_controller.rb3
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/clusters/applications/prometheus.rb7
-rw-r--r--app/models/concerns/relative_positioning.rb2
-rw-r--r--app/presenters/ci/pipeline_presenter.rb58
-rw-r--r--app/serializers/test_report_entity.rb15
-rw-r--r--app/serializers/test_report_serializer.rb5
-rw-r--r--app/serializers/test_suite_entity.rb16
-rw-r--r--changelogs/unreleased/31590-tag-delete-instrumentation.yml5
-rw-r--r--changelogs/unreleased/32839-fix-relative-position-edge-case.yml5
-rw-r--r--changelogs/unreleased/feature-ignore-prometheus-metrics-not-present.yml5
-rw-r--r--changelogs/unreleased/mr-links-4-pipes.yml5
-rw-r--r--config/gitlab.yml.example3
-rw-r--r--config/initializers/1_settings.rb3
-rw-r--r--config/initializers/pages.rb2
-rw-r--r--config/routes/project.rb1
-rw-r--r--doc/administration/logs.md13
-rw-r--r--doc/ci/yaml/README.md13
-rw-r--r--doc/development/code_review.md10
-rw-r--r--doc/development/documentation/feature-change-workflow.md4
-rw-r--r--lib/gitlab/pages_client.rb119
-rw-r--r--lib/tasks/gitlab/pages.rake9
-rw-r--r--locale/gitlab.pot3
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb70
-rw-r--r--spec/controllers/projects/registry/repositories_controller_spec.rb14
-rw-r--r--spec/controllers/projects/registry/tags_controller_spec.rb20
-rw-r--r--spec/lib/gitlab/pages_client_spec.rb174
-rw-r--r--spec/models/clusters/applications/prometheus_spec.rb12
-rw-r--r--spec/presenters/ci/pipeline_presenter_spec.rb38
-rw-r--r--spec/serializers/test_report_entity_spec.rb25
-rw-r--r--spec/serializers/test_suite_entity_spec.rb29
-rw-r--r--spec/support/shared_examples/relative_positioning_shared_examples.rb36
37 files changed, 417 insertions, 487 deletions
diff --git a/PROCESS.md b/PROCESS.md
index 997612dfbad..6bff60bff0f 100644
--- a/PROCESS.md
+++ b/PROCESS.md
@@ -11,15 +11,6 @@
- [Merge request coaching](#merge-request-coaching)
- [Assigning issues](#assigning-issues)
- [Be kind](#be-kind)
-- [Feature freeze on the 7th for the release on the 22nd](#feature-freeze-on-the-7th-for-the-release-on-the-22nd)
- - [Feature flags](#feature-flags)
- - [Between the 1st and the 7th](#between-the-1st-and-the-7th)
- - [What happens if these deadlines are missed?](#what-happens-if-these-deadlines-are-missed)
- - [On the 7th](#on-the-7th)
- - [Feature merge requests](#feature-merge-requests)
- - [Documentation merge requests](#documentation-merge-requests)
- - [After the 7th](#after-the-7th)
- - [Asking for an exception](#asking-for-an-exception)
- [Bugs](#bugs)
- [Regressions](#regressions)
- [Managing bugs](#managing-bugs)
@@ -100,135 +91,6 @@ Product Managers must have their proposal for that milestone ready by the 22nd o
This proposal will be shared with Engineering for discussion, feedback, and planning.
The plan for the upcoming milestone must be finalized by the 1st of the month, one week before kickoff on the 8th.
-## Feature freeze on the 7th for the release on the 22nd
-
-The feature freeze on the 7th has been discontinued. [Transition period overview](https://gitlab.com/gitlab-org/release/docs/blob/21cbd409dd5f157fe252f254f3e897f01908abe2/general/deploy/auto-deploy-transition.md#transition)
-describes the change to this process. During the transition period, the only guarantee that
-a change will be included in the release on the 22nd is if the change has been
-deployed to GitLab.com prior to this date.
-
-### Between the 1st and the 7th
-
-These types of merge requests for the upcoming release need special consideration:
-
-* **Large features**: a large feature is one that is highlighted in the kick-off
- and the release blogpost; typically this will have its own channel in Slack
- and a dedicated team with front-end, back-end, and UX.
-* **Small features**: any other feature request.
-
-It is strongly recommended that **large features** be with a maintainer **by the
-1st**. This means that:
-
-* There is a merge request (even if it's WIP).
-* The person (or people, if it needs a frontend and backend maintainer) who will
- ultimately be responsible for merging this have been pinged on the MR.
-
-It's OK if merge request isn't completely done, but this allows the maintainer
-enough time to make the decision about whether this can make it in before the
-freeze. If the maintainer doesn't think it will make it, they should inform the
-developers working on it and the Product Manager responsible for the feature.
-
-The maintainer can also choose to assign a reviewer to perform an initial
-review, but this way the maintainer is unlikely to be surprised by receiving an
-MR later in the cycle.
-
-It is strongly recommended that **small features** be with a reviewer (not
-necessarily a maintainer) **by the 3rd**.
-
-Most merge requests from the community do not have a specific release
-target. However, if one does and falls into either of the above categories, it's
-the reviewer's responsibility to manage the above communication and assignment
-on behalf of the community member.
-
-Every new feature or change should be shipped with its corresponding documentation
-in accordance with the
-[documentation process](https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html)
-and [structure](https://docs.gitlab.com/ee/development/documentation/structure.html) guides.
-Note that a technical writer will review all changes to documentation. This can occur
-in the same MR as the feature code, but [if there is not sufficient time or need,
-it can be planned via a follow-up issue for doc review](https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#1-product-managers-role),
-and another MR, if needed. Regardless, complete docs must be merged with code by the freeze.
-
-#### What happens if these deadlines are missed?
-
-If a small or large feature is _not_ with a maintainer or reviewer by the
-recommended date, this does _not_ mean that maintainers or reviewers will refuse
-to review or merge it, or that the feature will definitely not make it in before
-the feature freeze.
-
-However, with every day that passes without review, it will become more likely
-that the feature will slip, because maintainers and reviewers may not have
-enough time to do a thorough review, and developers may not have enough time to
-adequately address any feedback that may come back.
-
-A maintainer or reviewer may also determine that it will not be possible to
-finish the current scope of the feature in time, but that it is possible to
-reduce the scope so that something can still ship this month, with the remaining
-scope moving to the next release. The sooner this decision is made, in
-conversation with the Product Manager and developer, the more time there is to
-extract that which is now out of scope, and to finish that which remains in scope.
-
-For these reasons, it is strongly recommended to follow the guidelines above,
-to maximize the chances of your feature making it in before the feature freeze,
-and to prevent any last minute surprises.
-
-### On the 7th
-
-Merge requests should still be complete, following the [definition of done][done].
-
-If a merge request is not ready, but the developers and Product Manager
-responsible for the feature think it is essential that it is in the release,
-they can [ask for an exception](#asking-for-an-exception) in advance. This is
-preferable to merging something that we are not confident in, but should still
-be a rare case: most features can be allowed to slip a release.
-
-All Community Edition merge requests from GitLab team members merged on the
-freeze date (the 7th) should have a corresponding Enterprise Edition merge
-request, even if there are no conflicts. This is to reduce the size of the
-subsequent EE merge, as we often merge a lot to CE on the release date. For more
-information, see
-[Automatic CE->EE merge][automatic_ce_ee_merge] and
-[Guidelines for implementing Enterprise Edition features][ee_features].
-
-### After the 7th
-
-Once the stable branch is frozen, the only MRs that can be cherry-picked into
-the stable branch are:
-
-* Fixes for [regressions](#regressions) where the affected version `xx.x` in `regression:xx.x` is the current release. See [Managing bugs](#managing-bugs) section.
-* Fixes for security issues.
-* Fixes or improvements to automated QA scenarios.
-* [Documentation improvements](https://docs.gitlab.com/ee/development/documentation/workflow.html) for feature changes made in the same release, though initial docs for these features should have already been merged by the freeze, as required.
-* New or updated translations (as long as they do not touch application code).
-* Changes that are behind a feature flag and have the ~"feature flag" label.
-
-During the feature freeze all merge requests that are meant to go into the
-upcoming release should have the correct milestone assigned _and_ the
-`Pick into X.Y` label where `X.Y` is equal to the milestone, so that release
-managers can find and pick them.
-Merge requests without this label will not be picked into the stable release.
-
-For example, if the upcoming release is `10.2.0` you will need to set the
-`Pick into 10.2` label.
-
-Fixes marked like this will be shipped in the next RC (before the 22nd), or the
-next patch release.
-
-If a merge request is to be picked into more than one release it will need one
-`Pick into X.Y` label per release where the merge request should be back-ported
-to. For example:
-
-- `Pick into 10.1`
-- `Pick into 10.0`
-- `Pick into 9.5`
-
-### Asking for an exception
-
-If you think a merge request should go into an RC or patch even though it does not meet these requirements,
-you can ask for an exception to be made.
-
-Check [this guide](https://gitlab.com/gitlab-org/release/docs/blob/master/general/exception-request/process.md) about how to open an exception request before opening one.
-
## Bugs
A ~bug is a defect, error, failure which causes the system to behave incorrectly or prevents it from fulfilling the product requirements.
@@ -256,13 +118,6 @@ Regressions should be considered high priority issues that should be solved as s
### Managing bugs
**Prioritization:** We give higher priority to regressions on features that worked in the last recent monthly release and the current release candidates.
-The two scenarios below can [bypass the exception request in the release process](https://gitlab.com/gitlab-org/release/docs/blob/master/general/exception-request/process.md#after-the-7th), where the affected regression version matches the current monthly release version.
-* A regression which worked in the **Last monthly release**
- * **Example:** In 11.0 we released a new `feature X` that is verified as working. Then in release 11.1 the feature no longer works, this is regression for 11.1. The issue should have the `regression:11.1` label.
- * *Note:* When we say `the last recent monthly release`, this can refer to either the version currently running on GitLab.com, or the most recent version available in the package repositories.
-* A regression which worked in the **Current release candidates**
- * **Example:** In 11.1-RC3 we shipped a new feature which has been verified as working. Then in 11.1-RC5 the feature no longer works, this is regression for 11.1. The issue should have the `regression:11.1` label.
- * *Note:* Because GitLab.com runs release candidates of new releases, a regression can be reported in a release before its 'official' release date on the 22nd of the month.
When a bug is found:
1. Create an issue describing the problem in the most detailed way possible.
diff --git a/app/assets/javascripts/registry/components/collapsible_container.vue b/app/assets/javascripts/registry/components/collapsible_container.vue
index 41bd9225c6e..3e31d24088e 100644
--- a/app/assets/javascripts/registry/components/collapsible_container.vue
+++ b/app/assets/javascripts/registry/components/collapsible_container.vue
@@ -85,6 +85,8 @@ export default {
v-gl-modal="modalId"
:title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
+ data-track-event="click_button"
+ data-track-label="registry_repository_delete"
class="js-remove-repo btn-inverted"
variant="danger"
>
diff --git a/app/assets/javascripts/registry/components/table_registry.vue b/app/assets/javascripts/registry/components/table_registry.vue
index 9a2291613e4..d6d2896a8f8 100644
--- a/app/assets/javascripts/registry/components/table_registry.vue
+++ b/app/assets/javascripts/registry/components/table_registry.vue
@@ -192,6 +192,8 @@ export default {
v-gl-modal="modalId"
:disabled="!itemsToBeDeleted || itemsToBeDeleted.length === 0"
class="js-delete-registry float-right"
+ data-track-event="click_button"
+ data-track-label="bulk_registry_tag_delete"
variant="danger"
:title="s__('ContainerRegistry|Remove selected tags')"
:aria-label="s__('ContainerRegistry|Remove selected tags')"
@@ -246,6 +248,8 @@ export default {
v-gl-modal="modalId"
:title="s__('ContainerRegistry|Remove tag')"
:aria-label="s__('ContainerRegistry|Remove tag')"
+ data-track-event="click_button"
+ data-track-label="registry_tag_delete"
variant="danger"
class="js-delete-registry-row float-right btn-inverted btn-border-color btn-icon"
@click="deleteSingleItem(index)"
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index cfa46705483..1bacdc0b1b2 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
class Projects::PipelinesController < Projects::ApplicationController
+ include ::Gitlab::Utils::StrongMemoize
+
before_action :whitelist_query_limiting, only: [:create, :retry]
before_action :pipeline, except: [:index, :new, :create, :charts]
before_action :set_pipeline_path, only: [:show]
@@ -151,6 +153,19 @@ class Projects::PipelinesController < Projects::ApplicationController
@counts[:failed] = @project.all_pipelines.failed.count(:all)
end
+ def test_report
+ return unless Feature.enabled?(:junit_pipeline_view, project)
+
+ if pipeline_test_report == :error
+ render json: { status: :error_parsing_report }
+ return
+ end
+
+ render json: TestReportSerializer
+ .new(current_user: @current_user)
+ .represent(pipeline_test_report)
+ end
+
private
def serialize_pipelines
@@ -217,6 +232,14 @@ class Projects::PipelinesController < Projects::ApplicationController
view_context.limited_counter_with_delimiter(finder.execute)
end
+
+ def pipeline_test_report
+ strong_memoize(:pipeline_test_report) do
+ @pipeline.test_reports
+ rescue Gitlab::Ci::Parsers::ParserError
+ :error
+ end
+ end
end
Projects::PipelinesController.prepend_if_ee('EE::Projects::PipelinesController')
diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb
index e205e2fd4f8..9405fd526ae 100644
--- a/app/controllers/projects/registry/repositories_controller.rb
+++ b/app/controllers/projects/registry/repositories_controller.rb
@@ -8,6 +8,7 @@ module Projects
def index
@images = project.container_repositories
+ track_event(:list_repositories)
respond_to do |format|
format.html
@@ -21,6 +22,7 @@ module Projects
def destroy
DeleteContainerRepositoryWorker.perform_async(current_user.id, image.id)
+ track_event(:delete_repository)
respond_to do |format|
format.json { head :no_content }
diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb
index b5ee0ba9beb..e572c56adf5 100644
--- a/app/controllers/projects/registry/tags_controller.rb
+++ b/app/controllers/projects/registry/tags_controller.rb
@@ -8,6 +8,7 @@ module Projects
LIMIT = 15
def index
+ track_event(:list_tags)
respond_to do |format|
format.json do
render json: ContainerTagsSerializer
@@ -22,6 +23,7 @@ module Projects
result = Projects::ContainerRepository::DeleteTagsService
.new(image.project, current_user, tags: [params[:id]])
.execute(image)
+ track_event(:delete_tag)
respond_to do |format|
format.json { head(result[:status] == :success ? :ok : bad_request) }
@@ -43,6 +45,7 @@ module Projects
result = Projects::ContainerRepository::DeleteTagsService
.new(image.project, current_user, tags: tag_names)
.execute(image)
+ track_event(:delete_tag_bulk)
respond_to do |format|
format.json { head(result[:status] == :success ? :no_content : :bad_request) }
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index aed95b4601b..b34fd3f1ec9 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -746,6 +746,10 @@ module Ci
end
end
+ def all_merge_requests_by_recency
+ all_merge_requests.order(id: :desc)
+ end
+
def detailed_status(current_user)
Gitlab::Ci::Status::Pipeline::Factory
.new(self, current_user)
diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb
index 7a414d1a5bb..5e7fdd55cb6 100644
--- a/app/models/clusters/applications/prometheus.rb
+++ b/app/models/clusters/applications/prometheus.rb
@@ -112,7 +112,12 @@ module Clusters
def delete_knative_istio_metrics
return [] unless cluster.application_knative_available?
- [Gitlab::Kubernetes::KubectlCmd.delete("-f", Clusters::Applications::Knative::METRICS_CONFIG)]
+ [
+ Gitlab::Kubernetes::KubectlCmd.delete(
+ "-f", Clusters::Applications::Knative::METRICS_CONFIG,
+ "--ignore-not-found"
+ )
+ ]
end
end
end
diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb
index dfe3c391880..b645cf71443 100644
--- a/app/models/concerns/relative_positioning.rb
+++ b/app/models/concerns/relative_positioning.rb
@@ -127,6 +127,7 @@ module RelativePositioning
if pos_after && (pos_after - pos_before) < 2
before.move_sequence_after
+ pos_after = before.next_relative_position
end
self.relative_position = self.class.position_between(pos_before, pos_after)
@@ -138,6 +139,7 @@ module RelativePositioning
if pos_before && (pos_after - pos_before) < 2
after.move_sequence_before
+ pos_before = after.prev_relative_position
end
self.relative_position = self.class.position_between(pos_before, pos_after)
diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb
index 73a048dfa56..d81b1e6c522 100644
--- a/app/presenters/ci/pipeline_presenter.rb
+++ b/app/presenters/ci/pipeline_presenter.rb
@@ -48,15 +48,35 @@ module Ci
def ref_text
if pipeline.detached_merge_request_pipeline?
- _("for %{link_to_merge_request} with %{link_to_merge_request_source_branch}").html_safe % { link_to_merge_request: link_to_merge_request, link_to_merge_request_source_branch: link_to_merge_request_source_branch }
+ _("for %{link_to_merge_request} with %{link_to_merge_request_source_branch}")
+ .html_safe % {
+ link_to_merge_request: link_to_merge_request,
+ link_to_merge_request_source_branch: link_to_merge_request_source_branch
+ }
elsif pipeline.merge_request_pipeline?
- _("for %{link_to_merge_request} with %{link_to_merge_request_source_branch} into %{link_to_merge_request_target_branch}").html_safe % { link_to_merge_request: link_to_merge_request, link_to_merge_request_source_branch: link_to_merge_request_source_branch, link_to_merge_request_target_branch: link_to_merge_request_target_branch }
+ _("for %{link_to_merge_request} with %{link_to_merge_request_source_branch} into %{link_to_merge_request_target_branch}")
+ .html_safe % {
+ link_to_merge_request: link_to_merge_request,
+ link_to_merge_request_source_branch: link_to_merge_request_source_branch,
+ link_to_merge_request_target_branch: link_to_merge_request_target_branch
+ }
+ elsif pipeline.ref && pipeline.ref_exists?
+ _("for %{link_to_pipeline_ref}")
+ .html_safe % { link_to_pipeline_ref: link_to_pipeline_ref }
elsif pipeline.ref
- if pipeline.ref_exists?
- _("for %{link_to_pipeline_ref}").html_safe % { link_to_pipeline_ref: link_to_pipeline_ref }
- else
- _("for %{ref}").html_safe % { ref: content_tag(:span, pipeline.ref, class: 'ref-name') }
- end
+ _("for %{ref}").html_safe % { ref: plain_ref_name }
+ end
+ end
+
+ def all_related_merge_request_text
+ if all_related_merge_requests.none?
+ 'No related merge requests found.'
+ else
+ _("%{count} related %{pluralized_subject}: %{links}" % {
+ count: all_related_merge_requests.count,
+ pluralized_subject: 'merge request'.pluralize(all_related_merge_requests.count),
+ links: all_related_merge_request_links.join(', ')
+ }).html_safe
end
end
@@ -84,10 +104,30 @@ module Ci
private
+ def plain_ref_name
+ content_tag(:span, pipeline.ref, class: 'ref-name')
+ end
+
def merge_request_presenter
- return unless pipeline.triggered_by_merge_request?
+ strong_memoize(:merge_request_presenter) do
+ if pipeline.triggered_by_merge_request?
+ pipeline.merge_request.present(current_user: current_user)
+ end
+ end
+ end
- @merge_request_presenter ||= pipeline.merge_request.present(current_user: current_user)
+ def all_related_merge_request_links
+ all_related_merge_requests.map do |merge_request|
+ mr_path = project_merge_request_path(merge_request.project, merge_request)
+
+ link_to "#{merge_request.to_reference} #{merge_request.title}", mr_path, class: 'mr-iid'
+ end
+ end
+
+ def all_related_merge_requests
+ strong_memoize(:all_related_merge_requests) do
+ pipeline.ref ? pipeline.all_merge_requests_by_recency.to_a : []
+ end
end
end
end
diff --git a/app/serializers/test_report_entity.rb b/app/serializers/test_report_entity.rb
new file mode 100644
index 00000000000..9eb487da60a
--- /dev/null
+++ b/app/serializers/test_report_entity.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TestReportEntity < Grape::Entity
+ expose :total_time
+ expose :total_count
+
+ expose :success_count
+ expose :failed_count
+ expose :skipped_count
+ expose :error_count
+
+ expose :test_suites, using: TestSuiteEntity do |report|
+ report.test_suites.values
+ end
+end
diff --git a/app/serializers/test_report_serializer.rb b/app/serializers/test_report_serializer.rb
new file mode 100644
index 00000000000..8906b09bc6a
--- /dev/null
+++ b/app/serializers/test_report_serializer.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class TestReportSerializer < BaseSerializer
+ entity TestReportEntity
+end
diff --git a/app/serializers/test_suite_entity.rb b/app/serializers/test_suite_entity.rb
new file mode 100644
index 00000000000..0f88a496c77
--- /dev/null
+++ b/app/serializers/test_suite_entity.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class TestSuiteEntity < Grape::Entity
+ expose :name
+ expose :total_time
+ expose :total_count
+
+ expose :success_count
+ expose :failed_count
+ expose :skipped_count
+ expose :error_count
+
+ expose :test_cases, using: TestCaseEntity do |test_suite|
+ test_suite.test_cases.values.flat_map(&:values)
+ end
+end
diff --git a/changelogs/unreleased/31590-tag-delete-instrumentation.yml b/changelogs/unreleased/31590-tag-delete-instrumentation.yml
new file mode 100644
index 00000000000..d071808987f
--- /dev/null
+++ b/changelogs/unreleased/31590-tag-delete-instrumentation.yml
@@ -0,0 +1,5 @@
+---
+title: Collect docker registry related metrics
+merge_request: 17063
+author:
+type: added
diff --git a/changelogs/unreleased/32839-fix-relative-position-edge-case.yml b/changelogs/unreleased/32839-fix-relative-position-edge-case.yml
new file mode 100644
index 00000000000..fd975f27cdc
--- /dev/null
+++ b/changelogs/unreleased/32839-fix-relative-position-edge-case.yml
@@ -0,0 +1,5 @@
+---
+title: Fix relative positioning when moving items down and there is no space
+merge_request: 17781
+author:
+type: fixed
diff --git a/changelogs/unreleased/feature-ignore-prometheus-metrics-not-present.yml b/changelogs/unreleased/feature-ignore-prometheus-metrics-not-present.yml
new file mode 100644
index 00000000000..ab480548387
--- /dev/null
+++ b/changelogs/unreleased/feature-ignore-prometheus-metrics-not-present.yml
@@ -0,0 +1,5 @@
+---
+title: Avoid knative and prometheus uninstall race condition
+merge_request: 18020
+author:
+type: changed
diff --git a/changelogs/unreleased/mr-links-4-pipes.yml b/changelogs/unreleased/mr-links-4-pipes.yml
new file mode 100644
index 00000000000..8eed38963ea
--- /dev/null
+++ b/changelogs/unreleased/mr-links-4-pipes.yml
@@ -0,0 +1,5 @@
+---
+title: Use MR links in PipelinePresenter#ref_text for branch pipelines
+merge_request: 17947
+author:
+type: changed
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index 3b7abdfe17e..f2acfef80e9 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -319,8 +319,7 @@ production: &base
artifacts_server: true # Set to false if you want to disable online view of HTML artifacts
# external_http: ["1.1.1.1:80", "[2001::1]:80"] # If defined, enables custom domain support in GitLab Pages
# external_https: ["1.1.1.1:443", "[2001::1]:443"] # If defined, enables custom domain and certificate support in GitLab Pages
- admin:
- address: unix:/home/git/gitlab/tmp/sockets/private/pages-admin.socket # TCP connections are supported too (e.g. tcp://host:port)
+
# File that contains the shared secret key for verifying access for gitlab-pages.
# Default is '.gitlab_pages_shared_secret' relative to Rails.root (i.e. root of the GitLab app).
# secret_file: /home/git/gitlab/.gitlab_pages_shared_secret
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 4e66aff8c17..b22391e3e63 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -290,9 +290,6 @@ Settings.pages['url'] ||= Settings.__send__(:build_pages_url)
Settings.pages['external_http'] ||= false unless Settings.pages['external_http'].present?
Settings.pages['external_https'] ||= false unless Settings.pages['external_https'].present?
Settings.pages['artifacts_server'] ||= Settings.pages['enabled'] if Settings.pages['artifacts_server'].nil?
-
-Settings.pages['admin'] ||= Settingslogic.new({})
-Settings.pages.admin['certificate'] ||= ''
Settings.pages['secret_file'] ||= Rails.root.join('.gitlab_pages_shared_secret')
#
diff --git a/config/initializers/pages.rb b/config/initializers/pages.rb
deleted file mode 100644
index 835197557e8..00000000000
--- a/config/initializers/pages.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-Gitlab::PagesClient.read_or_create_token
-Gitlab::PagesClient.load_certificate
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 5225cd5b054..3675a4600fe 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -387,6 +387,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :builds
get :failures
get :status
+ get :test_report
Gitlab.ee do
get :security
diff --git a/doc/administration/logs.md b/doc/administration/logs.md
index 136e3c255de..dae0dae8395 100644
--- a/doc/administration/logs.md
+++ b/doc/administration/logs.md
@@ -294,9 +294,11 @@ This log records:
- Information whenever [Rack Attack] registers an abusive request.
- Requests over the [Rate Limit] on raw endpoints.
+- [Protected paths] abusive requests.
NOTE: **Note:**
-From [%12.1](https://gitlab.com/gitlab-org/gitlab-foss/issues/62756), user id and username are available on this log.
+From [%12.1](https://gitlab.com/gitlab-org/gitlab-foss/issues/62756), user id and username are also
+recorded on this log, if available.
## `graphql_json.log`
@@ -341,10 +343,6 @@ will be generated in `/var/log/gitlab/gitlab-rails/web_exporter.log` for
Omnibus GitLab packages or in `/home/git/gitlab/log/web_exporter.log` for
installations from source.
-[repocheck]: repository_checks.md
-[Rack Attack]: ../security/rack_attack.md
-[Rate Limit]: ../user/admin_area/settings/rate_limits_on_raw_endpoints.md
-
## `database_load_balancing.log` **(PREMIUM ONLY)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/15442) in GitLab 12.3.
@@ -354,3 +352,8 @@ It is stored at:
- `/var/log/gitlab/gitlab-rails/database_load_balancing.log` for Omnibus GitLab packages.
- `/home/git/gitlab/log/database_load_balancing.log` for installations from source.
+
+[repocheck]: repository_checks.md
+[Rack Attack]: ../security/rack_attack.md
+[Rate Limit]: ../user/admin_area/settings/rate_limits_on_raw_endpoints.md
+[Protected paths]: ../user/admin_area/settings/protected_paths.md
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index 6f096c59c5c..88f5fd2cdc2 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -107,7 +107,7 @@ The following table lists available parameters for jobs:
| [`environment`](#environment) | Name of an environment to which the job deploys. Also available: `environment:name`, `environment:url`, `environment:on_stop`, and `environment:action`. |
| [`cache`](#cache) | List of files that should be cached between subsequent runs. Also available: `cache:paths`, `cache:key`, `cache:untracked`, and `cache:policy`. |
| [`artifacts`](#artifacts) | List of files and directories to attach to a job on success. Also available: `artifacts:paths`, `artifacts:name`, `artifacts:untracked`, `artifacts:when`, `artifacts:expire_in`, `artifacts:reports`, and `artifacts:reports:junit`.<br><br>In GitLab [Enterprise Edition](https://about.gitlab.com/pricing/), these are available: `artifacts:reports:codequality`, `artifacts:reports:sast`, `artifacts:reports:dependency_scanning`, `artifacts:reports:container_scanning`, `artifacts:reports:dast`, `artifacts:reports:license_management`, `artifacts:reports:performance` and `artifacts:reports:metrics`. |
-| [`dependencies`](#dependencies) | Other jobs that a job depends on so that you can pass artifacts between them. |
+| [`dependencies`](#dependencies) | Restrict which artifacts are passed to a specific job by providing a list of jobs to fetch artifacts from. |
| [`coverage`](#coverage) | Code coverage settings for a given job. |
| [`retry`](#retry) | When and how many times a job can be auto-retried in case of a failure. |
| [`timeout`](#timeout) | Define a custom job-level timeout that takes precedence over the project-wide setting. |
@@ -782,6 +782,8 @@ In this example, a job either set to:
#### `rules:exists`
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/16574) in GitLab 12.4.
+
`exists` accepts an array of paths and will match if any of these paths exist
as files in the repository.
@@ -1455,7 +1457,7 @@ be available for download in the GitLab UI.
You can only use paths that are within the local working copy.
Wildcards can be used that follow the [glob](https://en.wikipedia.org/wiki/Glob_(programming)) patterns and [filepath.Match](https://golang.org/pkg/path/filepath/#Match).
-To pass artifacts between different jobs, see [dependencies](#dependencies).
+To restrict which jobs a specific job will fetch artifacts from, see [dependencies](#dependencies).
Send all files in `binaries` and `.config`:
@@ -1799,10 +1801,9 @@ be automatically shown in merge requests.
> Introduced in GitLab 8.6 and GitLab Runner v1.1.1.
-This feature should be used in conjunction with [`artifacts`](#artifacts) and
-allows you to define the artifacts to pass between different jobs.
-
-Note that `artifacts` from all previous [stages](#stages) are passed by default.
+By default, all [`artifacts`](#artifacts) from all previous [stages](#stages)
+are passed, but you can use the `dependencies` parameter to define a limited
+list of jobs (or no jobs) to fetch artifacts from.
To use this feature, define `dependencies` in context of the job and pass
a list of all previous jobs from which the artifacts should be downloaded.
diff --git a/doc/development/code_review.md b/doc/development/code_review.md
index 31a5111132b..421b70bd2db 100644
--- a/doc/development/code_review.md
+++ b/doc/development/code_review.md
@@ -256,18 +256,12 @@ Since [unblocking others is always a top priority](https://about.gitlab.com/hand
reviewers are expected to review assigned merge requests in a timely manner,
even when this may negatively impact their other tasks and priorities.
Doing so allows everyone involved in the merge request to iterate faster as the
-context is fresh in memory, improves contributors' experiences significantly,
-and gives authors more time to address feedback and iterate on their work before
-the [feature freeze](https://gitlab.com/gitlab-org/gitlab/blob/master/PROCESS.md#feature-freeze-on-the-7th-for-the-release-on-the-22nd).
+context is fresh in memory, improves contributors' experiences significantly.
A turnaround time of two working days is usually acceptable, since engineers
will typically have other things to work on while they're waiting for review,
but don't hesitate to ask the author if it's unclear what time frame would be
-acceptable, how urgent the review is, or how significant the blockage. Authors
-are also encouraged to provide this information up-front to reviewers, but are
-expected to be mindful of the [guidelines on when to ask for review on MRs that
-are intended to go in before the feature freeze](https://gitlab.com/gitlab-org/gitlab/blob/master/PROCESS.md#between-the-1st-and-the-7th),
-and realistic in their expectations if these were not followed.
+acceptable, how urgent the review is, or how significant the blockage.
If you don't think you'll be able to review a merge request within a reasonable
time frame, let the author know as soon as possible and try to help them find
diff --git a/doc/development/documentation/feature-change-workflow.md b/doc/development/documentation/feature-change-workflow.md
index 2b8a9ea6e1c..9e42d25d53a 100644
--- a/doc/development/documentation/feature-change-workflow.md
+++ b/doc/development/documentation/feature-change-workflow.md
@@ -7,7 +7,7 @@ description: How to add docs for new or enhanced GitLab features.
At GitLab, developers contribute new or updated documentation along with their code, but product managers and technical writers also have essential roles in the process.
- **Developers**: Author/update documentation in the same MR as their code, and
- merge it by the feature freeze for the assigned milestone. Request technical writer
+ merge it in the assigned milestone. Request technical writer
assistance if needed. Other developers typically act as reviewers.
- **Product Managers** (PMs): In the issue for all new and enhanced features,
confirm the documentation requirements, plus the mentioned feature description
@@ -40,7 +40,7 @@ interact with GitLab.
NOTE: **Note:**
When revamping documentation, if unrelated to the feature change, this should be submitted
in its own MR (using the [documentation improvement workflow](improvement-workflow.md))
-so that we can ensure the more time-sensitive doc updates are merged with code by the freeze.
+so that we can ensure the more time-sensitive doc updates are merged sooner.
## Documentation requirements in feature issues
diff --git a/lib/gitlab/pages_client.rb b/lib/gitlab/pages_client.rb
deleted file mode 100644
index 30a1f9ede25..00000000000
--- a/lib/gitlab/pages_client.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- class PagesClient
- class << self
- attr_reader :certificate, :token
-
- def call(service, rpc, request, timeout: nil)
- kwargs = request_kwargs(timeout)
- stub(service).__send__(rpc, request, kwargs) # rubocop:disable GitlabSecurity/PublicSend
- end
-
- # This function is not thread-safe. Call it from an initializer only.
- def read_or_create_token
- @token = read_token
- rescue Errno::ENOENT
- # TODO: uncomment this when omnibus knows how to write the token file for us
- # https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466
- #
- # write_token(SecureRandom.random_bytes(64))
- #
- # # Read from disk in case someone else won the race and wrote the file
- # # before us. If this fails again let the exception bubble up.
- # @token = read_token
- end
-
- # This function is not thread-safe. Call it from an initializer only.
- def load_certificate
- cert_path = config.certificate
- return unless cert_path.present?
-
- @certificate = File.read(cert_path)
- end
-
- def ping
- request = Grpc::Health::V1::HealthCheckRequest.new
- call(:health_check, :check, request, timeout: 5.seconds)
- end
-
- private
-
- def request_kwargs(timeout)
- encoded_token = Base64.strict_encode64(token.to_s)
- metadata = {
- 'authorization' => "Bearer #{encoded_token}"
- }
-
- result = { metadata: metadata }
-
- return result unless timeout
-
- # Do not use `Time.now` for deadline calculation, since it
- # will be affected by Timecop in some tests, but grpc's c-core
- # uses system time instead of timecop's time, so tests will fail
- # `Time.at(Process.clock_gettime(Process::CLOCK_REALTIME))` will
- # circumvent timecop
- deadline = Time.at(Process.clock_gettime(Process::CLOCK_REALTIME)) + timeout
- result[:deadline] = deadline
-
- result
- end
-
- def stub(name)
- stub_class(name).new(address, grpc_creds)
- end
-
- def stub_class(name)
- if name == :health_check
- Grpc::Health::V1::Health::Stub
- else
- # TODO use pages namespace
- Gitaly.const_get(name.to_s.camelcase.to_sym).const_get(:Stub)
- end
- end
-
- def address
- addr = config.address
- addr = addr.sub(%r{^tcp://}, '') if URI(addr).scheme == 'tcp'
- addr
- end
-
- def grpc_creds
- if address.start_with?('unix:')
- :this_channel_is_insecure
- elsif @certificate
- GRPC::Core::ChannelCredentials.new(@certificate)
- else
- # Use system certificate pool
- GRPC::Core::ChannelCredentials.new
- end
- end
-
- def config
- Gitlab.config.pages.admin
- end
-
- def read_token
- File.read(token_path)
- end
-
- def token_path
- Rails.root.join('.gitlab_pages_secret').to_s
- end
-
- def write_token(new_token)
- Tempfile.open(File.basename(token_path), File.dirname(token_path), encoding: 'ascii-8bit') do |f|
- f.write(new_token)
- f.close
- File.link(f.path, token_path)
- end
- rescue Errno::EACCES => ex
- # TODO stop rescuing this exception in GitLab 11.0 https://gitlab.com/gitlab-org/gitlab-foss/issues/45672
- Rails.logger.error("Could not write pages admin token file: #{ex}") # rubocop:disable Gitlab/RailsLogger
- rescue Errno::EEXIST
- # Another process wrote the token file concurrently with us. Use their token, not ours.
- end
- end
- end
-end
diff --git a/lib/tasks/gitlab/pages.rake b/lib/tasks/gitlab/pages.rake
deleted file mode 100644
index 100e480bd66..00000000000
--- a/lib/tasks/gitlab/pages.rake
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace :gitlab do
- namespace :pages do
- desc 'Ping the pages admin API'
- task admin_ping: :gitlab_environment do
- Gitlab::PagesClient.ping
- puts "OK: gitlab-pages admin API is reachable"
- end
- end
-end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index efeaf31924e..c61c27033c5 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -223,6 +223,9 @@ msgid_plural "%{count} pending comments"
msgstr[0] ""
msgstr[1] ""
+msgid "%{count} related %{pluralized_subject}: %{links}"
+msgstr ""
+
msgid "%{duration}ms"
msgstr ""
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index 3c2cb9ede40..d964b0672a9 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -398,6 +398,76 @@ describe Projects::PipelinesController do
end
end
+ describe 'GET test_report.json' do
+ subject(:get_test_report_json) do
+ post :test_report, params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id
+ },
+ format: :json
+ end
+
+ context 'when feature is enabled' do
+ before do
+ stub_feature_flags(junit_pipeline_view: true)
+ end
+
+ context 'when pipeline does not have a test report' do
+ let(:pipeline) { create(:ci_pipeline, project: project) }
+
+ it 'renders an empty test report' do
+ get_test_report_json
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['total_count']).to eq(0)
+ end
+ end
+
+ context 'when pipeline has a test report' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
+
+ it 'renders the test report' do
+ get_test_report_json
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['total_count']).to eq(4)
+ end
+ end
+
+ context 'when pipeline has corrupt test reports' do
+ let(:pipeline) { create(:ci_pipeline, project: project) }
+
+ before do
+ job = create(:ci_build, pipeline: pipeline)
+ create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project)
+ end
+
+ it 'renders the test reports' do
+ get_test_report_json
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['status']).to eq('error_parsing_report')
+ end
+ end
+ end
+
+ context 'when feature is disabled' do
+ let(:pipeline) { create(:ci_empty_pipeline, project: project) }
+
+ before do
+ stub_feature_flags(junit_pipeline_view: false)
+ end
+
+ it 'renders empty response' do
+ get_test_report_json
+
+ expect(response).to have_gitlab_http_status(:no_content)
+ expect(response.body).to be_empty
+ end
+ end
+ end
+
describe 'GET latest' do
let(:branch_main) { project.repository.branches[0] }
let(:branch_secondary) { project.repository.branches[1] }
diff --git a/spec/controllers/projects/registry/repositories_controller_spec.rb b/spec/controllers/projects/registry/repositories_controller_spec.rb
index 63d84b366d3..192e4ce2e73 100644
--- a/spec/controllers/projects/registry/repositories_controller_spec.rb
+++ b/spec/controllers/projects/registry/repositories_controller_spec.rb
@@ -40,6 +40,12 @@ describe Projects::Registry::RepositoriesController do
expect(response).to have_gitlab_http_status(:ok)
end
+ it 'tracks the event' do
+ expect(Gitlab::Tracking).to receive(:event).with(anything, 'list_repositories', {})
+
+ go_to_index
+ end
+
it 'creates a root container repository' do
expect { go_to_index }.to change { ContainerRepository.all.count }.by(1)
expect(ContainerRepository.first).to be_root_repository
@@ -92,8 +98,16 @@ describe Projects::Registry::RepositoriesController do
expect(DeleteContainerRepositoryWorker).to receive(:perform_async).with(user.id, repository.id)
delete_repository(repository)
+
expect(response).to have_gitlab_http_status(:no_content)
end
+
+ it 'tracks the event' do
+ expect(Gitlab::Tracking).to receive(:event).with(anything, 'delete_repository', {})
+ allow(DeleteContainerRepositoryWorker).to receive(:perform_async).with(user.id, repository.id)
+
+ delete_repository(repository)
+ end
end
end
end
diff --git a/spec/controllers/projects/registry/tags_controller_spec.rb b/spec/controllers/projects/registry/tags_controller_spec.rb
index 8da0d217e9e..5ab32b7d81d 100644
--- a/spec/controllers/projects/registry/tags_controller_spec.rb
+++ b/spec/controllers/projects/registry/tags_controller_spec.rb
@@ -38,6 +38,12 @@ describe Projects::Registry::TagsController do
expect(response).to match_response_schema('registry/tags')
expect(response).to include_pagination_headers
end
+
+ it 'tracks the event' do
+ expect(Gitlab::Tracking).to receive(:event).with(anything, 'list_tags', {})
+
+ get_tags
+ end
end
context 'when user can read the registry' do
@@ -100,6 +106,13 @@ describe Projects::Registry::TagsController do
destroy_tag('test.')
end
+
+ it 'tracks the event' do
+ expect_delete_tags(%w[test.])
+ expect(controller).to receive(:track_event).with(:delete_tag)
+
+ destroy_tag('test.')
+ end
end
end
@@ -134,6 +147,13 @@ describe Projects::Registry::TagsController do
bulk_destroy_tags(tags)
end
+
+ it 'tracks the event' do
+ expect_delete_tags(tags)
+ expect(Gitlab::Tracking).to receive(:event).with(anything, 'delete_tag_bulk', {})
+
+ bulk_destroy_tags(tags)
+ end
end
end
diff --git a/spec/lib/gitlab/pages_client_spec.rb b/spec/lib/gitlab/pages_client_spec.rb
deleted file mode 100644
index 84381843221..00000000000
--- a/spec/lib/gitlab/pages_client_spec.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Gitlab::PagesClient do
- subject { described_class }
-
- describe '.token' do
- it 'returns the token as it is on disk' do
- pending 'add omnibus support for generating the secret file https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466'
- expect(subject.token).to eq(File.read('.gitlab_pages_secret'))
- end
- end
-
- describe '.read_or_create_token' do
- subject { described_class.read_or_create_token }
- let(:token_path) { 'tmp/tests/gitlab-pages-secret' }
- before do
- allow(described_class).to receive(:token_path).and_return(token_path)
- FileUtils.rm_f(token_path)
- end
-
- it 'uses the existing token file if it exists' do
- secret = 'existing secret'
- File.write(token_path, secret)
-
- subject
- expect(described_class.token).to eq(secret)
- end
-
- it 'creates one if none exists' do
- pending 'add omnibus support for generating the secret file https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466'
-
- old_token = described_class.token
- # sanity check
- expect(File.exist?(token_path)).to eq(false)
-
- subject
- expect(described_class.token.bytesize).to eq(64)
- expect(described_class.token).not_to eq(old_token)
- end
- end
-
- describe '.write_token' do
- let(:token_path) { 'tmp/tests/gitlab-pages-secret' }
- before do
- allow(described_class).to receive(:token_path).and_return(token_path)
- FileUtils.rm_f(token_path)
- end
-
- it 'writes the secret' do
- new_secret = 'hello new secret'
- expect(File.exist?(token_path)).to eq(false)
-
- described_class.send(:write_token, new_secret)
-
- expect(File.read(token_path)).to eq(new_secret)
- end
-
- it 'does nothing if the file already exists' do
- existing_secret = 'hello secret'
- File.write(token_path, existing_secret)
-
- described_class.send(:write_token, 'new secret')
-
- expect(File.read(token_path)).to eq(existing_secret)
- end
- end
-
- describe '.load_certificate' do
- subject { described_class.load_certificate }
- before do
- allow(described_class).to receive(:config).and_return(config)
- end
-
- context 'with no certificate in the config' do
- let(:config) { double(:config, certificate: '') }
-
- it 'does not set @certificate' do
- subject
-
- expect(described_class.certificate).to be_nil
- end
- end
-
- context 'with a certificate path in the config' do
- let(:certificate_path) { 'tmp/tests/fake-certificate' }
- let(:config) { double(:config, certificate: certificate_path) }
-
- it 'sets @certificate' do
- certificate_data = "--- BEGIN CERTIFICATE ---\nbla\n--- END CERTIFICATE ---\n"
- File.write(certificate_path, certificate_data)
- subject
-
- expect(described_class.certificate).to eq(certificate_data)
- end
- end
- end
-
- describe '.request_kwargs' do
- let(:token) { 'secret token' }
- let(:auth_header) { 'Bearer c2VjcmV0IHRva2Vu' }
- before do
- allow(described_class).to receive(:token).and_return(token)
- end
-
- context 'without timeout' do
- it { expect(subject.send(:request_kwargs, nil)[:metadata]['authorization']).to eq(auth_header) }
- end
-
- context 'with timeout' do
- let(:timeout) { 1.second }
-
- it 'still sets the authorization header' do
- expect(subject.send(:request_kwargs, timeout)[:metadata]['authorization']).to eq(auth_header)
- end
-
- it 'sets a deadline value' do
- now = Time.now
- deadline = subject.send(:request_kwargs, timeout)[:deadline]
-
- expect(deadline).to be_between(now, now + 2 * timeout)
- end
- end
- end
-
- describe '.stub' do
- before do
- allow(described_class).to receive(:address).and_return('unix:/foo/bar')
- end
-
- it { expect(subject.send(:stub, :health_check)).to be_a(Grpc::Health::V1::Health::Stub) }
- end
-
- describe '.address' do
- subject { described_class.send(:address) }
-
- before do
- allow(described_class).to receive(:config).and_return(config)
- end
-
- context 'with a unix: address' do
- let(:config) { double(:config, address: 'unix:/foo/bar') }
-
- it { expect(subject).to eq('unix:/foo/bar') }
- end
-
- context 'with a tcp:// address' do
- let(:config) { double(:config, address: 'tcp://localhost:1234') }
-
- it { expect(subject).to eq('localhost:1234') }
- end
- end
-
- describe '.grpc_creds' do
- subject { described_class.send(:grpc_creds) }
-
- before do
- allow(described_class).to receive(:config).and_return(config)
- end
-
- context 'with a unix: address' do
- let(:config) { double(:config, address: 'unix:/foo/bar') }
-
- it { expect(subject).to eq(:this_channel_is_insecure) }
- end
-
- context 'with a tcp:// address' do
- let(:config) { double(:config, address: 'tcp://localhost:1234') }
-
- it { expect(subject).to be_a(GRPC::Core::ChannelCredentials) }
- end
- end
-end
diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb
index 8fc3b7e4c40..2aeb7e5a990 100644
--- a/spec/models/clusters/applications/prometheus_spec.rb
+++ b/spec/models/clusters/applications/prometheus_spec.rb
@@ -175,6 +175,18 @@ describe Clusters::Applications::Prometheus do
expect(subject).to be_rbac
end
+ describe '#predelete' do
+ let(:knative) { create(:clusters_applications_knative, :updated ) }
+ let(:prometheus) { create(:clusters_applications_prometheus, cluster: knative.cluster) }
+
+ subject { prometheus.uninstall_command.predelete }
+
+ it 'deletes knative metrics' do
+ metrics_config = Clusters::Applications::Knative::METRICS_CONFIG
+ is_expected.to include("kubectl delete -f #{metrics_config} --ignore-not-found")
+ end
+ end
+
context 'on a non rbac enabled cluster' do
before do
prometheus.cluster.platform_kubernetes.abac!
diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb
index 7e8bbedcf6d..8cfcd9befb3 100644
--- a/spec/presenters/ci/pipeline_presenter_spec.rb
+++ b/spec/presenters/ci/pipeline_presenter_spec.rb
@@ -176,6 +176,44 @@ describe Ci::PipelinePresenter do
end
end
+ describe '#all_related_merge_request_text' do
+ subject { presenter.all_related_merge_request_text }
+
+ context 'with zero related merge requests (branch pipeline)' do
+ it { is_expected.to eq('No related merge requests found.') }
+ end
+
+ context 'with one related merge request' do
+ let!(:mr_1) { create(:merge_request, project: project, source_project: project) }
+
+ it {
+ is_expected.to eq("1 related merge request: " \
+ "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>")
+ }
+ end
+
+ context 'with two related merge requests' do
+ let!(:mr_1) { create(:merge_request, project: project, source_project: project, target_branch: 'staging') }
+ let!(:mr_2) { create(:merge_request, project: project, source_project: project, target_branch: 'feature') }
+
+ it {
+ is_expected.to eq("2 related merge requests: " \
+ "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>, " \
+ "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>")
+ }
+ end
+ end
+
+ describe '#all_related_merge_requests' do
+ it 'memoizes the returned relation' do
+ query_count = ActiveRecord::QueryRecorder.new do
+ 2.times { presenter.send(:all_related_merge_requests).count }
+ end.count
+
+ expect(query_count).to eq(1)
+ end
+ end
+
describe '#link_to_merge_request' do
subject { presenter.link_to_merge_request }
diff --git a/spec/serializers/test_report_entity_spec.rb b/spec/serializers/test_report_entity_spec.rb
new file mode 100644
index 00000000000..5913d1c0208
--- /dev/null
+++ b/spec/serializers/test_report_entity_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe TestReportEntity do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports) }
+ let(:entity) { described_class.new(pipeline.test_reports) }
+
+ describe '#as_json' do
+ subject(:as_json) { entity.as_json }
+
+ it 'contains the total time' do
+ expect(as_json).to include(:total_time)
+ end
+
+ it 'contains the counts' do
+ expect(as_json).to include(:total_count, :success_count, :failed_count, :skipped_count, :error_count)
+ end
+
+ it 'contains the test suites' do
+ expect(as_json).to include(:test_suites)
+ expect(as_json[:test_suites].count).to eq(1)
+ end
+ end
+end
diff --git a/spec/serializers/test_suite_entity_spec.rb b/spec/serializers/test_suite_entity_spec.rb
new file mode 100644
index 00000000000..54dca3214b7
--- /dev/null
+++ b/spec/serializers/test_suite_entity_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe TestSuiteEntity do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports) }
+ let(:entity) { described_class.new(pipeline.test_reports.test_suites.values.first) }
+
+ describe '#as_json' do
+ subject(:as_json) { entity.as_json }
+
+ it 'contains the suite name' do
+ expect(as_json).to include(:name)
+ end
+
+ it 'contains the total time' do
+ expect(as_json).to include(:total_time)
+ end
+
+ it 'contains the counts' do
+ expect(as_json).to include(:total_count, :success_count, :failed_count, :skipped_count, :error_count)
+ end
+
+ it 'contains the test cases' do
+ expect(as_json).to include(:test_cases)
+ expect(as_json[:test_cases].count).to eq(4)
+ end
+ end
+end
diff --git a/spec/support/shared_examples/relative_positioning_shared_examples.rb b/spec/support/shared_examples/relative_positioning_shared_examples.rb
index b7382cea93c..99e62ebf422 100644
--- a/spec/support/shared_examples/relative_positioning_shared_examples.rb
+++ b/spec/support/shared_examples/relative_positioning_shared_examples.rb
@@ -84,6 +84,22 @@ RSpec.shared_examples 'a class that supports relative positioning' do
expect(item1.relative_position).to be < item2.relative_position
end
+
+ context 'when there is no space' do
+ let(:item3) { create(factory, default_params) }
+
+ before do
+ item1.update(relative_position: 1000)
+ item2.update(relative_position: 1001)
+ item3.update(relative_position: 1002)
+ end
+
+ it 'moves items correctly' do
+ item3.move_before(item2)
+
+ expect(item3.relative_position).to be_between(item1.reload.relative_position, item2.reload.relative_position).exclusive
+ end
+ end
end
describe '#move_after' do
@@ -94,6 +110,22 @@ RSpec.shared_examples 'a class that supports relative positioning' do
expect(item1.relative_position).to be > item2.relative_position
end
+
+ context 'when there is no space' do
+ let(:item3) { create(factory, default_params) }
+
+ before do
+ item1.update(relative_position: 1000)
+ item2.update(relative_position: 1001)
+ item3.update(relative_position: 1002)
+ end
+
+ it 'moves items correctly' do
+ item1.move_after(item2)
+
+ expect(item1.relative_position).to be_between(item2.reload.relative_position, item3.reload.relative_position).exclusive
+ end
+ end
end
describe '#move_to_end' do
@@ -196,7 +228,7 @@ RSpec.shared_examples 'a class that supports relative positioning' do
new_item.move_between(item1, item2)
- expect(new_item.relative_position).to be_between(item1.relative_position, item2.relative_position)
+ expect(new_item.relative_position).to be_between(item1.relative_position, item2.relative_position).exclusive
end
it 'uses rebalancing if there is no place' do
@@ -208,7 +240,7 @@ RSpec.shared_examples 'a class that supports relative positioning' do
new_item.move_between(item2, item3)
new_item.save!
- expect(new_item.relative_position).to be_between(item2.relative_position, item3.relative_position)
+ expect(new_item.relative_position).to be_between(item2.relative_position, item3.relative_position).exclusive
expect(item1.reload.relative_position).not_to eq(100)
end