serverspec-runner 1.1.0 → 1.1.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 +4 -4
- data/Rakefile +11 -8
- data/lib/extension/serverspec/helper/type.rb +18 -0
- data/lib/extension/serverspec/matcher/be_replicated.rb +21 -0
- data/lib/extension/serverspec/type/file.rb +7 -0
- data/lib/extension/serverspec/type/mysql.rb +7 -0
- data/lib/extension/specinfra/command/base/file.rb +7 -0
- data/lib/extension/specinfra/command/linux/base/mysql.rb +15 -0
- data/lib/serverspec-runner/version.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa635df9db0002480c11d5e3738f268f75bb1973
|
4
|
+
data.tar.gz: cbc8c13230023fb319135adf96b5b744138bf516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff5f23e4a57d359ec2f376332f0f9b90384a43e2583ccad149a38248b9cae8a3538599811e6ad4d45fdc84b268c3bb8fcc425f5a6a6b6be253fd316674a0107f
|
7
|
+
data.tar.gz: ba295c58962da3e81467ec23b0c18093e58fffc5a473752e3289f8fb6f06917b1ebeb99fa24e33cbbcb38ff1a9f397f8f0ea49dc0458cba2506c148458703d38
|
data/Rakefile
CHANGED
@@ -29,21 +29,24 @@ namespace :spec do
|
|
29
29
|
|
30
30
|
def init_specpath(path)
|
31
31
|
|
32
|
+
abs_path = File::expand_path(path)
|
33
|
+
|
32
34
|
begin
|
33
|
-
print "want to create spec-tree to #{
|
35
|
+
print "want to create spec-tree to #{abs_path}? (y/n): "
|
34
36
|
ans = STDIN.gets.strip
|
35
37
|
exit 0 unless (ans == 'y' || ans == 'yes')
|
36
38
|
rescue Exception
|
37
39
|
exit 0
|
38
40
|
end
|
39
41
|
|
40
|
-
FileUtils.mkdir_p(path)
|
41
|
-
FileUtils.cp("#{File.dirname(__FILE__)}/scenario.yml",
|
42
|
-
FileUtils.cp("#{File.dirname(__FILE__)}/ssh_options_default.yml",
|
43
|
-
FileUtils.cp("#{File.dirname(__FILE__)}/.rspec",
|
44
|
-
FileUtils.cp_r("#{File.dirname(__FILE__)}/spec
|
42
|
+
FileUtils.mkdir_p("#{path}/lib")
|
43
|
+
FileUtils.cp("#{File.dirname(__FILE__)}/scenario.yml", path)
|
44
|
+
FileUtils.cp("#{File.dirname(__FILE__)}/ssh_options_default.yml", path)
|
45
|
+
FileUtils.cp("#{File.dirname(__FILE__)}/.rspec", path)
|
46
|
+
FileUtils.cp_r("#{File.dirname(__FILE__)}/spec", path)
|
47
|
+
FileUtils.cp_r("#{File.dirname(__FILE__)}/lib/extension", "#{path}/lib")
|
45
48
|
|
46
|
-
puts("Please edit \"#{
|
49
|
+
puts("Please edit \"#{abs_path}/scenario.yml\" and change directory to \"#{abs_path}\" and exec \"serverspec-runner\" command !!")
|
47
50
|
end
|
48
51
|
|
49
52
|
def gen_exec_plan(parent, node, path, ssh_options, tasks, platform)
|
@@ -117,7 +120,7 @@ namespace :spec do
|
|
117
120
|
end
|
118
121
|
|
119
122
|
if !Dir.exists?(ENV['specpath'])
|
120
|
-
init_specpath(ENV['
|
123
|
+
init_specpath(ENV['specroot'])
|
121
124
|
exit 0
|
122
125
|
end
|
123
126
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Serverspec
|
2
|
+
module Helper
|
3
|
+
module Type
|
4
|
+
types = %w(
|
5
|
+
mysql
|
6
|
+
)
|
7
|
+
|
8
|
+
types.each {|type| require "serverspec/type/#{type}" }
|
9
|
+
|
10
|
+
types.each do |type|
|
11
|
+
define_method type do |*args|
|
12
|
+
name = args.first
|
13
|
+
eval "Serverspec::Type::#{type.to_camel_case}.new(name)"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec::Matchers.define :be_replicated do
|
2
|
+
match do |host|
|
3
|
+
host.replicated?(@master, @user, @password, @port)
|
4
|
+
end
|
5
|
+
|
6
|
+
chain :from do |master|
|
7
|
+
@master = master
|
8
|
+
end
|
9
|
+
|
10
|
+
chain :with_user do |user|
|
11
|
+
@user = user
|
12
|
+
end
|
13
|
+
|
14
|
+
chain :with_password do |password|
|
15
|
+
@password = password
|
16
|
+
end
|
17
|
+
|
18
|
+
chain :with_port do |port|
|
19
|
+
@port = port
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Specinfra::Command::Linux::Base::Mysql < Specinfra::Command::Base
|
2
|
+
class << self
|
3
|
+
def check_is_replicated(master=nil, user=nil, password=nil, port=nil)
|
4
|
+
opt_user = "--user=#{user} " || ''
|
5
|
+
opt_password = "--password=#{password} " || ''
|
6
|
+
opt_port = "--port=#{port} " || ''
|
7
|
+
|
8
|
+
cmd = ''
|
9
|
+
cmd += "echo 'show slave status \\G;' | mysql #{opt_user} #{opt_password} #{opt_port} | "
|
10
|
+
cmd += "grep -e 'Slave_IO_Running: Yes' -e 'Slave_SQL_Running: Yes' -e 'Master_Host: #{master}' | "
|
11
|
+
cmd += "wc -l | grep -w 3"
|
12
|
+
cmd
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,11 @@ require 'yaml'
|
|
5
5
|
require 'csv'
|
6
6
|
require 'serverspec-runner/util/hash'
|
7
7
|
|
8
|
+
# require extension libraries
|
9
|
+
Dir.glob([
|
10
|
+
ENV['specroot'] + '/lib/extension/serverspec/**/*.rb',
|
11
|
+
ENV['specroot'] + '/lib/extension/specinfra/**/*.rb']).each {|f| require f}
|
12
|
+
|
8
13
|
ssh_opts_default = YAML.load_file(ENV['ssh_options'])
|
9
14
|
csv_path = ENV['result_csv']
|
10
15
|
explains = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hiracy
|
@@ -96,6 +96,12 @@ files:
|
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
98
|
- bin/serverspec-runner
|
99
|
+
- lib/extension/serverspec/helper/type.rb
|
100
|
+
- lib/extension/serverspec/matcher/be_replicated.rb
|
101
|
+
- lib/extension/serverspec/type/file.rb
|
102
|
+
- lib/extension/serverspec/type/mysql.rb
|
103
|
+
- lib/extension/specinfra/command/base/file.rb
|
104
|
+
- lib/extension/specinfra/command/linux/base/mysql.rb
|
99
105
|
- lib/serverspec-runner.rb
|
100
106
|
- lib/serverspec-runner/util/hash.rb
|
101
107
|
- lib/serverspec-runner/version.rb
|