dnsruby 1.55 → 1.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +96 -0
- data/Rakefile +30 -29
- data/demo/axfr.rb +93 -93
- data/demo/check_soa.rb +99 -99
- data/demo/check_zone.rb +59 -59
- data/demo/digdlv.rb +43 -43
- data/demo/digroot.rb +34 -34
- data/demo/example_recurse.rb +14 -14
- data/demo/mresolv.rb +30 -30
- data/demo/mx.rb +31 -31
- data/demo/rubydig.rb +37 -37
- data/demo/to_resolve.txt +3088 -3088
- data/demo/trace_dns.rb +46 -46
- data/lib/dnsruby.rb +161 -526
- data/lib/dnsruby/DNS.rb +305 -0
- data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
- data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
- data/lib/dnsruby/code_mappers.rb +295 -0
- data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
- data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
- data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
- data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
- data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
- data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
- data/lib/dnsruby/message/decoder.rb +164 -0
- data/lib/dnsruby/message/encoder.rb +75 -0
- data/lib/dnsruby/message/header.rb +249 -0
- data/lib/dnsruby/message/message.rb +629 -0
- data/lib/dnsruby/message/question.rb +86 -0
- data/lib/dnsruby/message/section.rb +96 -0
- data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
- data/lib/dnsruby/packet_sender.rb +661 -0
- data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
- data/lib/dnsruby/resolv.rb +113 -0
- data/lib/dnsruby/resolver.rb +1192 -0
- data/lib/dnsruby/resource/A.rb +56 -0
- data/lib/dnsruby/resource/AAAA.rb +54 -0
- data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
- data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
- data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
- data/lib/dnsruby/resource/DLV.rb +27 -0
- data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
- data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
- data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
- data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
- data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
- data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
- data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
- data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
- data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
- data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
- data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
- data/lib/dnsruby/resource/NSEC.rb +275 -0
- data/lib/dnsruby/resource/NSEC3.rb +332 -0
- data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
- data/lib/dnsruby/resource/OPT.rb +272 -0
- data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
- data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
- data/lib/dnsruby/resource/RR.rb +421 -0
- data/lib/dnsruby/resource/RRSIG.rb +275 -0
- data/lib/dnsruby/resource/RRSet.rb +190 -0
- data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
- data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
- data/lib/dnsruby/resource/SPF.rb +29 -0
- data/lib/dnsruby/resource/SRV.rb +112 -0
- data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
- data/lib/dnsruby/resource/TKEY.rb +163 -0
- data/lib/dnsruby/resource/TSIG.rb +593 -0
- data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
- data/lib/dnsruby/resource/X25.rb +55 -0
- data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
- data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
- data/lib/dnsruby/resource/resource.rb +25 -0
- data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
- data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
- data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
- data/lib/dnsruby/the_log.rb +44 -0
- data/lib/dnsruby/update.rb +278 -0
- data/lib/dnsruby/validator_thread.rb +124 -0
- data/lib/dnsruby/version.rb +3 -0
- data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
- data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
- data/test/spec_helper.rb +16 -0
- data/test/tc_axfr.rb +31 -34
- data/test/tc_cache.rb +32 -32
- data/test/tc_dlv.rb +28 -28
- data/test/tc_dns.rb +73 -76
- data/test/tc_dnskey.rb +31 -32
- data/test/tc_dnsruby.rb +50 -44
- data/test/tc_ds.rb +36 -36
- data/test/tc_escapedchars.rb +252 -255
- data/test/tc_hash.rb +17 -21
- data/test/tc_header.rb +48 -57
- data/test/tc_hip.rb +19 -22
- data/test/tc_ipseckey.rb +18 -21
- data/test/tc_keith.rb +300 -0
- data/test/tc_message.rb +87 -0
- data/test/tc_misc.rb +83 -87
- data/test/tc_name.rb +81 -84
- data/test/tc_naptr.rb +18 -21
- data/test/tc_nsec.rb +55 -55
- data/test/tc_nsec3.rb +23 -24
- data/test/tc_nsec3param.rb +20 -21
- data/test/tc_packet.rb +90 -93
- data/test/tc_packet_unique_push.rb +48 -51
- data/test/tc_question.rb +30 -33
- data/test/tc_queue.rb +16 -17
- data/test/tc_recur.rb +16 -17
- data/test/tc_res_config.rb +38 -41
- data/test/tc_res_env.rb +29 -32
- data/test/tc_res_file.rb +26 -29
- data/test/tc_res_opt.rb +62 -65
- data/test/tc_resolver.rb +287 -242
- data/test/tc_rr-opt.rb +70 -63
- data/test/tc_rr-txt.rb +68 -71
- data/test/tc_rr-unknown.rb +45 -48
- data/test/tc_rr.rb +76 -70
- data/test/tc_rrset.rb +21 -22
- data/test/tc_rrsig.rb +19 -20
- data/test/tc_single_resolver.rb +294 -297
- data/test/tc_soak.rb +199 -202
- data/test/tc_soak_base.rb +29 -34
- data/test/tc_sshfp.rb +20 -23
- data/test/tc_tcp.rb +32 -35
- data/test/tc_tkey.rb +41 -44
- data/test/tc_tsig.rb +81 -84
- data/test/tc_update.rb +108 -111
- data/test/tc_validator.rb +29 -29
- data/test/tc_verifier.rb +81 -82
- data/test/ts_dnsruby.rb +16 -15
- data/test/ts_offline.rb +62 -63
- data/test/ts_online.rb +115 -115
- metadata +155 -90
- data/README +0 -59
- data/lib/Dnsruby/DNS.rb +0 -305
- data/lib/Dnsruby/PacketSender.rb +0 -656
- data/lib/Dnsruby/Resolver.rb +0 -1189
- data/lib/Dnsruby/TheLog.rb +0 -44
- data/lib/Dnsruby/message.rb +0 -1230
- data/lib/Dnsruby/resource/A.rb +0 -56
- data/lib/Dnsruby/resource/AAAA.rb +0 -54
- data/lib/Dnsruby/resource/DLV.rb +0 -27
- data/lib/Dnsruby/resource/NSEC.rb +0 -298
- data/lib/Dnsruby/resource/NSEC3.rb +0 -340
- data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
- data/lib/Dnsruby/resource/OPT.rb +0 -213
- data/lib/Dnsruby/resource/RRSIG.rb +0 -275
- data/lib/Dnsruby/resource/SPF.rb +0 -29
- data/lib/Dnsruby/resource/SRV.rb +0 -112
- data/lib/Dnsruby/resource/TKEY.rb +0 -163
- data/lib/Dnsruby/resource/TSIG.rb +0 -593
- data/lib/Dnsruby/resource/X25.rb +0 -55
- data/lib/Dnsruby/resource/resource.rb +0 -678
- data/lib/Dnsruby/update.rb +0 -278
- data/lib/Dnsruby/validator_thread.rb +0 -124
data/test/tc_soak.rb
CHANGED
@@ -1,203 +1,200 @@
|
|
1
|
-
|
2
|
-
#Copyright 2007 Nominet UK
|
3
|
-
#
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
#you may not use this file except in compliance with the License.
|
6
|
-
#You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
#See the License for the specific language governing permissions and
|
14
|
-
#limitations under the License.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
require 'test/
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
end
|
201
|
-
|
202
|
-
|
1
|
+
# --
|
2
|
+
# Copyright 2007 Nominet UK
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
17
|
+
require_relative 'spec_helper'
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'test/tc_single_resolver'
|
21
|
+
rescue LoadError
|
22
|
+
require 'tc_single_resolver'
|
23
|
+
end
|
24
|
+
begin
|
25
|
+
require 'test/tc_soak_base'
|
26
|
+
rescue LoadError
|
27
|
+
require 'tc_soak_base'
|
28
|
+
end
|
29
|
+
include Dnsruby
|
30
|
+
# This class tries to soak test the Dnsruby library.
|
31
|
+
# It can't do this very well, owing to the small number of sockets allowed to be open simultaneously.
|
32
|
+
# @TODO@ Future versions of dnsruby will allow random streaming over a fixed number of (cycling) random sockets,
|
33
|
+
# so this test can be beefed up considerably at that point.
|
34
|
+
# @todo@ A test DNS server running on localhost is really needed here
|
35
|
+
class TestSingleResolverSoak < Minitest::Test
|
36
|
+
|
37
|
+
def test_many_asynchronous_queries_one_single_resolver
|
38
|
+
run_many_asynch_queries_test_single_res(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_many_asynchronous_queries_many_single_resolvers
|
42
|
+
run_many_asynch_queries_test_single_res(50)
|
43
|
+
end
|
44
|
+
|
45
|
+
def run_many_asynch_queries_test_single_res(num_resolvers)
|
46
|
+
q = Queue.new
|
47
|
+
resolvers = []
|
48
|
+
timed_out = 0
|
49
|
+
query_count = 0
|
50
|
+
num_resolvers.times do |n|
|
51
|
+
resolvers.push(SingleResolver.new)
|
52
|
+
resolvers[n].packet_timeout=4
|
53
|
+
end
|
54
|
+
res_pos = 0
|
55
|
+
start = Time.now
|
56
|
+
# @todo@ On windows, MAX_FILES is 256. This means that we have to limit
|
57
|
+
# this test while we're not using single sockets.
|
58
|
+
# We run four queries per iteration, so we're limited to 64 runs.
|
59
|
+
63.times do |i|
|
60
|
+
rr_count = 0
|
61
|
+
TestSoakBase::Rrs.each do |data|
|
62
|
+
rr_count+=1
|
63
|
+
res = resolvers[res_pos]
|
64
|
+
res_pos=+1
|
65
|
+
if (res_pos >= num_resolvers)
|
66
|
+
res_pos = 0
|
67
|
+
end
|
68
|
+
res.send_async(Message.new(data[:name], data[:type]), q, [i,rr_count])
|
69
|
+
# p "Sent #{i}, #{rr_count}, Queue #{q}"
|
70
|
+
query_count+=1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
query_count.times do |i|
|
74
|
+
id,ret, error = q.pop
|
75
|
+
if (error.class == ResolvTimeout)
|
76
|
+
timed_out+=1
|
77
|
+
elsif (ret.class != Message)
|
78
|
+
p "ERROR RETURNED : #{error}"
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
stop=Time.now
|
83
|
+
time_taken=stop-start
|
84
|
+
p "Query count : #{query_count}, #{timed_out} timed out. #{time_taken} time taken"
|
85
|
+
assert(timed_out < query_count * 0.1, "#{timed_out} of #{query_count} timed out!")
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def test_many_threads_on_one_single_resolver_synchronous
|
90
|
+
# Test multi-threaded behaviour
|
91
|
+
# Check the header IDs to make sure they're all different
|
92
|
+
threads = Array.new
|
93
|
+
res = SingleResolver.new
|
94
|
+
ids = []
|
95
|
+
mutex = Mutex.new
|
96
|
+
timed_out = 0
|
97
|
+
query_count = 0
|
98
|
+
res.packet_timeout=4
|
99
|
+
start=Time.now
|
100
|
+
# Windows limits us to 256 sockets
|
101
|
+
num_times=250
|
102
|
+
if (/java/ =~ RUBY_PLATFORM)
|
103
|
+
# JRuby threads are native threads, so let's not go too mad!
|
104
|
+
num_times=50
|
105
|
+
end
|
106
|
+
num_times.times do |i|
|
107
|
+
threads[i] = Thread.new{
|
108
|
+
40.times do |j|
|
109
|
+
TestSoakBase::Rrs.each do |data|
|
110
|
+
mutex.synchronize do
|
111
|
+
query_count+=1
|
112
|
+
end
|
113
|
+
packet=nil
|
114
|
+
begin
|
115
|
+
packet = res.query(data[:name], data[:type])
|
116
|
+
rescue ResolvTimeout
|
117
|
+
mutex.synchronize {
|
118
|
+
timed_out+=1
|
119
|
+
}
|
120
|
+
next
|
121
|
+
end
|
122
|
+
assert(packet)
|
123
|
+
ids.push(packet.header.id)
|
124
|
+
assert_equal(packet.question[0].qclass, 'IN', 'Class correct' )
|
125
|
+
end
|
126
|
+
end
|
127
|
+
}
|
128
|
+
end
|
129
|
+
threads.each do |thread|
|
130
|
+
thread.join
|
131
|
+
end
|
132
|
+
stop=Time.now
|
133
|
+
time_taken=stop-start
|
134
|
+
p "Query count : #{query_count}, #{timed_out} timed out. #{time_taken} time taken"
|
135
|
+
# check_ids(ids) # only do this if we expect all different IDs - e.g. if we stream over a single socket
|
136
|
+
assert(timed_out < query_count * 0.1, "#{timed_out} of #{query_count} timed out!")
|
137
|
+
end
|
138
|
+
|
139
|
+
def check_ids(ids)
|
140
|
+
ids.sort!
|
141
|
+
count = 0
|
142
|
+
ids.each do |id|
|
143
|
+
count+=1
|
144
|
+
if (count < ids.length-1)
|
145
|
+
assert(ids[count+1] != id, "Two identical header ids used!")
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_many_threads_on_many_single_resolvers
|
151
|
+
# Test multi-threaded behaviour
|
152
|
+
# @todo@ Check the header IDs to make sure they're all different
|
153
|
+
threads = Array.new
|
154
|
+
mutex = Mutex.new
|
155
|
+
timed_out = 0
|
156
|
+
query_count = 0
|
157
|
+
start=Time.now
|
158
|
+
num_times=250
|
159
|
+
if (/java/ =~ RUBY_PLATFORM)
|
160
|
+
# JRuby threads are native threads, so let's not go too mad!
|
161
|
+
num_times=50
|
162
|
+
end
|
163
|
+
num_times.times do |i|
|
164
|
+
threads[i] = Thread.new{
|
165
|
+
res = SingleResolver.new
|
166
|
+
res.packet_timeout=4
|
167
|
+
40.times do |j|
|
168
|
+
TestSoakBase::Rrs.each do |data|
|
169
|
+
mutex.synchronize do
|
170
|
+
query_count+=1
|
171
|
+
end
|
172
|
+
q = Queue.new
|
173
|
+
res.send_async(Message.new(data[:name], data[:type]), q, [i,j])
|
174
|
+
id, packet, error = q.pop
|
175
|
+
if (error.class == ResolvTimeout)
|
176
|
+
mutex.synchronize {
|
177
|
+
timed_out+=1
|
178
|
+
}
|
179
|
+
next
|
180
|
+
elsif (packet.class!=Message)
|
181
|
+
p "ERROR! #{error}"
|
182
|
+
end
|
183
|
+
|
184
|
+
assert(packet)
|
185
|
+
assert_equal(packet.question[0].qclass, 'IN', 'Class correct' )
|
186
|
+
end
|
187
|
+
end
|
188
|
+
}
|
189
|
+
end
|
190
|
+
threads.each do |thread|
|
191
|
+
thread.join
|
192
|
+
end
|
193
|
+
stop=Time.now
|
194
|
+
time_taken=stop-start
|
195
|
+
p "Query count : #{query_count}, #{timed_out} timed out. #{time_taken} time taken"
|
196
|
+
assert(timed_out < query_count * 0.1, "#{timed_out} of #{query_count} timed out!")
|
197
|
+
end
|
198
|
+
|
199
|
+
|
203
200
|
end
|
data/test/tc_soak_base.rb
CHANGED
@@ -1,27 +1,22 @@
|
|
1
|
-
|
2
|
-
#Copyright 2007 Nominet UK
|
3
|
-
#
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
#you may not use this file except in compliance with the License.
|
6
|
-
#You may obtain a copy of the License at
|
7
|
-
#
|
1
|
+
# --
|
2
|
+
# Copyright 2007 Nominet UK
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
#See the License for the specific language governing permissions and
|
14
|
-
#limitations under the License.
|
15
|
-
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
16
|
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
rescue LoadError
|
20
|
-
end
|
21
|
-
require 'test/unit'
|
22
|
-
require 'dnsruby'
|
17
|
+
require_relative 'spec_helper'
|
23
18
|
|
24
|
-
class TestSoakBase # < Test
|
19
|
+
class TestSoakBase # < Minitest::Test
|
25
20
|
include Dnsruby
|
26
21
|
Rrs = [
|
27
22
|
{
|
@@ -44,12 +39,12 @@ class TestSoakBase # < Test::Unit::TestCase
|
|
44
39
|
:type => Types.TXT,
|
45
40
|
:name => 'txt.t.dnsruby.validation-test-servers.nominet.org.uk',
|
46
41
|
:strings => ['Net-DNS']
|
47
|
-
}
|
48
|
-
]
|
42
|
+
}
|
43
|
+
]
|
49
44
|
|
50
45
|
def TestSoakBase.test_continuous_queries_asynch_single_res
|
51
|
-
#
|
52
|
-
#
|
46
|
+
# Have two threads looping, with one sending, and one receiving queries.
|
47
|
+
# Never exceed more than 200 concurrent queries, but make sure they're always running.
|
53
48
|
outstanding_limit = 1
|
54
49
|
num_loops = 2000
|
55
50
|
num_sent = 0
|
@@ -76,7 +71,7 @@ class TestSoakBase # < Test::Unit::TestCase
|
|
76
71
|
}
|
77
72
|
end
|
78
73
|
end
|
79
|
-
|
74
|
+
|
80
75
|
}
|
81
76
|
receiver = Thread.new{
|
82
77
|
(num_loops*4).times do |i|
|
@@ -86,7 +81,7 @@ class TestSoakBase # < Test::Unit::TestCase
|
|
86
81
|
}
|
87
82
|
if (error.class == ResolvTimeout)
|
88
83
|
timed_out+=1
|
89
|
-
#
|
84
|
+
# p "Number #{i} timed out!"
|
90
85
|
elsif (ret.class != Message)
|
91
86
|
Dnsruby.log.debug("tc_single_resolver : Query #{i} ERROR RETURNED : #{error.class}, #{error}")
|
92
87
|
end
|
@@ -100,10 +95,10 @@ class TestSoakBase # < Test::Unit::TestCase
|
|
100
95
|
p "Query count : #{num_sent}, #{timed_out} timed out. #{time_taken} time taken"
|
101
96
|
assert(timed_out < num_sent * 0.1, "#{timed_out} of #{num_sent} timed out!")
|
102
97
|
end
|
103
|
-
|
98
|
+
|
104
99
|
def TestSoakBase.test_continuous_queries_asynch_resolver
|
105
|
-
#
|
106
|
-
#
|
100
|
+
# Have two threads looping, with one sending, and one receiving queries.
|
101
|
+
# Never exceed more than 250 concurrent queries, but make sure they're always running.
|
107
102
|
num_loops = 1000
|
108
103
|
num_sent = 0
|
109
104
|
q = Queue.new
|
@@ -113,9 +108,9 @@ class TestSoakBase # < Test::Unit::TestCase
|
|
113
108
|
num_in_progress = 0
|
114
109
|
sender = Thread.new{
|
115
110
|
res = Resolver.new
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
111
|
+
# On windows, MAX_FILES is 256. This means that we have to limit
|
112
|
+
# this test while we're not using single sockets.
|
113
|
+
# We run four queries per iteration, so we're limited to 64 runs.
|
119
114
|
num_loops.times do |i|
|
120
115
|
while (mutex.synchronize{num_in_progress> 50}) do # One query has several sockets in Resolver
|
121
116
|
sleep(0.01)
|
@@ -136,7 +131,7 @@ class TestSoakBase # < Test::Unit::TestCase
|
|
136
131
|
}
|
137
132
|
if (error.class == ResolvTimeout)
|
138
133
|
timed_out+=1
|
139
|
-
#
|
134
|
+
# p "Number #{i} timed out!"
|
140
135
|
elsif (ret.class != Message)
|
141
136
|
error_count+=1
|
142
137
|
Dnsruby.log.error("tc_single_resolver : Query #{i} ERROR RETURNED : #{error.class}, #{error}")
|