rebar 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -0
- data/lib/rebar/builder.rb +19 -0
- data/lib/rebar/dsl/database.rb +4 -4
- data/lib/rebar/dsl/hash.rb +2 -1
- data/lib/rebar/dsl/list.rb +2 -1
- data/lib/rebar/dsl/set.rb +2 -1
- data/lib/rebar/dsl/sorted_set.rb +2 -1
- data/lib/rebar/version.rb +1 -1
- data/test/builder_test.rb +9 -0
- data/test/hashes_test.rb +18 -0
- data/test/lists_test.rb +18 -0
- data/test/sets_test.rb +18 -0
- data/test/sorted_sets_test.rb +18 -0
- data/test/strings_test.rb +12 -0
- data/test/test_helper.rb +23 -0
- metadata +19 -5
data/Rakefile
CHANGED
data/lib/rebar/builder.rb
CHANGED
@@ -5,9 +5,28 @@ module Rebar
|
|
5
5
|
end
|
6
6
|
|
7
7
|
attr_reader :connection
|
8
|
+
attr_reader :system_cpu_time
|
9
|
+
attr_reader :user_cpu_time
|
10
|
+
attr_reader :memory_delta
|
8
11
|
|
9
12
|
def build(&block)
|
13
|
+
initial_cpu_sys = connection.info['used_cpu_sys'].to_i
|
14
|
+
initial_cpu_user = connection.info['used_cpu_user'].to_i
|
15
|
+
initial_memory = connection.info['used_memory'].to_i
|
16
|
+
|
10
17
|
Rebar::DSL::Database.new(connection).instance_eval(&block)
|
18
|
+
|
19
|
+
@system_cpu_time = connection.info['used_cpu_sys'].to_i - initial_cpu_sys
|
20
|
+
@user_cpu_time = connection.info['used_cpu_user'].to_i - initial_cpu_user
|
21
|
+
@memory_delta = connection.info['used_memory'].to_i - initial_memory
|
22
|
+
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def report
|
27
|
+
STDERR.puts "System CPU: \t#{system_cpu_time}s"
|
28
|
+
STDERR.puts "User CPU: \t#{user_cpu_time}s"
|
29
|
+
STDERR.puts "Memory delta: \t#{memory_delta} bytes"
|
11
30
|
end
|
12
31
|
|
13
32
|
def clean!
|
data/lib/rebar/dsl/database.rb
CHANGED
@@ -16,25 +16,25 @@ module Rebar
|
|
16
16
|
|
17
17
|
def hashes(count, &block)
|
18
18
|
count.times do
|
19
|
-
Rebar::DSL::Hash.new(connection, "rebar:hash:#{next_id(:hash)}"
|
19
|
+
Rebar::DSL::Hash.new(connection, "rebar:hash:#{next_id(:hash)}", &block)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def lists(count, &block)
|
24
24
|
count.times do
|
25
|
-
Rebar::DSL::List.new(connection, "rebar:list:#{next_id(:list)}"
|
25
|
+
Rebar::DSL::List.new(connection, "rebar:list:#{next_id(:list)}", &block)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def sets(count, &block)
|
30
30
|
count.times do
|
31
|
-
Rebar::DSL::Set.new(connection, "rebar:set:#{next_id(:set)}"
|
31
|
+
Rebar::DSL::Set.new(connection, "rebar:set:#{next_id(:set)}", &block)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def sorted_sets(count, &block)
|
36
36
|
count.times do
|
37
|
-
Rebar::DSL::SortedSet.new(connection, "rebar:sorted_set:#{next_id(:sorted_set)}"
|
37
|
+
Rebar::DSL::SortedSet.new(connection, "rebar:sorted_set:#{next_id(:sorted_set)}", &block)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/lib/rebar/dsl/hash.rb
CHANGED
data/lib/rebar/dsl/list.rb
CHANGED
data/lib/rebar/dsl/set.rb
CHANGED
data/lib/rebar/dsl/sorted_set.rb
CHANGED
data/lib/rebar/version.rb
CHANGED
data/test/hashes_test.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class HashesTest < Test::Unit::TestCase
|
4
|
+
def test_creates_hashes
|
5
|
+
Rebar.build(connection) do
|
6
|
+
hashes(5) do
|
7
|
+
keys(10)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
keys = connection.keys('rebar:hash:*')
|
12
|
+
assert_equal 5, keys.length, "Created incorrect number of hashes"
|
13
|
+
|
14
|
+
keys.each do |key|
|
15
|
+
assert_equal 10, connection.hkeys(key).length, "Created incorrect number of keys in hash #{key}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/lists_test.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListsTest < Test::Unit::TestCase
|
4
|
+
def test_creates_lists
|
5
|
+
Rebar.build(connection) do
|
6
|
+
lists(5) do
|
7
|
+
elements(10)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
keys = connection.keys('rebar:list:*')
|
12
|
+
assert_equal 5, keys.length, "Created incorrect number of lists"
|
13
|
+
|
14
|
+
keys.each do |key|
|
15
|
+
assert_equal 10, connection.llen(key), "Created incorrect number of elements in set #{key}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/sets_test.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SetsTest < Test::Unit::TestCase
|
4
|
+
def test_creates_sets
|
5
|
+
Rebar.build(connection) do
|
6
|
+
sets(5) do
|
7
|
+
members(10)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
keys = connection.keys('rebar:set:*')
|
12
|
+
assert_equal 5, keys.length, "Created incorrect number of sets"
|
13
|
+
|
14
|
+
keys.each do |key|
|
15
|
+
assert_equal 10, connection.smembers(key).length, "Created incorrect number of members in set #{key}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SortedSetsTest < Test::Unit::TestCase
|
4
|
+
def test_creates_sorted_sets
|
5
|
+
Rebar.build(connection) do
|
6
|
+
sorted_sets(5) do
|
7
|
+
members(10)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
keys = connection.keys('rebar:sorted_set:*')
|
12
|
+
assert_equal 5, keys.length, "Created incorrect number of sorted sets"
|
13
|
+
|
14
|
+
keys.each do |key|
|
15
|
+
assert_equal 10, connection.zrange(key, 0, -1).length, "Created incorrect number of members in sorted set #{key}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class StringsTest < Test::Unit::TestCase
|
4
|
+
def test_creates_strings
|
5
|
+
Rebar.build(connection) do
|
6
|
+
strings(5)
|
7
|
+
end
|
8
|
+
|
9
|
+
keys = connection.keys('rebar:string:*')
|
10
|
+
assert_equal 5, keys.length, "Created incorrect number of strings"
|
11
|
+
end
|
12
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'redis'
|
5
|
+
require 'rebar'
|
6
|
+
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'ruby-debug'
|
10
|
+
rescue LoadError
|
11
|
+
end
|
12
|
+
|
13
|
+
class Test::Unit::TestCase
|
14
|
+
def connection
|
15
|
+
@connection ||= Redis.new(:db => 15).tap do |connection|
|
16
|
+
connection.flushdb
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
connection.flushdb
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &70260397074220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70260397074220
|
25
25
|
description: ''
|
26
26
|
email: paul.rosania@gmail.com
|
27
27
|
executables: []
|
@@ -44,6 +44,13 @@ files:
|
|
44
44
|
- lib/rebar/random.rb
|
45
45
|
- lib/rebar/version.rb
|
46
46
|
- rebar.gemspec
|
47
|
+
- test/builder_test.rb
|
48
|
+
- test/hashes_test.rb
|
49
|
+
- test/lists_test.rb
|
50
|
+
- test/sets_test.rb
|
51
|
+
- test/sorted_sets_test.rb
|
52
|
+
- test/strings_test.rb
|
53
|
+
- test/test_helper.rb
|
47
54
|
homepage: https://github.com/paulrosania/rebar
|
48
55
|
licenses:
|
49
56
|
- MIT
|
@@ -69,4 +76,11 @@ rubygems_version: 1.8.11
|
|
69
76
|
signing_key:
|
70
77
|
specification_version: 3
|
71
78
|
summary: A simple stress testing tool for Redis
|
72
|
-
test_files:
|
79
|
+
test_files:
|
80
|
+
- test/builder_test.rb
|
81
|
+
- test/hashes_test.rb
|
82
|
+
- test/lists_test.rb
|
83
|
+
- test/sets_test.rb
|
84
|
+
- test/sorted_sets_test.rb
|
85
|
+
- test/strings_test.rb
|
86
|
+
- test/test_helper.rb
|