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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e4c88240b3693b54b38a400cb6c5d81b7fc9ea3
4
- data.tar.gz: cee598c858a66ba84dc8fe882a2036fe17cef5a6
3
+ metadata.gz: fa635df9db0002480c11d5e3738f268f75bb1973
4
+ data.tar.gz: cbc8c13230023fb319135adf96b5b744138bf516
5
5
  SHA512:
6
- metadata.gz: e312f8c2486768aed4437048ecfc9d0634e0bf3f09a5a08d73e9405431dc6c1da247df95b0b568dfefe60819f44c98a5ee6566abe8ea4b4220b9494bdeb16aa9
7
- data.tar.gz: d35b82a1b1c09767c58c12971057e73de81589a2de27f46dcb9ca3f08d03e1ca8c618e5e659f53c9addf6778fa607c45bd1707615ca3d269a52b819de9b1f3c6
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 #{ENV['specpath']}? (y/n): "
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", ENV['specroot'])
42
- FileUtils.cp("#{File.dirname(__FILE__)}/ssh_options_default.yml", ENV['specroot'])
43
- FileUtils.cp("#{File.dirname(__FILE__)}/.rspec", ENV['specroot'])
44
- FileUtils.cp_r("#{File.dirname(__FILE__)}/spec/.", path)
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 \"#{ENV['specroot']}/scenario.yml\" and change directory to \"#{ENV['specroot']}\" and exec \"serverspec-runner\" command !!")
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['specpath'])
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,7 @@
1
+ module Serverspec::Type
2
+ class File < Base
3
+ def text?
4
+ @runner.check_file_is_text(@name)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Serverspec::Type
2
+ class Mysql < Base
3
+ def replicated?(master=nil, user=nil, password=nil, port=nil)
4
+ @runner.check_mysql_is_replicated(master, user, password, port)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Specinfra::Command::Base::File < Specinfra::Command::Base
2
+ class << self
3
+ def check_is_text(file)
4
+ "file #{escape(file)} | egrep ' text$'"
5
+ end
6
+ end
7
+ 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
@@ -1,3 +1,3 @@
1
1
  module ServerspecRunner
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  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.0
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