comparison modules/translate/spec/acceptance/spec_helper_acceptance.rb @ 245:b0f8b88fea5c

Add "translate" module used by MySQL module
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Dec 2019 14:12:10 -0500
parents
children
comparison
equal deleted inserted replaced
244:48d3a1948e4d 245:b0f8b88fea5c
1 # frozen_string_literal: true
2
3 require 'serverspec'
4 require 'puppet_litmus'
5 require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))
6 include PuppetLitmus
7
8 if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost'
9 puts 'Running tests against this machine !'
10 if Gem.win_platform?
11 set :backend, :cmd
12 else
13 set :backend, :exec
14 end
15 else
16 # load inventory
17 inventory_hash = inventory_hash_from_inventory_file
18 node_config = config_from_node(inventory_hash, ENV['TARGET_HOST'])
19
20 if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes')
21 host = ENV['TARGET_HOST']
22 set :backend, :docker
23 set :docker_container, host
24 elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes')
25 set :backend, :ssh
26 options = Net::SSH::Config.for(host)
27 options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil?
28 options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil?
29 options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil?
30 options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
31 options[:verify_host_key] = Net::SSH::Verifiers::Null.new unless node_config.dig('ssh', 'host-key-check').nil?
32 host = if ENV['TARGET_HOST'].include?(':')
33 ENV['TARGET_HOST'].split(':').first
34 else
35 ENV['TARGET_HOST']
36 end
37 set :host, options[:host_name] || host
38 set :ssh_options, options
39 set :request_pty, true
40 elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes')
41 require 'winrm'
42
43 set :backend, :winrm
44 set :os, family: 'windows'
45 user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil?
46 pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil?
47 endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
48
49 opts = {
50 user: user,
51 password: pass,
52 endpoint: endpoint,
53 operation_timeout: 300,
54 }
55
56 winrm = WinRM::Connection.new opts
57 Specinfra.configuration.winrm = winrm
58 end
59 end