redis-store-testing 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 71815ba5296baca37bc71c004359262fa9d97640
4
+ data.tar.gz: 72690889deee759d137d8037c79ba8c1d9473441
5
+ SHA512:
6
+ metadata.gz: 31d1cbfbf94b1cc498756af44e51d903f06a1352924bab808a56b138d36f3f67cd1ca66da10fbedf3c1f89a5a9db64414758a495131b861f9d902a57b7c0eeba
7
+ data.tar.gz: 8e3609a056ec864cab9eca4c54cd471101509cd163a18b22bb7d854cf6e3791ff1583b63139b7c60b842ec5d166b18dc51b0953ee73ff27010d1485baa084c7d
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Luca Guidi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # Redis Store testing
2
+
3
+ Common [redis-store](http://redis-store.org) utilities.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'redis-store-testing'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```shell
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```shell
22
+ $ gem install redis-store-testing
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ # Rakefile
29
+ require 'bundler/setup'
30
+ require 'rake'
31
+ require 'bundler/gem_tasks'
32
+ require 'redis-store/testing/tasks'
33
+ ```
34
+
35
+ ```shell
36
+ $ bundle exec rake
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ # Just a placeholder. Don't require anything.
@@ -0,0 +1,46 @@
1
+ daemonize yes
2
+ pidfile ./tmp/pids/node-one.pid
3
+ port 6380
4
+ timeout 0
5
+ loglevel verbose
6
+ logfile stdout
7
+ databases 16
8
+
9
+ save 900 1
10
+ save 300 10
11
+ save 60 10000
12
+
13
+ # stop-writes-on-bgsave-error yes
14
+ rdbcompression yes
15
+ # rdbchecksum yes
16
+ dbfilename tmp/node-one-dump.rdb
17
+ dir ./
18
+
19
+ slave-serve-stale-data yes
20
+ # slave-read-only yes
21
+ # slave-priority 100
22
+
23
+ appendonly no
24
+ appendfsync everysec
25
+ no-appendfsync-on-rewrite no
26
+ # auto-aof-rewrite-percentage 100
27
+ # auto-aof-rewrite-min-size 64mb
28
+
29
+ # lua-time-limit 5000
30
+
31
+ # slowlog-log-slower-than 10000
32
+ # slowlog-max-len 128
33
+
34
+ # hash-max-ziplist-entries 512
35
+ # hash-max-ziplist-value 64
36
+ list-max-ziplist-entries 512
37
+ list-max-ziplist-value 64
38
+ set-max-intset-entries 512
39
+ # zset-max-ziplist-entries 128
40
+ # zset-max-ziplist-value 64
41
+
42
+ activerehashing yes
43
+
44
+ # client-output-buffer-limit normal 0 0 0
45
+ # client-output-buffer-limit slave 256mb 64mb 60
46
+ # client-output-buffer-limit pubsub 32mb 8mb 60
@@ -0,0 +1,46 @@
1
+ daemonize yes
2
+ pidfile ./tmp/pids/node-two.pid
3
+ port 6381
4
+ timeout 0
5
+ loglevel verbose
6
+ logfile stdout
7
+ databases 16
8
+
9
+ save 900 1
10
+ save 300 10
11
+ save 60 10000
12
+
13
+ # stop-writes-on-bgsave-error yes
14
+ rdbcompression yes
15
+ # rdbchecksum yes
16
+ dbfilename tmp/node-two-dump.rdb
17
+ dir ./
18
+
19
+ slave-serve-stale-data yes
20
+ # slave-read-only yes
21
+ # slave-priority 100
22
+
23
+ appendonly no
24
+ appendfsync everysec
25
+ no-appendfsync-on-rewrite no
26
+ # auto-aof-rewrite-percentage 100
27
+ # auto-aof-rewrite-min-size 64mb
28
+
29
+ # lua-time-limit 5000
30
+
31
+ # slowlog-log-slower-than 10000
32
+ # slowlog-max-len 128
33
+
34
+ # hash-max-ziplist-entries 512
35
+ # hash-max-ziplist-value 64
36
+ list-max-ziplist-entries 512
37
+ list-max-ziplist-value 64
38
+ set-max-intset-entries 512
39
+ # zset-max-ziplist-entries 128
40
+ # zset-max-ziplist-value 64
41
+
42
+ activerehashing yes
43
+
44
+ # client-output-buffer-limit normal 0 0 0
45
+ # client-output-buffer-limit slave 256mb 64mb 60
46
+ # client-output-buffer-limit pubsub 32mb 8mb 60
@@ -0,0 +1,46 @@
1
+ daemonize yes
2
+ pidfile ./tmp/pids/redis.pid
3
+ port 6379
4
+ timeout 0
5
+ loglevel verbose
6
+ logfile stdout
7
+ databases 16
8
+
9
+ save 900 1
10
+ save 300 10
11
+ save 60 10000
12
+
13
+ # stop-writes-on-bgsave-error yes
14
+ rdbcompression yes
15
+ # rdbchecksum yes
16
+ dbfilename tmp/dump.rdb
17
+ dir ./
18
+
19
+ slave-serve-stale-data yes
20
+ # slave-read-only yes
21
+ # slave-priority 100
22
+
23
+ appendonly no
24
+ appendfsync everysec
25
+ no-appendfsync-on-rewrite no
26
+ # auto-aof-rewrite-percentage 100
27
+ # auto-aof-rewrite-min-size 64mb
28
+
29
+ # lua-time-limit 5000
30
+
31
+ # slowlog-log-slower-than 10000
32
+ # slowlog-max-len 128
33
+
34
+ # hash-max-ziplist-entries 512
35
+ # hash-max-ziplist-value 64
36
+ list-max-ziplist-entries 512
37
+ list-max-ziplist-value 64
38
+ set-max-intset-entries 512
39
+ # zset-max-ziplist-entries 128
40
+ # zset-max-ziplist-value 64
41
+
42
+ activerehashing yes
43
+
44
+ # client-output-buffer-limit normal 0 0 0
45
+ # client-output-buffer-limit slave 256mb 64mb 60
46
+ # client-output-buffer-limit pubsub 32mb 8mb 60
@@ -0,0 +1,32 @@
1
+ require 'redis-store/testing/runners'
2
+
3
+ class RedisReplicationRunner
4
+ def self.runners
5
+ [ RedisRunner, NodeOneRedisRunner, NodeTwoRedisRunner ]
6
+ end
7
+
8
+ def initialize(dir)
9
+ @dir = dir
10
+ end
11
+
12
+ def start
13
+ runners.each do |runner|
14
+ runner.start
15
+ end
16
+ end
17
+
18
+ def stop
19
+ runners.each do |runner|
20
+ runner.stop
21
+ end
22
+ end
23
+
24
+ protected
25
+ def runners
26
+ @runners ||= begin
27
+ self.class.runners.map do |runner|
28
+ runner.new(@dir)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,73 @@
1
+ require 'pathname'
2
+
3
+ class RedisRunner
4
+ attr_reader :dir
5
+
6
+ def initialize(dir)
7
+ @dir = dir
8
+ end
9
+
10
+ def redisdir
11
+ dir.join 'vendor/redis'
12
+ end
13
+
14
+ def start
15
+ system %(redis-server #{configuration})
16
+ end
17
+
18
+ def stop
19
+ begin
20
+ Process.kill('SIGTERM', pid)
21
+ rescue
22
+ # Suppress exceptions for Travis CI
23
+ end
24
+ end
25
+
26
+ protected
27
+ def configuration
28
+ root.join 'config/redis.conf'
29
+ end
30
+
31
+ def pid_file
32
+ dir.join 'tmp/pids/redis.pid'
33
+ end
34
+
35
+ def pid
36
+ ::File.open(pid_file).read.to_i
37
+ end
38
+
39
+ private
40
+ def root
41
+ @root ||= begin
42
+ root = if Kernel.respond_to?(:__dir__)
43
+ __dir__
44
+ else
45
+ ::File.dirname(__FILE__)
46
+ end
47
+
48
+ Pathname.new(root)
49
+ end
50
+ end
51
+ end
52
+
53
+ class NodeOneRedisRunner < RedisRunner
54
+ protected
55
+ def configuration
56
+ root.join 'config/node-one.conf'
57
+ end
58
+
59
+ def self.pid_file
60
+ dir.join 'tmp/pids/node-one.pid'
61
+ end
62
+ end
63
+
64
+ class NodeTwoRedisRunner < RedisRunner
65
+ protected
66
+ def configuration
67
+ root.join 'config/node-two.conf'
68
+ end
69
+
70
+ def self.pid_file
71
+ dir.join 'tmp/pids/node-two.pid'
72
+ end
73
+ end
@@ -0,0 +1,155 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'fileutils'
4
+ require 'pathname'
5
+ require 'open-uri'
6
+ require 'redis-store/testing/redis_replication_runner'
7
+
8
+ class RedisStoreTesting
9
+ include Rake::DSL
10
+
11
+ def self.install_tasks(options = {})
12
+ new(options[:dir]).install
13
+ end
14
+
15
+ def initialize(dir = nil)
16
+ @dir = Pathname.new(dir ||= Dir.pwd).realpath
17
+ @runner = RedisReplicationRunner.new(@dir)
18
+ end
19
+
20
+ def install
21
+ namespace :redis do
22
+ redis_about
23
+ redis_install
24
+ redis_make
25
+ redis_download
26
+
27
+ namespace :test do
28
+ redis_test_suite
29
+ redis_test_run
30
+ redis_test_prepare
31
+ end
32
+
33
+ namespace :replication do
34
+ redis_replication_start
35
+ redis_replication_stop
36
+ redis_replication_console
37
+ end
38
+ end
39
+
40
+ task default: 'redis:test:suite'
41
+ end
42
+
43
+ protected
44
+ def redis_about
45
+ desc 'About redis'
46
+ task :about do
47
+ puts "\nSee http://redis.io for information about Redis.\n\n"
48
+ end
49
+ end
50
+
51
+ def redis_install
52
+ desc 'Install the lastest verison of Redis from Github (requires git, duh)'
53
+ task install: [ :about, :download, :make ] do
54
+ %w(redis-benchmark redis-cli redis-server).each do |bin|
55
+ if File.exist?(path = "#{@runner.redisdir}/src/#{bin}")
56
+ sh "sudo cp #{path} /usr/bin/"
57
+ else
58
+ sh "sudo cp #{@runner.redisdir}/#{bin} /usr/bin/"
59
+ end
60
+ end
61
+
62
+ puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/"
63
+
64
+ sh "sudo cp #{@runner.redisdir}/redis.conf /etc/"
65
+ puts "Installed redis.conf to /etc/ \n You should look at this file!"
66
+ end
67
+ end
68
+
69
+ def redis_make
70
+ task :make do
71
+ sh "cd #{@runner.redisdir} && make clean"
72
+ sh "cd #{@runner.redisdir} && make"
73
+ end
74
+ end
75
+
76
+ def redis_download
77
+ desc "Download package"
78
+ task :download do
79
+ require 'git'
80
+
81
+ sh "rm -rf #{@runner.redisdir} && mkdir -p vendor && rm -rf redis"
82
+ Git.clone("git://github.com/antirez/redis.git", "redis")
83
+ sh "mv redis vendor"
84
+
85
+ commit = case ENV['VERSION']
86
+ when "1.3.12" then "26ef09a83526e5099bce"
87
+ when "2.2.12" then "5960ac9dec5184bf4184"
88
+ when "2.2.4" then "2b886275e9756bb8619a"
89
+ when "2.0.5" then "9b695bb0a00c01ad4d55"
90
+ end
91
+
92
+ arguments = commit.nil? ? "pull origin master" : "reset --hard #{commit}"
93
+ sh "cd #{@runner.redisdir} && git #{arguments}"
94
+ end
95
+ end
96
+
97
+ def redis_test_suite
98
+ desc 'Run all the examples by starting a background Redis instance'
99
+ task suite: 'redis:test:prepare' do
100
+ invoke_with_redis_replication 'redis:test:run'
101
+ end
102
+ end
103
+
104
+ def redis_test_run
105
+ Rake::TestTask.new(:run) do |t|
106
+ t.libs.push 'lib'
107
+ t.test_files = FileList['test/**/*_test.rb']
108
+ t.ruby_opts = ["-I test"]
109
+ t.verbose = true
110
+ end
111
+ end
112
+
113
+ def redis_test_prepare
114
+ task :prepare do
115
+ FileUtils.mkdir_p @dir.join('tmp/pids')
116
+ FileUtils.rm Dir.glob(@dir.join('tmp/*.rdb'))
117
+ end
118
+ end
119
+
120
+ def redis_replication_start
121
+ desc "Starts redis replication servers"
122
+ task :start do
123
+ @runner.start
124
+ end
125
+ end
126
+
127
+ def redis_replication_stop
128
+ desc "Stops redis replication servers"
129
+ task :stop do
130
+ @runner.stop
131
+ end
132
+ end
133
+
134
+ def redis_replication_console
135
+ desc "Open an IRb session with the master/slave replication"
136
+ task :console do
137
+ @runner.start
138
+ system "bundle exec irb -I lib -I extra -r redis-store.rb"
139
+ @runner.stop
140
+ end
141
+ end
142
+
143
+ private
144
+
145
+ def invoke_with_redis_replication(task_name)
146
+ begin
147
+ Rake::Task['redis:replication:start'].invoke
148
+ Rake::Task[task_name].invoke
149
+ ensure
150
+ Rake::Task['redis:replication:stop'].invoke
151
+ end
152
+ end
153
+ end
154
+
155
+ RedisStoreTesting.install_tasks
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'redis-store-testing'
6
+ spec.version = '0.0.1'
7
+ spec.authors = ['Luca Guidi']
8
+ spec.email = ['me@lucaguidi.com']
9
+ spec.description = %q{redis-store testing}
10
+ spec.summary = %q{Common redis-store testing utilities}
11
+ spec.homepage = 'http://redis-store.org'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'rake'
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis-store-testing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Luca Guidi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ description: redis-store testing
42
+ email:
43
+ - me@lucaguidi.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/redis-store-testing.rb
54
+ - lib/redis-store/testing/config/node-one.conf
55
+ - lib/redis-store/testing/config/node-two.conf
56
+ - lib/redis-store/testing/config/redis.conf
57
+ - lib/redis-store/testing/redis_replication_runner.rb
58
+ - lib/redis-store/testing/runners.rb
59
+ - lib/redis-store/testing/tasks.rb
60
+ - redis-store-testing.gemspec
61
+ homepage: http://redis-store.org
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.0.3
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Common redis-store testing utilities
85
+ test_files: []