public
Homepage: http://rubyforge.org/projects/starling
Clone URL: git://github.com/defunkt/starling.git
tests work
defunkt (author)
Fri Jan 18 14:25:50 -0800 2008
commit  1097048ee202106bd0b3c46bdd6ba068fe6a71d9
tree    037bfcc71c33de74bbb3d4820b105bab9030e724
parent  2c91a750e933fa5090b179329b710800f7235bf1
...
26
27
28
 
29
30
 
31
32
33
...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
110
111
...
26
27
28
29
30
 
31
32
33
34
...
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
0
@@ -26,8 +26,9 @@ class TestStarling < Test::Unit::TestCase
0
   end
0
 
0
   def teardown
0
+ sleep 0.01
0
     @server.stop
0
- @client = nil
0
+ @client.reset
0
     FileUtils.rm_f(File.join(tmp_path, '*'))
0
     sleep 0.01
0
   end
0
@@ -45,67 +46,71 @@ class TestStarling < Test::Unit::TestCase
0
     assert_equal v, @client.get('test_set_and_get_one_entry')
0
   end
0
 
0
-# def test_set_with_expiry
0
-# v = rand((2**32)-1)
0
-# assert_equal nil, @client.get('test_set_with_expiry')
0
-# now = Time.now.to_i
0
-# @client.set('test_set_with_expiry', v + 2, now)
0
-# @client.set('test_set_with_expiry', v)
0
-# sleep(now + 1 - Time.now.to_f)
0
-# assert_equal v, @client.get('test_set_with_expiry')
0
-# end
0
-#
0
-# def test_log_rotation
0
-# log_rotation_path = File.join(tmp_path, 'test_log_rotation')
0
-#
0
-# Dir.glob("#{log_rotation_path}*").each do |file|
0
-# File.unlink(file) rescue nil
0
-# end
0
-# assert_equal nil, @client.get('test_log_rotation')
0
-#
0
-# v = 'x' * 8192
0
-#
0
-# @client.set('test_log_rotation', v)
0
-# assert_equal 8207, File.size(log_rotation_path)
0
-# @client.get('test_log_rotation')
0
-#
0
-# assert_equal nil, @client.get('test_log_rotation')
0
-#
0
-# @client.set('test_log_rotation', v)
0
-# assert_equal v, @client.get('test_log_rotation')
0
-#
0
-# assert_equal 1, File.size(log_rotation_path)
0
-# assert_equal 2, Dir.glob("#{log_rotation_path}*").size
0
-# end
0
-#
0
-# def test_stats
0
-# stats = @client.stats
0
-# assert_kind_of Hash, stats
0
-# assert stats.has_key?('127.0.0.1:22133')
0
-#
0
-# server_stats = stats['127.0.0.1:22133']
0
-#
0
-# basic_stats = %w( bytes pid time limit_maxbytes cmd_get version
0
-# bytes_written cmd_set get_misses total_connections
0
-# curr_connections curr_items uptime get_hits total_items
0
-# rusage_system rusage_user bytes_read )
0
-#
0
-# basic_stats.each do |stat|
0
-# assert server_stats.has_key?(stat)
0
-# end
0
-# end
0
-#
0
-# def test_unknown_command_returns_valid_result
0
-# response = @client.add('blah', 1)
0
-# assert_match 'CLIENT_ERROR', response
0
-# end
0
-
0
-# def test_that_disconnecting_and_reconnecting_works
0
-# v = rand(2**32-1)
0
-# @client.set('test_that_disconnecting_and_reconnecting_works', v)
0
-# @client.reset
0
-# assert_equal v, @client.get('test_that_disconnecting_and_reconnecting_works')
0
-# end
0
+ def test_set_with_expiry
0
+ v = rand((2**32)-1)
0
+ assert_equal nil, @client.get('test_set_with_expiry')
0
+ now = Time.now.to_i
0
+ @client.set('test_set_with_expiry', v + 2, now)
0
+ @client.set('test_set_with_expiry', v)
0
+ sleep(now + 1 - Time.now.to_f)
0
+ assert_equal v, @client.get('test_set_with_expiry')
0
+ end
0
+
0
+ def test_log_rotation
0
+ log_rotation_path = File.join(tmp_path, 'test_log_rotation')
0
+
0
+ Dir.glob("#{log_rotation_path}*").each do |file|
0
+ File.unlink(file) rescue nil
0
+ end
0
+ assert_equal nil, @client.get('test_log_rotation')
0
+
0
+ v = 'x' * 8192
0
+
0
+ @client.set('test_log_rotation', v)
0
+ assert_equal 8207, File.size(log_rotation_path)
0
+ @client.get('test_log_rotation')
0
+
0
+ assert_equal nil, @client.get('test_log_rotation')
0
+
0
+ @client.set('test_log_rotation', v)
0
+ assert_equal v, @client.get('test_log_rotation')
0
+
0
+ assert_equal 1, File.size(log_rotation_path)
0
+ assert_equal 2, Dir.glob("#{log_rotation_path}*").size
0
+ end
0
+
0
+ def test_stats
0
+ stats = @client.stats
0
+ assert_kind_of Hash, stats
0
+ assert stats.has_key?('127.0.0.1:22133')
0
+
0
+ server_stats = stats['127.0.0.1:22133']
0
+
0
+ basic_stats = %w( bytes pid time limit_maxbytes cmd_get version
0
+ bytes_written cmd_set get_misses total_connections
0
+ curr_connections curr_items uptime get_hits total_items
0
+ rusage_system rusage_user bytes_read )
0
+
0
+ basic_stats.each do |stat|
0
+ assert server_stats.has_key?(stat)
0
+ end
0
+ end
0
+
0
+ def test_funknown_command_returns_valid_result
0
+ response = @client.add('blah', 1)
0
+ assert_match 'CLIENT_ERROR', response
0
+ response = @client.add('blah', 2)
0
+ assert_match 'CLIENT_ERROR', response
0
+ response = @client.get('blah')
0
+ assert response.nil?
0
+ end
0
+
0
+ def test_disconnecting_and_reconnecting_works
0
+ v = rand(2**32-1)
0
+ @client.set('test_that_disconnecting_and_reconnecting_works', v)
0
+ @client.reset
0
+ assert_equal v, @client.get('test_that_disconnecting_and_reconnecting_works')
0
+ end
0
 
0
   private
0
 

Comments

    No one has commented yet.