diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-29 06:09:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-29 06:09:06 +0000 |
commit | 401607eed7e0918553e985e1f12e99dc1ff9e948 (patch) | |
tree | 75b1b125b6281d762594aff4acdea4df6e8ff4e2 /qa | |
parent | 7a78c31f67b83bee08ec73eae8f935803b406deb (diff) | |
download | gitlab-ce-401607eed7e0918553e985e1f12e99dc1ff9e948.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/resource/project.rb | 25 | ||||
-rw-r--r-- | qa/qa/specs/features/api/1_manage/migration/gitlab_migration_release_spec.rb | 71 |
2 files changed, 94 insertions, 2 deletions
diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index 5a66b8f1567..2db4f4b5f65 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -210,6 +210,10 @@ module QA "#{api_get_path}/wikis" end + def api_releases_path + "#{api_get_path}/releases" + end + def api_post_body post_body = { name: name, @@ -394,9 +398,22 @@ module QA api_post_to(api_wikis_path, title: title, content: content) end + def releases + response = api_get_from(api_releases_path) + parse_body(response) + end + + def create_release(tag, ref = default_branch, **params) + api_post_to(api_releases_path, tag_name: tag, ref: ref, **params) + end + # Uses the API to wait until a pull mirroring update is successful (pull mirroring is treated as an import) def wait_for_pull_mirroring - mirror_succeeded = Support::Retrier.retry_until(max_duration: 180, raise_on_failure: false, sleep_interval: 1) do + mirror_succeeded = Support::Retrier.retry_until( + max_duration: 180, + raise_on_failure: false, + sleep_interval: 1 + ) do reload! api_resource[:import_status] == "finished" end @@ -407,7 +424,11 @@ module QA def remove_via_api! super - Support::Retrier.retry_until(max_duration: 60, sleep_interval: 1, message: "Waiting for #{self.class.name} to be removed") do + Support::Retrier.retry_until( + max_duration: 60, + sleep_interval: 1, + message: "Waiting for #{self.class.name} to be removed" + ) do !exists? rescue InternalServerError # Retry on transient errors that are likely to be due to race conditions between concurrent delete operations diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_release_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_release_spec.rb new file mode 100644 index 00000000000..201b8efdf6a --- /dev/null +++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_release_spec.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +require_relative 'gitlab_project_migration_common' + +module QA + RSpec.describe 'Manage' do + describe 'Gitlab migration' do + include_context 'with gitlab project migration' + + context 'with release' do + let(:tag) { 'v0.0.1' } + let(:source_project_with_readme) { true } + + let(:milestone) do + Resource::ProjectMilestone.fabricate_via_api! do |resource| + resource.project = source_project + resource.api_client = api_client + end + end + + let(:source_release) { comparable_release(source_project.releases.find { |r| r[:tag_name] == tag }) } + let(:imported_release) { comparable_release(imported_releases.find { |r| r[:tag_name] == tag }) } + let(:imported_releases) { imported_project.releases } + + # Update release object to be comparable + # + # Convert objects with project specific attributes like paths and urls to be comparable + # + # @param [Hash] release + # @return [Hash] + def comparable_release(release) + release&.except(:_links, :evidences)&.merge( + { + author: release[:author].except(:web_url), + commit: release[:commit].except(:web_url), + commit_path: release[:commit_path].split("/-/").last, + tag_path: release[:tag_path].split("/-/").last, + assets: release[:assets].merge({ + sources: release.dig(:assets, :sources).map do |source| + source.merge({ url: source[:url].split("/-/").last }) + end + }), + milestones: release[:milestones].map do |milestone| + milestone.except(:id, :project_id).merge({ web_url: milestone[:web_url].split("/-/").last }) + end + # TODO: Add back evidence testing once implemented + # https://gitlab.com/gitlab-org/gitlab/-/issues/360567 + # evidences: release[:evidences].map do |evidence| + # evidence.merge({ filepath: evidence[:filepath].split("/-/").last }) + # end + } + ) + end + + before do + source_project.create_release(tag, milestones: [milestone.title]) + end + + it( + 'successfully imports project release', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/360243' + ) do + expect_import_finished + + expect(imported_releases.size).to eq(1), "Expected to have 1 migrated release" + expect(imported_release).to eq(source_release) + end + end + end + end +end |