beaker-abs 0.3.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7368f79fad3e2f153910b013aa69eca32d05970d
4
- data.tar.gz: dd38119800e44a48abe03b50fbb15c61400c293c
2
+ SHA256:
3
+ metadata.gz: 542e094d8256f1b3d3ada74a529c5c8f1ca43bdd6160d2080c5d5dd233004440
4
+ data.tar.gz: 4be53717ea6a8ec508a8053f4556ae1e21932aa239c868edbdd30c371c99f860
5
5
  SHA512:
6
- metadata.gz: 1f6259cefad7b1939cfa66b60b39eaa7c681ce229643ec7bb2c9180aba436c3e29abc692d34fe477bf21fdbbcaa34e470b72ff40a7de1059d8b08bc4bf071eab
7
- data.tar.gz: 72fde57f1d1a73104e1a544c890537d07ab373a31e763911961aff3d295617899cc2488a6656022120058048a9867c01857a9473a82cc533d6e18896c9c585dc
6
+ metadata.gz: 35abd48debcfb67e37d176a493e6bb74643f41c83e3ca3c92ddb5554635f97dae70d70fd2c922a47e19e6ea82d4ab8c631588e698c34aa051a74c7038eba49e0
7
+ data.tar.gz: 60d24bfed3d554ebe8b8743dfb7889228f4a2ded06cb6a2f19a5449137d6a14a94b5412344263a8b64d37e6ad454c0259928c3df5fafe8d079d5e70b40e375b3
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "13:00"
8
+ open-pull-requests-limit: 10
@@ -1,5 +1,6 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.1.8
5
- before_install: gem install bundler -v 1.12.3
3
+ - 2.6
4
+ before_install:
5
+ - gem install bundler
6
+
@@ -0,0 +1 @@
1
+ * @puppetlabs/beaker
data/Gemfile CHANGED
@@ -2,3 +2,17 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in beaker-abs.gemspec
4
4
  gemspec
5
+
6
+ def location_for(place, fake_version = nil)
7
+ if place =~ /^(git:[^#]*)#(.*)/
8
+ [fake_version, { :git => $1, :branch => $2, :require => false }].compact
9
+ elsif place =~ /^file:\/\/(.*)/
10
+ ['>= 0', { :path => File.expand_path($1), :require => false }]
11
+ else
12
+ [place, { :require => false }]
13
+ end
14
+ end
15
+
16
+ group :testing do
17
+ gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0')
18
+ end
data/README.md CHANGED
@@ -1,22 +1,21 @@
1
- # BeakerAbs
1
+ # beaker-abs
2
2
 
3
3
  Implements a Beaker hypervisor that makes hosts provisioned by the AlwaysBeScheduling service available to a Beaker run.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Beaker will automatically load the appropriate hypervisors for any given hosts file, so as long as your project dependencies are satisfied there's nothing else to do. No need to `require` this library in your tests.
8
8
 
9
- ```ruby
10
- gem 'beaker-abs'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
9
+ As of Beaker 4.0, all hypervisor and DSL extension libraries have been removed and are no longer dependencies. In order to use a specific hypervisor or DSL extension library in your project, you will need to include them alongside Beaker in your Gemfile or project.gemspec. E.g.
16
10
 
17
- Or install it yourself as:
18
-
19
- $ gem install beaker-abs
11
+ ~~~ruby
12
+ # Gemfile
13
+ gem 'beaker', '~>4.0'
14
+ gem 'beaker-abs'
15
+ # project.gemspec
16
+ s.add_runtime_dependency 'beaker', '~>4.0'
17
+ s.add_runtime_dependency 'beaker-abs'
18
+ ~~~
20
19
 
21
20
  ## Usage
22
21
 
@@ -42,6 +41,32 @@ env ABS_RESOURCE_HOSTS=<data> beaker --hosts hosts.yaml
42
41
  ```
43
42
 
44
43
  Beaker will populate the `vmhostname` property for each host using information provided by the AlwaysBeScheduling service.
44
+ This is typically used in a CI scenario, where the jenkins run-me-maybe plugin is populating the ABS_RESOURCE_HOSTS variable.
45
+
46
+ ### Using vmfloaty
47
+
48
+ If you do not specify a ABS_RESOURCE_HOSTS and request to provision via the beaker options, beaker-abs will fallback to using
49
+ your vmfloaty configuration. By default it will look for the service named 'abs'. The name can also be configured via
50
+ the environment variable ABS_SERVICE_NAME or the top level option in the hosts file abs_service_name. Similarly, the priority defaults to "1" which means
51
+ it will take precedence over CI tests. Be careful not to run a CI test with this option. The priority can be configured via
52
+ the environment variable ABS_SERVICE_PRIORITY or the top level option in the hosts file abs_service_priority.
53
+
54
+ #### Examples
55
+
56
+ Changing from default priority 1 to 3 via env var
57
+ ```
58
+ ABS_SERVICE_PRIORITY=3 bundle exec beaker --provision --hosts=hosts.cfg --tests acceptance/tests
59
+ ```
60
+
61
+ Changing the service name to look for in ~/.vmfloaty.yml via a beaker option file
62
+ ```
63
+ $ cat options.rb
64
+ {
65
+ provision: 'true',
66
+ abs_service_name: "FOOBAR"
67
+ }
68
+ $ bundle exec beaker --hosts=hosts.cfg --tests acceptance/tests --options options.rb
69
+ ```
45
70
 
46
71
  ## Development
47
72
 
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_dependency "beaker", "~> 4.0"
22
+ spec.add_dependency "vmfloaty", ">= 1.0", "< 1.2"
23
+ spec.add_development_dependency "bundler", "~> 2.1"
24
+ spec.add_development_dependency "rake", "~> 13.0"
23
25
  spec.add_development_dependency "minitest", "~> 5.0"
24
26
 
25
- spec.add_runtime_dependency "beaker", '>= 2.9.0', '< 4.0'
26
27
  end
@@ -1,5 +1,5 @@
1
1
  module BeakerAbs
2
2
  module Version
3
- STRING = '0.3.0'
3
+ STRING = '0.8.1'
4
4
  end
5
5
  end
@@ -1,7 +1,22 @@
1
1
  require 'beaker'
2
2
  require 'json'
3
+ require 'pry-byebug'
4
+ require 'vmfloaty'
5
+ require 'vmfloaty/conf'
6
+ require 'vmfloaty/utils'
3
7
 
4
8
  module Beaker
9
+ class Clifloaty
10
+ # the floaty service needs a 'cli' object that would normally represent the flags passed on the command line
11
+ # that object is then "merged" with the floaty config files to add/change options
12
+ # creating a dummy cli here
13
+ attr_reader :url, :token, :user, :service, :priority
14
+ def initialize(service, priority)
15
+ @service = service #the name of the service you want to use
16
+ @priority = priority
17
+ end
18
+ end
19
+
5
20
  class Abs < Beaker::Hypervisor
6
21
  def initialize(hosts, options)
7
22
  @options = options
@@ -9,7 +24,12 @@ module Beaker
9
24
  @hosts = hosts
10
25
 
11
26
  resource_hosts = ENV['ABS_RESOURCE_HOSTS'] || @options[:abs_resource_hosts]
12
- raise ArgumentError.new("ABS_RESOURCE_HOSTS must be specified when using the Beaker::Abs hypervisor") if resource_hosts.nil?
27
+
28
+ @abs_service_name = ENV['ABS_SERVICE_NAME'] || @options[:abs_service_name] || "abs"
29
+ @abs_service_priority = ENV['ABS_SERVICE_PRIORITY'] || @options[:abs_service_priority] || "1"
30
+
31
+ raise ArgumentError.new("ABS_RESOURCE_HOSTS must be specified when using the Beaker::Abs hypervisor when provisioning") if resource_hosts.nil? && !options[:provision]
32
+ resource_hosts = provision_vms(hosts).to_json if resource_hosts.nil?
13
33
  @resource_hosts = JSON.parse(resource_hosts)
14
34
  end
15
35
 
@@ -21,8 +41,9 @@ module Beaker
21
41
  engine = resource_host['engine']
22
42
  case engine
23
43
  when /^(vmpooler|nspooler)$/
24
- # putting ip last as its not set by ABS
25
- return [:vmhostname, :hostname, :ip]
44
+ # ABS does not set ip, do not include
45
+ # vmpooler hostname is the platform name, nspooler hostname == vmhostname
46
+ return [:vmhostname]
26
47
  else
27
48
  super
28
49
  end
@@ -50,6 +71,7 @@ module Beaker
50
71
  type = resource_host['type']
51
72
  type2hosts[type] ||= []
52
73
  type2hosts[type] << resource_host['hostname']
74
+ type2hosts[type] << resource_host['ip']
53
75
  end
54
76
 
55
77
  # for each host, get a vm for that template type
@@ -60,6 +82,7 @@ module Beaker
60
82
 
61
83
  if provisioned_hosts = type2hosts[template]
62
84
  host['vmhostname'] = provisioned_hosts.shift
85
+ host['ip'] = provisioned_hosts.shift
63
86
  else
64
87
  raise ArgumentError.new("Failed to provision host '#{host.hostname}', no template of type '#{host['template']}' was provided.")
65
88
  end
@@ -72,5 +95,72 @@ module Beaker
72
95
  def cleanup
73
96
  # nothing to do
74
97
  end
98
+
99
+ def provision_vms(hosts)
100
+
101
+ verbose = false
102
+ config = Conf.read_config # get the vmfloaty config file in home dir
103
+
104
+ # TODO: the options object provided by the floaty cli is required in get_service_config()
105
+ cli = Clifloaty.new(@abs_service_name, @abs_service_priority)
106
+
107
+ #the service object is the interfacte to all methods
108
+ abs_service = Service.new(cli, config)
109
+ supported_vm_list = abs_service.list(verbose)
110
+ supported_vm_list = supported_vm_list.reject { |e| e.empty? }
111
+ supported_vm_list = supported_vm_list.reject { |e| e.start_with?("*") }
112
+
113
+ vm_request = generate_floaty_request_strings(hosts, supported_vm_list)
114
+
115
+
116
+ vm_beaker_abs = []
117
+ # Will return a JSON Object like this:
118
+ # {"redhat-7-x86_64"=>["rich-apparition.delivery.puppetlabs.net", "despondent-side.delivery.puppetlabs.net"], "centos-7-x86_64"=>["firmer-vamp.delivery.puppetlabs.net"]}
119
+ os_types = Utils.generate_os_hash(vm_request.split)
120
+ vm_floaty_output = abs_service.retrieve(verbose, os_types)
121
+
122
+
123
+ raise ArgumentError.new("Timed out getting the ABS resources") if vm_floaty_output.nil?
124
+ vm_floaty_output_cleaned = Utils.standardize_hostnames(vm_floaty_output)
125
+ vm_floaty_output_cleaned.each do |os_platform, value|
126
+ # filter any extra key that does not have an Array value
127
+ if !value.is_a?(Array)
128
+ next
129
+ end
130
+ value.each do | hostname |
131
+ # I don't think the engine is being used by the beaker-abs process
132
+ vm_beaker_abs.push({"hostname": hostname, "type": os_platform, "engine":"beaker-abs"})
133
+ end
134
+ end
135
+
136
+ # to do need to figure out what the NSPooler requests are, and combine the output for that with vm_beaker_abs and return that object
137
+ # for now just returning vmpooler abs object
138
+ vm_beaker_abs
139
+ end
140
+
141
+ # Based upon the host file, this method counts the number of each template needed
142
+ # and generates the host=Xnum eg redhat-7-x86_64=2 expected by floaty
143
+ def generate_floaty_request_strings(hosts, supported_vm_list)
144
+ vm_list = {}
145
+
146
+ hosts.each do |host|
147
+ if supported_vm_list.include?(host[:template])
148
+ if vm_list.include?(host[:template])
149
+ vm_list[host[:template]] = vm_list[host[:template]] + 1
150
+ else
151
+ vm_list[host[:template]] = 1
152
+ end
153
+ else
154
+ raise ArgumentError.new("#{host.name} has a template #{host[:template]} that is not found in vmpooler or nspooler")
155
+ end
156
+ end
157
+
158
+ vm_request = ""
159
+ vm_list.each do |key, value|
160
+ vm_request.concat("#{key}=#{value} ")
161
+ end
162
+
163
+ vm_request
164
+ end
75
165
  end
76
166
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-abs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cooper
@@ -9,70 +9,84 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-08-14 00:00:00.000000000 Z
12
+ date: 2020-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: bundler
15
+ name: beaker
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.12'
21
- type: :development
20
+ version: '4.0'
21
+ type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.12'
27
+ version: '4.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: vmfloaty
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '1.0'
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '1.2'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '1.0'
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
30
50
  requirement: !ruby/object:Gem::Requirement
31
51
  requirements:
32
52
  - - "~>"
33
53
  - !ruby/object:Gem::Version
34
- version: '10.0'
54
+ version: '2.1'
35
55
  type: :development
36
56
  prerelease: false
37
57
  version_requirements: !ruby/object:Gem::Requirement
38
58
  requirements:
39
59
  - - "~>"
40
60
  - !ruby/object:Gem::Version
41
- version: '10.0'
61
+ version: '2.1'
42
62
  - !ruby/object:Gem::Dependency
43
- name: minitest
63
+ name: rake
44
64
  requirement: !ruby/object:Gem::Requirement
45
65
  requirements:
46
66
  - - "~>"
47
67
  - !ruby/object:Gem::Version
48
- version: '5.0'
68
+ version: '13.0'
49
69
  type: :development
50
70
  prerelease: false
51
71
  version_requirements: !ruby/object:Gem::Requirement
52
72
  requirements:
53
73
  - - "~>"
54
74
  - !ruby/object:Gem::Version
55
- version: '5.0'
75
+ version: '13.0'
56
76
  - !ruby/object:Gem::Dependency
57
- name: beaker
77
+ name: minitest
58
78
  requirement: !ruby/object:Gem::Requirement
59
79
  requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 2.9.0
63
- - - "<"
80
+ - - "~>"
64
81
  - !ruby/object:Gem::Version
65
- version: '4.0'
66
- type: :runtime
82
+ version: '5.0'
83
+ type: :development
67
84
  prerelease: false
68
85
  version_requirements: !ruby/object:Gem::Requirement
69
86
  requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 2.9.0
73
- - - "<"
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '4.0'
89
+ version: '5.0'
76
90
  description: Adds a custom hypervisor that uses hosts provisioned by the Always Be
77
91
  Scheduling service.
78
92
  email:
@@ -82,12 +96,13 @@ executables: []
82
96
  extensions: []
83
97
  extra_rdoc_files: []
84
98
  files:
99
+ - ".github/dependabot.yml"
85
100
  - ".gitignore"
86
101
  - ".travis.yml"
102
+ - CODEOWNERS
87
103
  - Gemfile
88
104
  - HISTORY.md
89
105
  - LICENSE.txt
90
- - MAINTAINERS
91
106
  - README.md
92
107
  - Rakefile
93
108
  - beaker-abs.gemspec
@@ -113,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
128
  - !ruby/object:Gem::Version
114
129
  version: '0'
115
130
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.5.1
131
+ rubygems_version: 3.0.8
118
132
  signing_key:
119
133
  specification_version: 4
120
134
  summary: Let's test Puppet, using hosts provisioned by Always Be Scheduling service.
@@ -1,17 +0,0 @@
1
- {
2
- "version": 1,
3
- "file_format": "This MAINTAINERS file format is described at http://pup.pt/maintainers",
4
- "issues": "https://tickets.puppetlabs.com/browse/QENG/",
5
- "people": [
6
- {
7
- "github": "joshcooper",
8
- "email": "josh@puppet.com",
9
- "name": "Josh Cooper"
10
- },
11
- {
12
- "github": "rick",
13
- "email": "rick@puppet.com",
14
- "name": "Rick Bradley"
15
- }
16
- ]
17
- }