drbdump 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +8 -0
- data/.gemtest +0 -0
- data/History.rdoc +4 -0
- data/Manifest.txt +30 -0
- data/README.rdoc +71 -0
- data/Rakefile +30 -0
- data/bin/drbdump +6 -0
- data/example/ping.rb +241 -0
- data/example/service_primes.rb +212 -0
- data/example/tuplespace_primes.rb +196 -0
- data/lib/drbdump.rb +714 -0
- data/lib/drbdump/loader.rb +75 -0
- data/lib/drbdump/message.rb +72 -0
- data/lib/drbdump/message_result.rb +84 -0
- data/lib/drbdump/message_send.rb +146 -0
- data/lib/drbdump/statistic.rb +90 -0
- data/lib/drbdump/statistics.rb +318 -0
- data/lib/drbdump/test_case.rb +91 -0
- data/test/arg.dump +0 -0
- data/test/drb_fin.dump +0 -0
- data/test/http.dump +0 -0
- data/test/ping.dump +0 -0
- data/test/ring.dump +0 -0
- data/test/test_drbdump.rb +283 -0
- data/test/test_drbdump_loader.rb +88 -0
- data/test/test_drbdump_message.rb +31 -0
- data/test/test_drbdump_message_result.rb +73 -0
- data/test/test_drbdump_message_send.rb +105 -0
- data/test/test_drbdump_statistic.rb +98 -0
- data/test/test_drbdump_statistics.rb +264 -0
- data/test/too_large_packet.pcap +0 -0
- metadata +183 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'drbdump/test_case'
|
2
|
+
|
3
|
+
class TestDRbDumpLoader < DRbDump::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@loader = DRbDump::Loader.new load_limit: 40
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_load
|
12
|
+
ms = load "\x00\x00\x00\x05\x04\x08[\x06T"
|
13
|
+
|
14
|
+
assert_equal "\x04\x08[\x06T", ms.stream
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_load_marshal_read_error
|
18
|
+
stream = Object.new
|
19
|
+
stream.instance_variable_set :@read, false
|
20
|
+
def stream.read(size)
|
21
|
+
raise if @read
|
22
|
+
|
23
|
+
@read = true
|
24
|
+
|
25
|
+
"\x00\x00\x00\x05"
|
26
|
+
end
|
27
|
+
|
28
|
+
assert_raises DRbDump::Loader::DataError do
|
29
|
+
@loader.load stream
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_load_marshal_too_short
|
34
|
+
assert_raises DRbDump::Loader::Premature do
|
35
|
+
load "\x00\x00\x00\x05\x04\x08[\x06"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_load_no_marshal
|
40
|
+
stream = Object.new
|
41
|
+
stream.instance_variable_set :@read, false
|
42
|
+
def stream.read(size)
|
43
|
+
return nil if @read
|
44
|
+
|
45
|
+
@read = true
|
46
|
+
|
47
|
+
"\x00\x00\x00\x05"
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_raises DRbDump::Loader::DataError do
|
51
|
+
@loader.load stream
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_load_no_size
|
56
|
+
assert_raises DRbDump::Loader::SizeError do
|
57
|
+
load ''
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_load_size_read_error
|
62
|
+
stream = Object.new
|
63
|
+
def stream.read() end # ArgumentError
|
64
|
+
|
65
|
+
assert_raises DRbDump::Loader::SizeError do
|
66
|
+
@loader.load stream
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_load_size_too_short
|
71
|
+
assert_raises DRbDump::Loader::Premature do
|
72
|
+
load "\x00\x00\x00"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_load_size_too_long
|
77
|
+
assert_raises DRbDump::Loader::TooLarge do
|
78
|
+
load [41].pack 'N'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def load stream
|
83
|
+
stream = StringIO.new stream
|
84
|
+
@loader.load stream
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'drbdump/test_case'
|
2
|
+
|
3
|
+
class TestDRbDumpMessage < DRbDump::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
drbdump
|
9
|
+
|
10
|
+
@packet = packets(ARG_DUMP).first
|
11
|
+
|
12
|
+
@m = DRbDump::Message.new @drbdump, @packet
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_destination
|
16
|
+
assert_equal '"druby://kault:57315"', @m.destination
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_resolve_addresses
|
20
|
+
@m.resolve_addresses
|
21
|
+
|
22
|
+
assert_equal '"druby://kault:57317"', @m.source
|
23
|
+
assert_equal '"druby://kault:57315"', @m.destination
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_source
|
27
|
+
assert_equal '"druby://kault:57317"', @m.source
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'drbdump/test_case'
|
2
|
+
|
3
|
+
class TestDRbDumpMessageResult < DRbDump::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
drbdump
|
9
|
+
|
10
|
+
@packet = packets(ARG_DUMP).first
|
11
|
+
|
12
|
+
status = Marshal::Structure.new "\x04\x08T"
|
13
|
+
value = StringIO.new "\x00\x00\x00\x08\x04\x08\[\x06\"\x07OK"
|
14
|
+
|
15
|
+
@mr = DRbDump::MessageResult.new @drbdump, @packet, status, value
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_allocations
|
19
|
+
assert_equal 2, @mr.allocations
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_display
|
23
|
+
out, = capture_io do
|
24
|
+
@mr.display
|
25
|
+
end
|
26
|
+
|
27
|
+
expected = <<-EXPECTED
|
28
|
+
23:46:20.561298 "druby://kault:57315" \u21d0 "druby://kault:57317" success: ["OK"]
|
29
|
+
EXPECTED
|
30
|
+
|
31
|
+
assert_equal expected, out
|
32
|
+
|
33
|
+
assert_equal 1, @statistics.drb_results_received
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_display_quiet
|
37
|
+
@drbdump.quiet = true
|
38
|
+
|
39
|
+
assert_silent do
|
40
|
+
@mr.display
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_equal 1, @statistics.drb_results_received
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_result
|
47
|
+
assert_equal '["OK"]', @mr.result
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_status
|
51
|
+
assert_equal true, @mr.status
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_timestamp
|
55
|
+
first, _, last = packets(FIN_DUMP).first 3
|
56
|
+
|
57
|
+
ms = DRbDump::MessageSend.new @drbdump, last, nil, nil
|
58
|
+
|
59
|
+
assert_equal last.timestamp, ms.timestamp
|
60
|
+
|
61
|
+
@drbdump.incomplete_timestamps[first.source] = first.timestamp
|
62
|
+
|
63
|
+
assert_equal first.timestamp, ms.timestamp
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_update_statistics
|
67
|
+
@mr.update_statistics
|
68
|
+
|
69
|
+
assert_equal 1, @statistics.drb_results_received
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'drbdump/test_case'
|
2
|
+
|
3
|
+
class TestDRbDumpMessageSend < DRbDump::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
drbdump
|
9
|
+
|
10
|
+
@packet = packets(ARG_DUMP).first
|
11
|
+
|
12
|
+
receiver = Marshal::Structure.new "\x04\x080"
|
13
|
+
msg = "\x00\x00\x00\x0b\x04\x08\"\x0cmessage"
|
14
|
+
argc = "\x00\x00\x00\x04\x04\x08i\x08"
|
15
|
+
argv = [
|
16
|
+
"\x00\x00\x00\x05\x04\x08\"\x06a",
|
17
|
+
"\x00\x00\x00\x05\x04\x08\"\x06b",
|
18
|
+
"\x00\x00\x00\x05\x04\x08\"\x06c",
|
19
|
+
]
|
20
|
+
block = "\x00\x00\x00\x03\x04\x080"
|
21
|
+
|
22
|
+
stream = StringIO.new msg + argc + argv.join + block
|
23
|
+
|
24
|
+
@ms = DRbDump::MessageSend.new @drbdump, @packet, receiver, stream
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_allocations
|
28
|
+
assert_equal 4, @ms.allocations
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_arguments
|
32
|
+
assert_equal '"a", "b", "c"', @ms.arguments
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_argument_count
|
36
|
+
assert_equal 3, @ms.argument_count
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_argv
|
40
|
+
assert_equal %w[a b c], @ms.argv
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_block
|
44
|
+
assert_nil @ms.block
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_display
|
48
|
+
out, = capture_io do
|
49
|
+
@ms.display
|
50
|
+
end
|
51
|
+
|
52
|
+
expected = <<-EXPECTED
|
53
|
+
23:46:20.561298 "druby://kault:57317" \u21d2 ("druby://kault:57315", nil).message("a", "b", "c")
|
54
|
+
EXPECTED
|
55
|
+
|
56
|
+
assert_equal expected, out
|
57
|
+
|
58
|
+
assert_equal 1, @statistics.drb_messages_sent
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_display_quiet
|
62
|
+
@drbdump.quiet = true
|
63
|
+
|
64
|
+
assert_silent do
|
65
|
+
@ms.display
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal 1, @statistics.drb_messages_sent
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_load_message
|
72
|
+
assert_equal 'message', @ms.raw_message.load
|
73
|
+
assert_equal 3, @ms.argc
|
74
|
+
assert_equal %w[a b c], @ms.raw_argv.map { |obj| obj.load }
|
75
|
+
assert_nil @ms.raw_block.load
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_message
|
79
|
+
assert_equal 'message', @ms.message
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_receiver
|
83
|
+
assert_nil @ms.receiver
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_timestamp
|
87
|
+
first, _, last = packets(FIN_DUMP).first 3
|
88
|
+
|
89
|
+
ms = DRbDump::MessageSend.new @drbdump, last, nil, nil
|
90
|
+
|
91
|
+
assert_equal last.timestamp, ms.timestamp
|
92
|
+
|
93
|
+
@drbdump.incomplete_timestamps[first.source] = first.timestamp
|
94
|
+
|
95
|
+
assert_equal first.timestamp, ms.timestamp
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_update_statistics
|
99
|
+
@ms.update_statistics
|
100
|
+
|
101
|
+
assert_equal 1, @statistics.drb_messages_sent
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'drbdump/test_case'
|
2
|
+
|
3
|
+
class TestDRbDumpStatistic < DRbDump::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@s = DRbDump::Statistic.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_add
|
10
|
+
assert_equal 0, @s.count
|
11
|
+
assert_in_delta 0.0, @s.mean
|
12
|
+
assert_in_delta 0.0, @s.sample_variance
|
13
|
+
assert_in_delta 0.0, @s.standard_deviation
|
14
|
+
assert_equal Float::INFINITY, @s.min
|
15
|
+
assert_equal( -Float::INFINITY, @s.max)
|
16
|
+
|
17
|
+
@s.add 4
|
18
|
+
|
19
|
+
assert_equal 1, @s.count
|
20
|
+
assert_in_delta 4.0, @s.mean
|
21
|
+
assert_in_delta 0.0, @s.sample_variance
|
22
|
+
assert_in_delta 0.0, @s.standard_deviation
|
23
|
+
assert_equal 4, @s.min
|
24
|
+
assert_equal 4, @s.max
|
25
|
+
|
26
|
+
@s.add 7
|
27
|
+
|
28
|
+
assert_equal 2, @s.count
|
29
|
+
assert_in_delta 5.500, @s.mean
|
30
|
+
assert_in_delta 4.500, @s.sample_variance
|
31
|
+
assert_in_delta 2.121, @s.standard_deviation
|
32
|
+
assert_equal 4, @s.min
|
33
|
+
assert_equal 7, @s.max
|
34
|
+
|
35
|
+
@s.add 13
|
36
|
+
|
37
|
+
assert_equal 3, @s.count
|
38
|
+
assert_in_delta 8.000, @s.mean
|
39
|
+
assert_in_delta 21.000, @s.sample_variance
|
40
|
+
assert_in_delta 4.583, @s.standard_deviation
|
41
|
+
assert_equal 4, @s.min
|
42
|
+
assert_equal 13, @s.max
|
43
|
+
|
44
|
+
@s.add 16
|
45
|
+
|
46
|
+
assert_equal 4, @s.count
|
47
|
+
assert_in_delta 10.000, @s.mean
|
48
|
+
assert_in_delta 30.000, @s.sample_variance
|
49
|
+
assert_in_delta 5.477, @s.standard_deviation
|
50
|
+
assert_equal 4, @s.min
|
51
|
+
assert_equal 16, @s.max
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_add_catastrophic_cancellation
|
55
|
+
assert_equal 0, @s.count
|
56
|
+
assert_in_delta 0.0, @s.mean
|
57
|
+
|
58
|
+
@s.add 4 + 10e8
|
59
|
+
|
60
|
+
assert_equal 1, @s.count
|
61
|
+
assert_in_epsilon 4 + 10e8, @s.mean
|
62
|
+
|
63
|
+
@s.add 7 + 10e8
|
64
|
+
|
65
|
+
assert_equal 2, @s.count
|
66
|
+
assert_in_epsilon 5.5 + 10e8, @s.mean
|
67
|
+
assert_in_epsilon 4.5, @s.sample_variance
|
68
|
+
|
69
|
+
@s.add 13 + 10e8
|
70
|
+
|
71
|
+
assert_equal 3, @s.count
|
72
|
+
assert_in_epsilon 8 + 10e8, @s.mean
|
73
|
+
assert_in_epsilon 21.0, @s.sample_variance
|
74
|
+
|
75
|
+
@s.add 16 + 10e8
|
76
|
+
|
77
|
+
assert_equal 4, @s.count
|
78
|
+
assert_in_epsilon 10e8, @s.mean
|
79
|
+
assert_in_epsilon 30.0, @s.sample_variance
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_to_a
|
83
|
+
@s.add 4
|
84
|
+
@s.add 7
|
85
|
+
|
86
|
+
ary = @s.to_a
|
87
|
+
|
88
|
+
assert_equal 2, ary.shift
|
89
|
+
assert_equal 4, ary.shift
|
90
|
+
assert_in_epsilon 5.5, ary.shift
|
91
|
+
assert_equal 7, ary.shift
|
92
|
+
assert_in_epsilon 2.12, ary.shift
|
93
|
+
|
94
|
+
assert_empty ary
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,264 @@
|
|
1
|
+
require 'drbdump/test_case'
|
2
|
+
|
3
|
+
class TestDRbDumpStatistics < DRbDump::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@MS = Marshal::Structure
|
9
|
+
|
10
|
+
drbdump
|
11
|
+
|
12
|
+
@statistics = @drbdump.statistics
|
13
|
+
@packet = packets(ARG_DUMP).first
|
14
|
+
@random = Random.new 2
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_add_message_send
|
18
|
+
receiver = @MS.new "\x04\x080"
|
19
|
+
msg = "\x00\x00\x00\x0b\x04\x08\"\x0cmessage"
|
20
|
+
argc = "\x00\x00\x00\x04\x04\x08i\x08"
|
21
|
+
argv = [
|
22
|
+
"\x00\x00\x00\x07\x04\x08[\x06\"\x06a",
|
23
|
+
"\x00\x00\x00\x0a\x04\x08[\x07\"\x06a\"\x06b",
|
24
|
+
"\x00\x00\x00\x0d\x04\x08[\x08\"\x06a\"\x06b\"\x06c",
|
25
|
+
]
|
26
|
+
block = "\x00\x00\x00\x03\x04\x080"
|
27
|
+
|
28
|
+
stream = StringIO.new msg + argc + argv.join + block
|
29
|
+
|
30
|
+
message = DRbDump::MessageSend.new @drbdump, @packet, receiver, stream
|
31
|
+
|
32
|
+
@statistics.add_message_send message
|
33
|
+
|
34
|
+
assert_equal 1, @statistics.drb_messages_sent
|
35
|
+
|
36
|
+
source = message.source
|
37
|
+
destination = message.destination
|
38
|
+
|
39
|
+
assert_equal @packet.timestamp,
|
40
|
+
@statistics.last_peer_send[source][destination]
|
41
|
+
|
42
|
+
assert_equal ['message', 3, 10],
|
43
|
+
@statistics.last_sent_message[source][destination]
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_add_result_exception
|
47
|
+
status = @MS.new "\x04\x08F"
|
48
|
+
value = StringIO.new "\x00\x00\x00\x08\x04\x08\"\x09FAIL" # fake exception
|
49
|
+
|
50
|
+
result = DRbDump::MessageResult.new @drbdump, @packet, status, value
|
51
|
+
|
52
|
+
source = result.source
|
53
|
+
destination = result.destination
|
54
|
+
|
55
|
+
@statistics.last_peer_send[destination][source] = Time.at 0
|
56
|
+
@statistics.last_sent_message[destination][source] = 'message', 3, 1
|
57
|
+
|
58
|
+
@statistics.add_result result
|
59
|
+
|
60
|
+
assert_equal 1, @statistics.drb_results_received
|
61
|
+
assert_equal 1, @statistics.drb_exceptions_raised
|
62
|
+
|
63
|
+
stat = @statistics.message_allocations['message'][3]
|
64
|
+
|
65
|
+
assert_equal 1, stat.count
|
66
|
+
assert_equal 2.0, stat.mean
|
67
|
+
assert_equal 0.0, stat.standard_deviation
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_add_result_success
|
71
|
+
status = @MS.new "\x04\x08T"
|
72
|
+
value = StringIO.new "\x00\x00\x00\x08\x04\x08\[\x06\"\x07OK"
|
73
|
+
|
74
|
+
result = DRbDump::MessageResult.new @drbdump, @packet, status, value
|
75
|
+
|
76
|
+
source = result.source
|
77
|
+
destination = result.destination
|
78
|
+
|
79
|
+
@statistics.last_peer_send[destination][source] = Time.at 0
|
80
|
+
@statistics.last_sent_message[destination][source] = 'message', 3, 1
|
81
|
+
|
82
|
+
@statistics.add_result result
|
83
|
+
|
84
|
+
assert_equal 1, @statistics.drb_results_received
|
85
|
+
assert_equal 0, @statistics.drb_exceptions_raised
|
86
|
+
|
87
|
+
stat = @statistics.message_allocations['message'][3]
|
88
|
+
|
89
|
+
assert_equal 1, stat.count
|
90
|
+
assert_equal 3.0, stat.mean
|
91
|
+
assert_equal 0.0, stat.standard_deviation
|
92
|
+
|
93
|
+
refute @statistics.last_peer_send[destination][source]
|
94
|
+
assert_equal 1, @statistics.peer_latencies[destination][source].count
|
95
|
+
|
96
|
+
stat = @statistics.message_latencies['message'][3]
|
97
|
+
|
98
|
+
assert_equal 1, stat.count
|
99
|
+
assert_in_epsilon 1364885180.0, stat.mean
|
100
|
+
assert_equal 0.0, stat.standard_deviation
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_adjust_units
|
104
|
+
adjusted = @statistics.adjust_units [0.051, 0.2], 's'
|
105
|
+
|
106
|
+
assert_in_epsilon 0.051, adjusted.shift
|
107
|
+
assert_in_epsilon 0.2, adjusted.shift
|
108
|
+
assert_equal 's', adjusted.shift
|
109
|
+
assert_empty adjusted
|
110
|
+
|
111
|
+
adjusted = @statistics.adjust_units [0.049, 0.2], 's'
|
112
|
+
|
113
|
+
assert_in_epsilon 49.0, adjusted.shift
|
114
|
+
assert_in_epsilon 200.0, adjusted.shift
|
115
|
+
assert_equal 'ms', adjusted.shift
|
116
|
+
assert_empty adjusted
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_merge_results
|
121
|
+
@statistics.message_allocations['one'][2] = statistic
|
122
|
+
@statistics.message_allocations['one'][3] = statistic
|
123
|
+
@statistics.message_allocations['three'][1] = statistic
|
124
|
+
@statistics.message_latencies['one'][2] = statistic
|
125
|
+
@statistics.message_latencies['one'][3] = statistic
|
126
|
+
@statistics.message_latencies['three'][1] = statistic
|
127
|
+
|
128
|
+
_, _, _, allocation_rows =
|
129
|
+
@statistics.extract_and_size @statistics.message_allocations
|
130
|
+
_, _, _, latency_rows =
|
131
|
+
@statistics.extract_and_size @statistics.message_latencies
|
132
|
+
|
133
|
+
results = @statistics.merge_results allocation_rows, latency_rows
|
134
|
+
|
135
|
+
expecteds = [
|
136
|
+
['one', 2, 9, 2.200, 5.809, 10.477, 3.199, 2.272, 4.166, 6.967, 2.476],
|
137
|
+
['one', 3, 6, 3.585, 6.488, 8.198, 1.646, 2.195, 6.282, 10.933, 2.901],
|
138
|
+
['three', 1, 4, 1.653, 3.696, 6.052, 2.298, 1.272, 5.401, 10.537, 2.954],
|
139
|
+
]
|
140
|
+
|
141
|
+
assert_equal expecteds.size, results.size
|
142
|
+
|
143
|
+
result = results.shift
|
144
|
+
expected = expecteds.shift
|
145
|
+
|
146
|
+
assert_equal expected.shift, result.shift, 'message name'
|
147
|
+
assert_equal expected.shift, result.shift, 'argument count'
|
148
|
+
assert_equal expected.shift, result.shift, 'send count'
|
149
|
+
|
150
|
+
assert_in_epsilon expected.shift, result.shift
|
151
|
+
assert_in_epsilon expected.shift, result.shift
|
152
|
+
assert_in_epsilon expected.shift, result.shift
|
153
|
+
assert_in_epsilon expected.shift, result.shift
|
154
|
+
assert_in_epsilon expected.shift, result.shift
|
155
|
+
assert_in_epsilon expected.shift, result.shift
|
156
|
+
assert_in_epsilon expected.shift, result.shift
|
157
|
+
assert_in_epsilon expected.shift, result.shift
|
158
|
+
|
159
|
+
assert_empty result
|
160
|
+
assert_empty expected
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_show_basic
|
164
|
+
@statistics.total_packet_count = 5
|
165
|
+
@statistics.rinda_packet_count = 1
|
166
|
+
@statistics.drb_packet_count = 3
|
167
|
+
@statistics.drb_messages_sent = 1
|
168
|
+
@statistics.drb_results_received = 2
|
169
|
+
@statistics.drb_exceptions_raised = 1
|
170
|
+
|
171
|
+
out, = capture_io do
|
172
|
+
@statistics.show_basic
|
173
|
+
end
|
174
|
+
|
175
|
+
expected = <<-EXPECTED
|
176
|
+
5 total packets captured
|
177
|
+
1 Rinda packets captured
|
178
|
+
3 DRb packets captured
|
179
|
+
1 messages sent
|
180
|
+
2 results received
|
181
|
+
1 exceptions raised
|
182
|
+
EXPECTED
|
183
|
+
|
184
|
+
assert_equal expected, out
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_show_peers
|
188
|
+
@statistics.peer_latencies['a.example.50100']['b.example.51000'] = statistic
|
189
|
+
@statistics.peer_latencies['b.example.51000']['a.example.50100'] = statistic
|
190
|
+
@statistics.peer_latencies['c.example.52000']['a.example.50100'] = statistic
|
191
|
+
|
192
|
+
out, = capture_io do
|
193
|
+
@statistics.show_peers
|
194
|
+
end
|
195
|
+
|
196
|
+
expected = <<-EXPECTED
|
197
|
+
Peers min, avg, max, stddev:
|
198
|
+
9 messages: a.example.50100 to b.example.51000; 2.200, 5.809, 10.477, 3.199 s
|
199
|
+
6 messages: b.example.51000 to a.example.50100; 3.585, 6.488, 8.198, 1.646 s
|
200
|
+
4 messages: c.example.52000 to a.example.50100; 1.653, 3.696, 6.052, 2.298 s
|
201
|
+
EXPECTED
|
202
|
+
|
203
|
+
assert_equal expected, out
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_show_peers_collapse_singles
|
207
|
+
s = DRbDump::Statistic.new
|
208
|
+
s.add rand 2.0
|
209
|
+
@statistics.peer_latencies['a.example.50100']['b.example.51000'] = s
|
210
|
+
s = DRbDump::Statistic.new
|
211
|
+
s.add rand 2.0
|
212
|
+
@statistics.peer_latencies['b.example.51000']['a.example.50100'] = s
|
213
|
+
s = DRbDump::Statistic.new
|
214
|
+
s.add rand 2.0
|
215
|
+
@statistics.peer_latencies['c.example.52000']['a.example.50100'] = s
|
216
|
+
|
217
|
+
out, = capture_io do
|
218
|
+
@statistics.show_peers
|
219
|
+
end
|
220
|
+
|
221
|
+
expected = <<-EXPECTED
|
222
|
+
Peers min, avg, max, stddev:
|
223
|
+
3 single-message peers 0.052, 0.674, 1.099, 0.551 s
|
224
|
+
EXPECTED
|
225
|
+
|
226
|
+
assert_equal expected, out
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_show_messages
|
230
|
+
@statistics.message_allocations['one'][2] = statistic
|
231
|
+
@statistics.message_allocations['one'][3] = statistic
|
232
|
+
@statistics.message_allocations['three'][1] = statistic
|
233
|
+
@statistics.message_latencies['one'][2] = statistic
|
234
|
+
@statistics.message_latencies['one'][3] = statistic
|
235
|
+
@statistics.message_latencies['three'][1] = statistic
|
236
|
+
|
237
|
+
out, = capture_io do
|
238
|
+
@statistics.show_messages
|
239
|
+
end
|
240
|
+
|
241
|
+
expected = <<-EXPECTED
|
242
|
+
Messages sent min, avg, max, stddev:
|
243
|
+
one (2 args) 9 sent; 2.2, 5.8, 10.5, 3.2 allocations; 2.272, 4.166, 6.967, 2.476 s
|
244
|
+
one (3 args) 6 sent; 3.6, 6.5, 8.2, 1.6 allocations; 2.195, 6.282, 10.933, 2.901 s
|
245
|
+
three (1 args) 4 sent; 1.7, 3.7, 6.1, 2.3 allocations; 1.272, 5.401, 10.537, 2.954 s
|
246
|
+
EXPECTED
|
247
|
+
|
248
|
+
assert_equal expected, out
|
249
|
+
end
|
250
|
+
|
251
|
+
def rand *args
|
252
|
+
@random.rand(*args)
|
253
|
+
end
|
254
|
+
|
255
|
+
def statistic
|
256
|
+
s = DRbDump::Statistic.new
|
257
|
+
rand(1..20).times do
|
258
|
+
s.add rand 1..11.0
|
259
|
+
end
|
260
|
+
s
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
|