beaker-abs 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 82eb019d362ee494be591f4c05a9cd436b36d58f
4
- data.tar.gz: f6a5815d36c276af5dca0716bb247c0a970ed2e6
2
+ SHA256:
3
+ metadata.gz: 27a203607bea7dbf86a777845e5001652eaaf84cb9e4cf68bdd363101bbd4720
4
+ data.tar.gz: 254e86cb24ad8dd8485b04d1eb051cd174e50f04cbe71a8a6a587477d6b2f5c6
5
5
  SHA512:
6
- metadata.gz: 2446833607e222a257fbdea166829e3d96d2cc35e27d1d65bd499af0726c96ea5a5f11257aced79f8ae38fd83fcdac49bc17fcf37ac9e0bc7401c7aadb5034a8
7
- data.tar.gz: fecd4f6291c4b2455914803d51eef9eaf1f587589535914a4b4df1cf86b8be6ef827e098ff8e1035800cb3e618688a3de7f0eff3219a69c880d61785ec022086
6
+ metadata.gz: 076db68386151e5accabb9c2b1407b2c1ddaf43904083c58b99007b3627283a1362943190d4471d4fa2cf51412b7c1f5de8e1c97416f1ece296a0baa564b4cd1
7
+ data.tar.gz: 168fee1b01fe2266bc2cf48dffa16753ab5ae2c9645077218ca2fc85e81742abb37bd9569bc165f1452d4ab2a29191d3b7900dc7ebcd014158b35173ffacc315
@@ -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
data/.travis.yml CHANGED
@@ -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
+
data/CODEOWNERS ADDED
@@ -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
 
data/beaker-abs.gemspec CHANGED
@@ -18,8 +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", "< 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
27
  end
@@ -1,5 +1,5 @@
1
1
  module BeakerAbs
2
2
  module Version
3
- STRING = '0.4.0'
3
+ STRING = '0.9.0'
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.4.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cooper
@@ -9,36 +9,70 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-12-12 00:00:00.000000000 Z
12
+ date: 2021-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: beaker
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.0'
28
+ - !ruby/object:Gem::Dependency
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: '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: '2'
14
48
  - !ruby/object:Gem::Dependency
15
49
  name: bundler
16
50
  requirement: !ruby/object:Gem::Requirement
17
51
  requirements:
18
52
  - - "~>"
19
53
  - !ruby/object:Gem::Version
20
- version: '1.12'
54
+ version: '2.1'
21
55
  type: :development
22
56
  prerelease: false
23
57
  version_requirements: !ruby/object:Gem::Requirement
24
58
  requirements:
25
59
  - - "~>"
26
60
  - !ruby/object:Gem::Version
27
- version: '1.12'
61
+ version: '2.1'
28
62
  - !ruby/object:Gem::Dependency
29
63
  name: rake
30
64
  requirement: !ruby/object:Gem::Requirement
31
65
  requirements:
32
66
  - - "~>"
33
67
  - !ruby/object:Gem::Version
34
- version: '10.0'
68
+ version: '13.0'
35
69
  type: :development
36
70
  prerelease: false
37
71
  version_requirements: !ruby/object:Gem::Requirement
38
72
  requirements:
39
73
  - - "~>"
40
74
  - !ruby/object:Gem::Version
41
- version: '10.0'
75
+ version: '13.0'
42
76
  - !ruby/object:Gem::Dependency
43
77
  name: minitest
44
78
  requirement: !ruby/object:Gem::Requirement
@@ -62,12 +96,13 @@ executables: []
62
96
  extensions: []
63
97
  extra_rdoc_files: []
64
98
  files:
99
+ - ".github/dependabot.yml"
65
100
  - ".gitignore"
66
101
  - ".travis.yml"
102
+ - CODEOWNERS
67
103
  - Gemfile
68
104
  - HISTORY.md
69
105
  - LICENSE.txt
70
- - MAINTAINERS
71
106
  - README.md
72
107
  - Rakefile
73
108
  - beaker-abs.gemspec
@@ -93,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
128
  - !ruby/object:Gem::Version
94
129
  version: '0'
95
130
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.6.12
131
+ rubygems_version: 3.0.8
98
132
  signing_key:
99
133
  specification_version: 4
100
134
  summary: Let's test Puppet, using hosts provisioned by Always Be Scheduling service.
data/MAINTAINERS DELETED
@@ -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
- }