vanagon 0.8.2 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/bin/build +1 -1
  4. data/lib/vanagon/component/dsl.rb +14 -24
  5. data/lib/vanagon/component/source/git.rb +1 -6
  6. data/lib/vanagon/component/source/http.rb +7 -0
  7. data/lib/vanagon/component/source/local.rb +8 -2
  8. data/lib/vanagon/driver.rb +31 -11
  9. data/lib/vanagon/engine/always_be_scheduling.rb +92 -0
  10. data/lib/vanagon/engine/base.rb +1 -2
  11. data/lib/vanagon/engine/hardware.rb +1 -1
  12. data/lib/vanagon/engine/pooler.rb +42 -10
  13. data/lib/vanagon/optparse.rb +1 -0
  14. data/lib/vanagon/platform.rb +10 -7
  15. data/lib/vanagon/platform/dsl.rb +13 -2
  16. data/lib/vanagon/project.rb +41 -3
  17. data/lib/vanagon/project/dsl.rb +9 -4
  18. data/lib/vanagon/utilities.rb +10 -13
  19. data/resources/Makefile.erb +1 -1
  20. data/resources/rpm/project.spec.erb +9 -0
  21. data/spec/fixtures/files/fake_dir/fake_file.txt +0 -0
  22. data/spec/fixtures/files/fake_nested_dir/fake_dir/fake_file.txt +0 -0
  23. data/spec/lib/vanagon/component/dsl_spec.rb +51 -2
  24. data/spec/lib/vanagon/component/source/git_spec.rb +8 -0
  25. data/spec/lib/vanagon/component/source/http_spec.rb +15 -15
  26. data/spec/lib/vanagon/component/source/local_spec.rb +17 -1
  27. data/spec/lib/vanagon/component/source_spec.rb +1 -1
  28. data/spec/lib/vanagon/driver_spec.rb +33 -1
  29. data/spec/lib/vanagon/engine/always_be_scheduling_spec.rb +84 -0
  30. data/spec/lib/vanagon/engine/pooler_spec.rb +80 -16
  31. data/spec/lib/vanagon/platform/dsl_spec.rb +14 -0
  32. data/spec/lib/vanagon/platform/windows_spec.rb +2 -2
  33. data/spec/lib/vanagon/project_spec.rb +79 -5
  34. data/spec/lib/vanagon/utilities_spec.rb +5 -0
  35. data/spec/spec_helper.rb +22 -2
  36. metadata +29 -24
@@ -68,8 +68,8 @@ class Vanagon
68
68
  # We only magically handle get_ methods, any other methods just get the
69
69
  # standard method_missing treatment.
70
70
  #
71
- def method_missing(method, *args)
72
- attribute_match = method.to_s.match(/get_(.*)/)
71
+ def method_missing(method_name, *args)
72
+ attribute_match = method_name.to_s.match(/get_(.*)/)
73
73
  if attribute_match
74
74
  attribute = attribute_match.captures.first
75
75
  else
@@ -79,6 +79,10 @@ class Vanagon
79
79
  @platform.send(attribute)
80
80
  end
81
81
 
82
+ def respond_to_missing?(method_name, include_private = false)
83
+ method_name.to_s.start_with?('get_') || super
84
+ end
85
+
82
86
  # Set the path to make for the platform
83
87
  #
84
88
  # @param make_cmd [String] Full path to the make command for the platform
@@ -221,6 +225,13 @@ class Vanagon
221
225
  self.vmpooler_template(name)
222
226
  end
223
227
 
228
+ # Set the name of this platform as always-be-scheduling (ABS) expects it
229
+ #
230
+ # @param name [String] name of the platform to request from always-be-scheduling
231
+ def abs_resource_name(name)
232
+ @platform.abs_resource_name = name
233
+ end
234
+
224
235
  # Set the name of the docker image to use
225
236
  #
226
237
  # @param name [String] name of the docker image to use
@@ -54,10 +54,15 @@ class Vanagon
54
54
  end
55
55
 
56
56
  # Magic getter to retrieve settings in the project
57
- def method_missing(method, *args)
58
- if @settings.key?(method)
59
- return @settings[method]
57
+ def method_missing(method_name, *args)
58
+ if @settings.key?(method_name)
59
+ return @settings[method_name]
60
60
  end
61
+ super
62
+ end
63
+
64
+ def respond_to_missing?(method_name, include_private = false)
65
+ @settings.key?(method_name) || super
61
66
  end
62
67
 
63
68
  # Collects all sources and patches into the provided workdir
@@ -82,6 +87,39 @@ class Vanagon
82
87
  files.flatten.uniq
83
88
  end
84
89
 
90
+ # Returns a filtered out set of components only including those
91
+ # components necessary to build a specific component. This is a
92
+ # recursive function that will call itself until it gets to a
93
+ # component with no build requirements
94
+ #
95
+ # @param name [String] name of component to add. must be present in configdir/components and named $name.rb currently
96
+ # @return [Array] array of Vanagon::Component including only those required to build "name", or [] if there are none
97
+ def filter_component(name)
98
+ filtered_component = get_component(name)
99
+ return [] if filtered_component.nil?
100
+ included_components = [filtered_component]
101
+
102
+ unless filtered_component.build_requires.empty?
103
+ filtered_component.build_requires.each do |build_requirement|
104
+ unless get_component(build_requirement).nil?
105
+ included_components += filter_component(build_requirement)
106
+ end
107
+ end
108
+ end
109
+ included_components.uniq
110
+ end
111
+
112
+ # Gets the component with component.name = "name" from the list
113
+ # of project.components
114
+ #
115
+ # @param [String] component name
116
+ # @return [Vanagon::Component] the component with component.name = "name"
117
+ def get_component(name)
118
+ comps = @components.select { |comp| comp.name.to_s == name.to_s }
119
+ raise "ERROR: two or more components with the same name: #{comps.first.name}" if comps.size > 1
120
+ comps.first
121
+ end
122
+
85
123
  # Collects all of the requires for both the project and its components
86
124
  #
87
125
  # @return [Array] array of runtime requirements for the project
@@ -44,18 +44,23 @@ class Vanagon
44
44
  # We only magically handle get_ methods, any other methods just get the
45
45
  # standard method_missing treatment.
46
46
  #
47
- def method_missing(method, *args)
48
- attribute_match = method.to_s.match(/get_(.*)/)
47
+ def method_missing(method_name, *args)
48
+ attribute_match = method_name.to_s.match(/get_(.*)/)
49
49
  if attribute_match
50
50
  attribute = attribute_match.captures.first
51
51
  @project.send(attribute)
52
- elsif @project.settings.key?(method)
53
- return @project.settings[method]
52
+ elsif @project.settings.key?(method_name)
53
+ return @project.settings[method_name]
54
54
  else
55
55
  super
56
56
  end
57
57
  end
58
58
 
59
+ def respond_to_missing?(method_name, include_private = false)
60
+ method_name.to_s.start_with?('get_') || @project.settings.key?(method_name) || super
61
+ end
62
+
63
+
59
64
  # Sets a key value pair on the settings hash of the project
60
65
  #
61
66
  # @param name [String] name of the setting
@@ -16,6 +16,7 @@ class Vanagon
16
16
 
17
17
  # Utility to get the md5 sum of a file
18
18
  #
19
+ # @deprecated Please use #get_sum instead, this will be removed in a future vanagon release.
19
20
  # @param file [String] file to md5sum
20
21
  # @return [String] md5sum of the given file
21
22
  def get_md5sum(file)
@@ -25,21 +26,17 @@ class Vanagon
25
26
  # Generic file summing utility
26
27
  #
27
28
  # @param file [String] file to sum
28
- # @param type [String] type of sum to provide
29
+ # @param type [String] type of sum to provide, defaults to md5
29
30
  # @return [String] sum of the given file
30
31
  # @raise [RuntimeError] raises an exception if the given sum type is not supported
31
- def get_sum(file, type)
32
- case type.downcase
33
- when 'md5'
34
- Digest::MD5.file(file).hexdigest.to_s
35
- when 'sha256'
36
- Digest::SHA256.file(file).hexdigest.to_s
37
- when 'sha512'
38
- Digest::SHA512.file(file).hexdigest.to_s
39
- else
40
- fail "Don't know how to produce a sum of type: '#{type}' for '#{file}'."
41
- end
42
- end
32
+ def get_sum(file, type = 'md5')
33
+ Digest.const_get(type.upcase).file(file).hexdigest.to_s
34
+
35
+ # If Digest::const_get fails, it'll raise a LoadError when it tries to
36
+ # pull in the subclass `type`. We catch that error, and fail instead.
37
+ rescue LoadError
38
+ fail "Don't know how to produce a sum of type: '#{type}' for '#{file}'"
39
+ end
43
40
 
44
41
  # Simple wrapper around Net::HTTP. Will make a request of the given type to
45
42
  # the given url and return the body as parsed by JSON.
@@ -36,7 +36,7 @@ file-list: file-list-before-build <%= @name %>-project
36
36
  <%- end -%>
37
37
 
38
38
  <%- if @bill_of_materials -%>
39
- <%= @bill_of_materials %>:
39
+ <%= @bill_of_materials.path %>:
40
40
  mkdir -p '<%= @bill_of_materials.path %>'
41
41
  mv bill-of-materials '<%= @bill_of_materials.path %>'
42
42
  <%- end -%>
@@ -48,6 +48,15 @@ Autoreq: 0
48
48
  <%- get_requires.each do |requires| -%>
49
49
  Requires: <%= requires %>
50
50
  <%- end -%>
51
+ # All rpm packages built by vanagon have the pre-/post-install script
52
+ # boilerplates (defined below). These require `mkdir` and `touch` but previously
53
+ # did not specify a dependency on these.
54
+ # In the future, we will supress pre/post scripts completely if there's nothing
55
+ # specified by the project or the components.
56
+ Requires(pre): /bin/mkdir
57
+ Requires(pre): /bin/touch
58
+ Requires(post): /bin/mkdir
59
+ Requires(post): /bin/touch
51
60
  <%- if has_services? -%>
52
61
  <%- if @platform.servicetype == "systemd" -%>
53
62
  <%- if @platform.is_sles? -%>
File without changes
@@ -53,15 +53,64 @@ end" }
53
53
  plat._platform
54
54
  }
55
55
 
56
-
57
-
58
56
  let(:platform) { double(Vanagon::Platform) }
59
57
 
58
+ # These TOTALLY VALID sums are computed against a passage from
59
+ # "The Hitchhiker's Guide to the Galaxy", by Douglas Adams (1979).
60
+ # Specifically, about humans assuming they are smarter than dolphins
61
+ # for exactly the same reason dolphins assume they are smart than
62
+ # humans. This seemed appropriate after the checksum refactoring
63
+ # broke all checksums and we discovered that they were untested.
64
+ let(:dummy_md5_sum) { "08b55473b59d2b43af8b61c9512ef5c6" }
65
+ let(:dummy_sha1_sum) { "fdaa03c3f506d7b71635f2c32dfd41b0cc8b904f" }
66
+ let(:dummy_sha256_sum) { "fd9c922702eb2e2fb26376c959753f0fc167bb6bc99c79262fcff7bcc8b34be1" }
67
+ let(:dummy_sha512_sum) { "8feda1e9896be618dd6c65120d10afafce93888df8569c598f52285083c23befd1477da5741939d4eae042f822e45ca2e45d8d4d18cf9224b7acaf71d883841e" }
68
+
60
69
  before do
61
70
  allow(platform).to receive(:install).and_return('install')
62
71
  allow(platform).to receive(:copy).and_return('cp')
63
72
  end
64
73
 
74
+ describe "#md5sum" do
75
+ it "sets a checksum value & type correctly" do
76
+ comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
77
+ comp.md5sum(dummy_md5_sum)
78
+
79
+ expect(comp._component.options[:sum]).to eq(dummy_md5_sum)
80
+ expect(comp._component.options[:sum_type]).to eq('md5')
81
+ end
82
+ end
83
+
84
+ describe "#sha1sum" do
85
+ it "sets a checksum value & type correctly" do
86
+ comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
87
+ comp.sha1sum(dummy_sha1_sum)
88
+
89
+ expect(comp._component.options[:sum]).to eq(dummy_sha1_sum)
90
+ expect(comp._component.options[:sum_type]).to eq('sha1')
91
+ end
92
+ end
93
+
94
+ describe "#sha256sum" do
95
+ it "sets a checksum value & type correctly" do
96
+ comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
97
+ comp.sha256sum(dummy_sha256_sum)
98
+
99
+ expect(comp._component.options[:sum]).to eq(dummy_sha256_sum)
100
+ expect(comp._component.options[:sum_type]).to eq('sha256')
101
+ end
102
+ end
103
+
104
+ describe "#sha512sum" do
105
+ it "sets a checksum value & type correctly" do
106
+ comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
107
+ comp.sha512sum(dummy_sha512_sum)
108
+
109
+ expect(comp._component.options[:sum]).to eq(dummy_sha512_sum)
110
+ expect(comp._component.options[:sum_type]).to eq('sha512')
111
+ end
112
+ end
113
+
65
114
  describe '#load_from_json' do
66
115
  it "sets the ref and url based on the json fixture" do
67
116
  comp = Vanagon::Component::DSL.new('test-fixture', {}, {})
@@ -32,6 +32,14 @@ describe "Vanagon::Component::Source::Git" do
32
32
  end
33
33
  end
34
34
 
35
+ describe "#ref" do
36
+ it "returns a default value of HEAD when no explicit Git reference is provided" do
37
+ git_source = klass.new(url, workdir: workdir)
38
+ expect(git_source.ref)
39
+ .to eq('HEAD')
40
+ end
41
+ end
42
+
35
43
  describe "#fetch" do
36
44
  it "raises an error on checkout failure with a bad SHA" do
37
45
  expect { klass.new("#{url}", ref: bad_sha, workdir: workdir).fetch }
@@ -12,7 +12,14 @@ describe "Vanagon::Component::Source::Http" do
12
12
  let (:md5sum) { 'abcdssasasa' }
13
13
  let (:sha256sum) { 'foobarbaz' }
14
14
  let (:sha512sum) { 'teststring' }
15
- let (:workdir) { "/tmp" }
15
+ let (:workdir) { Dir.mktmpdir }
16
+
17
+ describe "#initialize" do
18
+ it "fails with a bad sum_type" do
19
+ expect { Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir, sum_type: "md4") }
20
+ .to raise_error(RuntimeError)
21
+ end
22
+ end
16
23
 
17
24
  describe "#dirname" do
18
25
  it "returns the name of the tarball, minus extension for archives" do
@@ -30,17 +37,10 @@ describe "Vanagon::Component::Source::Http" do
30
37
  end
31
38
  end
32
39
 
33
- describe "verify" do
34
- it "fails with a bad sum_type" do
35
- http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir, sum_type: "md4")
36
- expect(http_source).to receive(:download).and_return(plaintext_filename)
37
- http_source.fetch
38
- expect{ http_source.verify }.to raise_error(RuntimeError)
39
- end
40
-
40
+ describe "#verify" do
41
41
  it "calls md5 digest when it's supposed to" do
42
- Digest::MD5.any_instance.stub(:file).and_return(Digest::MD5.new)
43
- Digest::MD5.any_instance.stub(:hexdigest).and_return(md5sum)
42
+ allow_any_instance_of(Digest::MD5).to receive(:file).and_return(Digest::MD5.new)
43
+ allow_any_instance_of(Digest::MD5).to receive(:hexdigest).and_return(md5sum)
44
44
  http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: md5sum, workdir: workdir, sum_type: "md5")
45
45
  expect(http_source).to receive(:download).and_return(plaintext_filename)
46
46
  http_source.fetch
@@ -48,8 +48,8 @@ describe "Vanagon::Component::Source::Http" do
48
48
  end
49
49
 
50
50
  it "calls sha256 digest when it's supposed to" do
51
- Digest::SHA256.any_instance.stub(:file).and_return(Digest::SHA256.new)
52
- Digest::SHA256.any_instance.stub(:hexdigest).and_return(sha256sum)
51
+ allow_any_instance_of(Digest::SHA256).to receive(:file).and_return(Digest::SHA256.new)
52
+ allow_any_instance_of(Digest::SHA256).to receive(:hexdigest).and_return(sha256sum)
53
53
  http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: sha256sum, workdir: workdir, sum_type: "sha256")
54
54
  expect(http_source).to receive(:download).and_return(plaintext_filename)
55
55
  http_source.fetch
@@ -57,8 +57,8 @@ describe "Vanagon::Component::Source::Http" do
57
57
  end
58
58
 
59
59
  it "calls sha512 digest when it's supposed to" do
60
- Digest::SHA512.any_instance.stub(:file).and_return(Digest::SHA512.new)
61
- Digest::SHA512.any_instance.stub(:hexdigest).and_return(sha512sum)
60
+ allow_any_instance_of(Digest::SHA512).to receive(:file).and_return(Digest::SHA512.new)
61
+ allow_any_instance_of(Digest::SHA512).to receive(:hexdigest).and_return(sha512sum)
62
62
  http_source = Vanagon::Component::Source::Http.new(plaintext_url, sum: sha512sum, workdir: workdir, sum_type: "sha512")
63
63
  expect(http_source).to receive(:download).and_return(plaintext_filename)
64
64
  http_source.fetch
@@ -4,7 +4,9 @@ describe "Vanagon::Component::Source::File" do
4
4
  let (:file_base) { 'file://spec/fixtures/files/fake_file_ext' }
5
5
  let (:tar_filename) { 'file://spec/fixtures/files/fake_dir.tar.gz' }
6
6
  let (:plaintext_filename) { 'file://spec/fixtures/files/fake_file.txt' }
7
- let (:workdir) { "/tmp" }
7
+ let (:workdir) { Dir.mktmpdir }
8
+ let (:simple_directory) { 'file://spec/fixtures/files/fake_dir/' }
9
+ let (:nested_directory) { 'file://spec/fixtures/files/fake_nested_dir/' }
8
10
 
9
11
  describe "#fetch" do
10
12
  it "puts the source file in to the workdir" do
@@ -12,6 +14,18 @@ describe "Vanagon::Component::Source::File" do
12
14
  file.fetch
13
15
  expect(File).to exist("#{workdir}/fake_file.txt")
14
16
  end
17
+
18
+ it "puts the source directory in to the workdir" do
19
+ file = Vanagon::Component::Source::Local.new(simple_directory, workdir: workdir)
20
+ file.fetch
21
+ expect(File).to exist("#{workdir}/fake_dir/fake_file.txt")
22
+ end
23
+
24
+ it "preserves nested directories when copying folders" do
25
+ file = Vanagon::Component::Source::Local.new(nested_directory, workdir: workdir)
26
+ file.fetch
27
+ expect(File).to exist("#{workdir}/fake_nested_dir/fake_dir/fake_file.txt")
28
+ end
15
29
  end
16
30
 
17
31
  describe "#dirname" do
@@ -20,7 +34,9 @@ describe "Vanagon::Component::Source::File" do
20
34
  file.fetch
21
35
  expect(file.dirname).to eq("fake_dir")
22
36
  end
37
+ end
23
38
 
39
+ describe "#ref" do
24
40
  it "returns the current directory for non-archive files" do
25
41
  file = Vanagon::Component::Source::Local.new(plaintext_filename, workdir: workdir)
26
42
  file.fetch
@@ -21,7 +21,7 @@ describe "Vanagon::Component::Source" do
21
21
 
22
22
  let(:ref) { "cafebeef" }
23
23
  let(:sum) { "abcd1234" }
24
- let(:workdir) { "/tmp" }
24
+ let(:workdir) { Dir.mktmpdir }
25
25
 
26
26
  let(:original_git_url) { "git://things.and.stuff/foo-bar.git" }
27
27
  let(:rewritten_git_url) { "git://things.end.stuff/foo-ber.git" }
@@ -54,6 +54,39 @@ describe 'Vanagon::Driver' do
54
54
  'engine' => 'hardware' })
55
55
  end
56
56
 
57
+ it 'returns the first build_host using the hardware engine when not using an engine, and not specifying an engine in the platform configuration' do
58
+ platform = eval_platform('aix-7.1-ppc', <<-END)
59
+ platform 'aix-7.1-ppc' do |plat|
60
+ plat.build_host ["pe-aix-71-01", "pe-aix-71-02"]
61
+ end
62
+ END
63
+
64
+ info = create_driver(platform).build_host_info
65
+
66
+ expect(info).to match({ 'name' => 'pe-aix-71-01',
67
+ 'engine' => 'hardware' })
68
+ end
69
+
70
+ it 'returns the platform and the always_be_scheduling engine when using the always_be_scheduling engine' do
71
+ platform = eval_platform('aix-7.1-ppc', <<-END)
72
+ platform 'aix-7.1-ppc' do |plat|
73
+ plat.build_host ["pe-aix-71-01", "pe-aix-71-02"]
74
+ end
75
+ END
76
+
77
+ info = create_driver(platform, :engine => 'always_be_scheduling').build_host_info
78
+
79
+ expect(info).to match({ 'name' => 'aix-7.1-ppc',
80
+ 'engine' => 'always_be_scheduling' })
81
+ end
82
+
83
+ it 'returns the vmpooler_template using the always_be_scheduling engine when using the always_be_scheduling engine' do
84
+ info = create_driver(redhat, :engine => 'always_be_scheduling').build_host_info
85
+
86
+ expect(info).to match({ 'name' => 'centos-7-x86_64',
87
+ 'engine' => 'always_be_scheduling' })
88
+ end
89
+
57
90
  it 'returns the docker_image using the docker engine' do
58
91
  platform = eval_platform('el-7-x86_64', <<-END)
59
92
  platform 'el-7-x86_64' do |plat|
@@ -85,4 +118,3 @@ describe 'Vanagon::Driver' do
85
118
  end
86
119
  end
87
120
  end
88
-
@@ -0,0 +1,84 @@
1
+ require 'vanagon/engine/always_be_scheduling'
2
+ require 'vanagon/driver'
3
+ require 'vanagon/platform'
4
+ require 'logger'
5
+
6
+ class Vanagon
7
+ class Driver
8
+ @@logger = Logger.new('/dev/null')
9
+ end
10
+ end
11
+
12
+ describe 'Vanagon::Engine::AlwaysBeScheduling' do
13
+ let (:platform) {
14
+ plat = Vanagon::Platform::DSL.new('aix-6.1-ppc')
15
+ plat.instance_eval("platform 'aix-6.1-ppc' do |plat|
16
+ plat.build_host 'abcd'
17
+ end")
18
+ plat._platform
19
+ }
20
+
21
+ let (:platform_with_vmpooler_template) {
22
+ plat = Vanagon::Platform::DSL.new('ubuntu-10.04-amd64 ')
23
+ plat.instance_eval("platform 'aix-6.1-ppc' do |plat|
24
+ plat.build_host 'abcd'
25
+ plat.vmpooler_template 'ubuntu-1004-amd64'
26
+ end")
27
+ plat._platform
28
+ }
29
+
30
+ let (:platform_with_abs_resource_name) {
31
+ plat = Vanagon::Platform::DSL.new('aix-6.1-ppc')
32
+ plat.instance_eval("platform 'aix-6.1-ppc' do |plat|
33
+ plat.build_host 'abcd'
34
+ plat.abs_resource_name 'aix-61-ppc'
35
+ end")
36
+ plat._platform
37
+ }
38
+
39
+ let (:platform_with_both) {
40
+ plat = Vanagon::Platform::DSL.new('aix-6.1-ppc')
41
+ plat.instance_eval("platform 'aix-6.1-ppc' do |plat|
42
+ plat.build_host 'abcd'
43
+ plat.vmpooler_template 'aix-six-one-ppc'
44
+ plat.abs_resource_name 'aix-61-ppc'
45
+ end")
46
+ plat._platform
47
+ }
48
+
49
+ describe '#validate_platform' do
50
+ it 'returns true if the platform has the required attributes' do
51
+ expect(Vanagon::Engine::AlwaysBeScheduling.new(platform, nil).validate_platform)
52
+ .to be(true)
53
+ end
54
+ end
55
+
56
+ describe '#build_host_name' do
57
+ it 'by default returns the platform name with no translation' do
58
+ expect(Vanagon::Engine::AlwaysBeScheduling.new(platform, nil).build_host_name)
59
+ .to eq("aix-6.1-ppc")
60
+ end
61
+
62
+ it 'returns vmpooler_template if vmpooler_template is specified' do
63
+ expect(Vanagon::Engine::AlwaysBeScheduling.new(platform_with_vmpooler_template, nil).build_host_name)
64
+ .to eq("ubuntu-1004-amd64")
65
+ end
66
+
67
+ it 'returns abs_resource_name if abs_resource_name is specified' do
68
+ expect(Vanagon::Engine::AlwaysBeScheduling.new(platform_with_abs_resource_name, nil).build_host_name)
69
+ .to eq("aix-61-ppc")
70
+ end
71
+
72
+ it 'prefers abs_resource_name to vmpooler_template if both are specified' do
73
+ expect(Vanagon::Engine::AlwaysBeScheduling.new(platform_with_both, nil).build_host_name)
74
+ .to eq("aix-61-ppc")
75
+ end
76
+ end
77
+
78
+ describe '#name' do
79
+ it 'returns "always_be_scheduling" engine name' do
80
+ expect(Vanagon::Engine::AlwaysBeScheduling.new(platform, nil).name)
81
+ .to eq('always_be_scheduling')
82
+ end
83
+ end
84
+ end