Codebase list ruby-beaker-hostgenerator / ba83c23
(PE-21479) Drop use of pe_family/pe_upgrade_family The pe_family and pe_upgrade_family environment variables were only being used as a means of signaling that we want pe_dir to be archives/releases. (If pe_version and pe_family were equal, we'd return archives/releases for pe_dir). This behavior was changed in the previous commit to instead base the tarball source on the version string format. The only other behavior that passing family had was that if either verison or family were nil, pe_dir would be nil. So theoretically, if you only set pe_version to some valid version, you would get a beaker config with no pe_dir set, and Beaker could then set pe_dir based on BEAKER_PE_DIR or pe_dist_dir environment variables. This commit removes family so that we can clean up pipelines which would otherwise be setting pe_family just for the purpose of avoiding this behavior. It is potentially a breaking change if someone was relying on the absence of pe_family to allow Beaker to set pe_dir as mentioned above. Josh Partlow 6 years ago
3 changed file(s) with 25 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
1919 ENV['pe_version']
2020 end
2121
22 def pe_family
23 ENV['pe_family']
24 end
25
2622 def pe_upgrade_version
2723 ENV['pe_upgrade_version']
2824 end
2925
30 def pe_upgrade_family
31 ENV['pe_upgrade_family']
32 end
33
34 def pe_dir(version, family)
35 # XXX family is no longer used, but it is possible that a job relied on the
36 # behavior that not setting family would return nil for pe_dir(), allowing beaker
37 # to pick up from ENV['BEAKER_PE_DIR'] or ENV['pe_dist_dir']
38 # https://github.com/puppetlabs/beaker/blob/3f52daf76b8b0a47a101a8ea76fbe4ace1e8efaf/lib/beaker/options/presets.rb#L25
39 if version && family
40 base_regex = '(\A\d+\.\d+)\.\d+'
41 source = case version
42 when /#{base_regex}\Z/
43 then "#{PE_TARBALL_SERVER}/archives/releases/#{version}/"
44 when /#{base_regex}-rc\d+\Z/
45 then "#{PE_TARBALL_SERVER}/archives/internal/%s/"
46 when /#{base_regex}-.*PEZ_.*/
47 then "#{PE_TARBALL_SERVER}/%s/feature/ci-ready"
48 when /#{base_regex}-.*/
49 then "#{PE_TARBALL_SERVER}/%s/ci-ready"
50 end
51 return sprintf(source, $1)
26 def pe_dir(version)
27 return if version.nil?
28
29 base_regex = '(\A\d+\.\d+)\.\d+'
30 source = case version
31 when /#{base_regex}\Z/
32 then "#{PE_TARBALL_SERVER}/archives/releases/#{version}/"
33 when /#{base_regex}-rc\d+\Z/
34 then "#{PE_TARBALL_SERVER}/archives/internal/%s/"
35 when /#{base_regex}-.*PEZ_.*/
36 then "#{PE_TARBALL_SERVER}/%s/feature/ci-ready"
37 when /#{base_regex}-.*/
38 then "#{PE_TARBALL_SERVER}/%s/ci-ready"
5239 end
40 return sprintf(source, $1)
5341 end
5442
5543 PE_USE_WIN32 = ENV['pe_use_win32']
6452
6553 def base_host_config(options)
6654 {
67 'pe_dir' => options[:pe_dir] || pe_dir(pe_version, pe_family),
55 'pe_dir' => options[:pe_dir] || pe_dir(pe_version),
6856 'pe_ver' => options[:pe_ver] || pe_version,
69 'pe_upgrade_dir' => options[:pe_upgrade_dir] || pe_dir(pe_upgrade_version, pe_upgrade_family),
57 'pe_upgrade_dir' => options[:pe_upgrade_dir] || pe_dir(pe_upgrade_version),
7058 'pe_upgrade_ver' => options[:pe_upgrade_ver] || pe_upgrade_version,
7159 }
7260 end
66 module Utils
77 module_function
88
9 def pe_dir(version, family)
10 BeakerHostGenerator::Data.pe_dir(version, family)
9 def pe_dir(version, family = nil)
10 BeakerHostGenerator::Data.pe_dir(version)
1111 end
1212
1313 def fixup_node(cfg)
9696 let(:rc_version) { '2017.3.0-rc4' }
9797
9898 it "returns ci-ready for a dev version" do
99 expect(BeakerHostGenerator::Data.pe_dir(dev_version, '2017.3')).to match(%r{2017\.3/ci-ready})
100 expect(BeakerHostGenerator::Data.pe_dir(dev_version_no_rc, '2017.3')).to match(%r{2017\.3/ci-ready})
101 end
102
103 it "returns ci-ready even if pe_family matches" do
104 expect(BeakerHostGenerator::Data.pe_dir(dev_version, dev_version)).to match(%r{2017\.3/ci-ready})
105 expect(BeakerHostGenerator::Data.pe_dir(dev_version_no_rc, dev_version_no_rc)).to match(%r{2017\.3/ci-ready})
99 expect(BeakerHostGenerator::Data.pe_dir(dev_version)).to match(%r{2017\.3/ci-ready})
100 expect(BeakerHostGenerator::Data.pe_dir(dev_version_no_rc)).to match(%r{2017\.3/ci-ready})
106101 end
107102
108103 it "returns archives/releases for a release version" do
109 expect(BeakerHostGenerator::Data.pe_dir(release_version, '2017.3')).to match(%r{archives/releases/2017\.2})
104 expect(BeakerHostGenerator::Data.pe_dir(release_version)).to match(%r{archives/releases/2017\.2})
110105 end
111106
112107 it "returns archives/internal for an rc version" do
113 expect(BeakerHostGenerator::Data.pe_dir(rc_version, '2017.3')).to match(%r{archives/internal/2017\.3})
114 end
115
116 it "returns archives/internal for an rc version even if pe_family matches" do
117 expect(BeakerHostGenerator::Data.pe_dir(rc_version, rc_version)).to match(%r{archives/internal/2017\.3})
108 expect(BeakerHostGenerator::Data.pe_dir(rc_version)).to match(%r{archives/internal/2017\.3})
118109 end
119110
120111 it "returns feature/ci-ready for a PEZ version" do
121 expect(BeakerHostGenerator::Data.pe_dir(pez_version, '2017.3')).to match(%r{2017\.3/feature/ci-ready})
112 expect(BeakerHostGenerator::Data.pe_dir(pez_version)).to match(%r{2017\.3/feature/ci-ready})
122113 end
123114
124 it "(backwards compatible) returns archives/release if pe_version matches pe_family" do
125 expect(BeakerHostGenerator::Data.pe_dir(release_version, release_version)).to match(%r{archives/releases/2017\.2\.2})
126 end
127
128 it "(backwords compatible) returns nil if eiher argument is nil" do
129 expect(BeakerHostGenerator::Data.pe_dir(nil, '2017.3')).to be_nil
130 expect(BeakerHostGenerator::Data.pe_dir(dev_version, nil)).to be_nil
115 it "returns nil if version is nil" do
116 expect(BeakerHostGenerator::Data.pe_dir(nil)).to be_nil
131117 end
132118 end
133119 end