Class: Gitlab::QA::Support::GitlabUpgradePath

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/support/gitlab_upgrade_path.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_version, semver_component, edition) ⇒ GitlabUpgradePath

Get upgrade path between N - 1 and current version not including current release

Parameters:

  • current_version (String)
  • semver_component (String)

    version number component for previous version detection - major|minor|patch

  • edition (String)

    GitLab edition - ee or ce



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/qa/support/gitlab_upgrade_path.rb', line 15

def initialize(current_version, semver_component, edition)
  @logger = Runtime::Logger.logger

  unless current_version.match?(GitlabVersionInfo::VERSION_PATTERN)
    logger.error("Invalid 'current_version' format: #{current_version}. Expected format: MAJOR.MINOR.PATCH (e.g., 17.8.2)")
    exit 1
  end

  @version_info = GitlabVersionInfo.new(current_version, edition)
  @current_version = Gem::Version.new(current_version.match(GitlabVersionInfo::VERSION_PATTERN)[:version]) # Extract version without postfixes like pre or ee
  @semver_component = semver_component
  @edition = edition
end

Instance Method Details

#fetchArray<QA::Release>

Get upgrade path between releases

Return array with only previous version for updates from previous minor, patch versions

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gitlab/qa/support/gitlab_upgrade_path.rb', line 34

def fetch
  case semver_component
  when "patch"
    patch_upgrade_path
  when "minor"
    minor_upgrade_path
  when "major"
    major_upgrade_path
  when "from_patch"
    from_patch_upgrade_path
  else
    raise ArgumentError, "Unknown semver component: #{semver_component}"
  end
rescue GitlabVersionInfo::VersionNotFoundError
  logger.error("Failed to construct gitlab upgrade path")
  raise
end