mogilefs-client 3.7.1 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +0 -1
- data/.gitignore +3 -3
- data/{.wrongdoc.yml → .olddoc.yml} +2 -0
- data/GIT-VERSION-GEN +13 -2
- data/GNUmakefile +12 -86
- data/README +19 -9
- data/TODO +0 -4
- data/examples/mog-sync.rb +245 -0
- data/examples/usage_fetcher.rb +44 -0
- data/lib/mogilefs/admin.rb +12 -10
- data/mogilefs-client.gemspec +20 -0
- data/pkg.mk +150 -0
- data/test/fresh.rb +10 -82
- data/test/setup.rb +2 -6
- data/test/test_admin.rb +25 -1
- data/test/test_fresh.rb +71 -0
- data/test/test_mogilefs.rb +25 -29
- data/test/test_mogilefs_integration.rb +15 -5
- data/test/test_mogilefs_integration_large_pipe.rb +7 -3
- data/test/test_mogilefs_integration_list_keys.rb +8 -4
- data/test/test_mogtool_bigfile.rb +7 -3
- metadata +39 -76
- data/.gemtest +0 -0
- data/Rakefile +0 -56
- data/test/integration.rb +0 -43
@@ -0,0 +1,44 @@
|
|
1
|
+
# example to fetch all usage files into the current directory
|
2
|
+
# This will download dev*/usage files to the current files with the template:
|
3
|
+
# ${HOSTNAME}_${PORT}_dev$DEVID.txt
|
4
|
+
$stderr.sync = $stdout.sync = Thread.abort_on_exception = true
|
5
|
+
ARGV.empty? and abort "Usage: #$0 TRACKERS"
|
6
|
+
|
7
|
+
require 'net/http/persistent' # gem install net-http-persistent
|
8
|
+
require 'uri'
|
9
|
+
require 'thread'
|
10
|
+
require 'mogilefs'
|
11
|
+
queue = Queue.new
|
12
|
+
nhp = Net::HTTP::Persistent.new
|
13
|
+
adm = MogileFS::Admin.new(hosts: ARGV)
|
14
|
+
|
15
|
+
by_hostid = {}
|
16
|
+
adm.get_hosts.each { |host| by_hostid[host["hostid"]] = host }
|
17
|
+
by_hostid.freeze # by_hostid is read-only at this point
|
18
|
+
|
19
|
+
nr = by_hostid.size
|
20
|
+
thr = nr.times.map do
|
21
|
+
Thread.new do
|
22
|
+
while dev = queue.shift
|
23
|
+
host = by_hostid[dev["hostid"]]
|
24
|
+
port = host["http_get_port"] || host["http_port"]
|
25
|
+
devid = dev["devid"]
|
26
|
+
url = "http://#{host["hostip"]}:#{port}/dev#{devid}/usage"
|
27
|
+
uri = URI(url)
|
28
|
+
response = nhp.request(uri)
|
29
|
+
body = response.body
|
30
|
+
File.open("#{host["hostname"]}_#{port}_dev#{devid}.txt", "w") do |fp|
|
31
|
+
fp.write(body)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
adm.get_devices.each do |dev|
|
38
|
+
case dev["status"]
|
39
|
+
when "alive", "readonly", "drain"
|
40
|
+
queue.push(dev)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
nr.times { queue.push(nil) } # terminate the threads
|
44
|
+
thr.each(&:join)
|
data/lib/mogilefs/admin.rb
CHANGED
@@ -29,9 +29,9 @@ class MogileFS::Admin < MogileFS::Client
|
|
29
29
|
#
|
30
30
|
# [{"status"=>"alive",
|
31
31
|
# "http_get_port"=>nil,
|
32
|
-
# "http_port"=>
|
33
|
-
# "hostid"=>
|
34
|
-
# "hostip"=>"",
|
32
|
+
# "http_port"=>7500,
|
33
|
+
# "hostid"=>1,
|
34
|
+
# "hostip"=>"192.168.1.2",
|
35
35
|
# "hostname"=>"rur-1",
|
36
36
|
# "altip"=>"",
|
37
37
|
# "altmask"=>""}]
|
@@ -64,17 +64,18 @@ class MogileFS::Admin < MogileFS::Client
|
|
64
64
|
|
65
65
|
def get_devices(devid = nil)
|
66
66
|
to_i = %w(mb_asof mb_free mb_used mb_total devid weight hostid)
|
67
|
-
want = %w(status observed_state).concat(to_i)
|
67
|
+
want = %w(status reject_bad_md5 observed_state utilization).concat(to_i)
|
68
68
|
rv = @backend.get_devices(devid ? { :devid => devid } : {})
|
69
69
|
rv = clean('devices', 'dev', rv, true, to_i, want)
|
70
|
-
ostates = Hash[%w(readable writeable unreachable).map! { |f| [f,f] }]
|
71
70
|
|
72
71
|
rv.each do |row|
|
73
72
|
u = row["utilization"] and
|
74
73
|
row["utilization"] = nil == u ? nil : u.to_f
|
75
74
|
|
76
|
-
|
77
|
-
|
75
|
+
case row["observed_state"]
|
76
|
+
when ""
|
77
|
+
row["observed_state"] = nil
|
78
|
+
end
|
78
79
|
|
79
80
|
# be sure we do not set this at all for pre-2.60 MogileFS-Server
|
80
81
|
case row["reject_bad_md5"]
|
@@ -119,6 +120,7 @@ class MogileFS::Admin < MogileFS::Client
|
|
119
120
|
#
|
120
121
|
# *** This command no longer works with recent versions of MogileFS ***
|
121
122
|
# *** Use mogstats(1) from the MogileFS::Utils package on CPAN ***
|
123
|
+
# *** We will remove this method in 4.x ***
|
122
124
|
#
|
123
125
|
# admin.get_stats
|
124
126
|
#
|
@@ -147,9 +149,9 @@ class MogileFS::Admin < MogileFS::Client
|
|
147
149
|
}
|
148
150
|
end
|
149
151
|
|
150
|
-
|
151
|
-
|
152
|
-
|
152
|
+
%w(device file replication).each do |s|
|
153
|
+
stats.delete(s) if stats[s].empty?
|
154
|
+
end
|
153
155
|
|
154
156
|
stats
|
155
157
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
ENV["VERSION"] or abort "VERSION= must be specified"
|
2
|
+
require 'olddoc'
|
3
|
+
$LOAD_PATH << 'lib'
|
4
|
+
require 'mogilefs'
|
5
|
+
extend Olddoc::Gemspec
|
6
|
+
name, summary, title = readme_metadata
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
manifest = File.read('.manifest').split(/\n/)
|
9
|
+
s.name = 'mogilefs-client'
|
10
|
+
s.version = MogileFS::VERSION
|
11
|
+
s.executables = %w(mog)
|
12
|
+
s.authors = ["#{s.name} hackers"]
|
13
|
+
s.summary = summary
|
14
|
+
s.description = readme_description
|
15
|
+
s.email = Olddoc.config['private_email']
|
16
|
+
s.files = manifest
|
17
|
+
s.add_development_dependency('olddoc', '~> 1.0')
|
18
|
+
s.homepage = Olddoc.config['rdoc_url']
|
19
|
+
s.license = 'BSD-3-Clause'
|
20
|
+
end
|
data/pkg.mk
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
RUBY = ruby
|
2
|
+
RAKE = rake
|
3
|
+
RSYNC = rsync
|
4
|
+
OLDDOC = olddoc
|
5
|
+
RDOC = rdoc
|
6
|
+
|
7
|
+
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
|
8
|
+
@./GIT-VERSION-GEN
|
9
|
+
-include GIT-VERSION-FILE
|
10
|
+
-include local.mk
|
11
|
+
DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
|
12
|
+
RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
|
13
|
+
RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
|
14
|
+
lib := lib
|
15
|
+
|
16
|
+
ext := $(firstword $(wildcard ext/*))
|
17
|
+
ifneq ($(ext),)
|
18
|
+
ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
|
19
|
+
ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
|
20
|
+
ext_src := $(wildcard $(ext)/*.c $(ext_h))
|
21
|
+
ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
|
22
|
+
ext_d := $(ext_pfx)/$(ext)/.d
|
23
|
+
$(ext)/extconf.rb: $(wildcard $(ext)/*.h)
|
24
|
+
@>> $@
|
25
|
+
$(ext_d):
|
26
|
+
@mkdir -p $(@D)
|
27
|
+
@> $@
|
28
|
+
$(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
|
29
|
+
install -m 644 $< $@
|
30
|
+
$(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
|
31
|
+
$(RM) -f $(@D)/*.o
|
32
|
+
cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
|
33
|
+
ext_sfx := _ext.$(DLEXT)
|
34
|
+
ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
|
35
|
+
$(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
|
36
|
+
@echo $^ == $@
|
37
|
+
$(MAKE) -C $(@D)
|
38
|
+
lib := $(lib):$(ext_pfx)/$(ext)
|
39
|
+
build: $(ext_dl)
|
40
|
+
else
|
41
|
+
build:
|
42
|
+
endif
|
43
|
+
|
44
|
+
pkg_extra += GIT-VERSION-FILE NEWS LATEST
|
45
|
+
NEWS: GIT-VERSION-FILE .olddoc.yml
|
46
|
+
$(OLDDOC) prepare
|
47
|
+
LATEST: NEWS
|
48
|
+
|
49
|
+
manifest:
|
50
|
+
$(RM) .manifest
|
51
|
+
$(MAKE) .manifest
|
52
|
+
|
53
|
+
.manifest: $(pkg_extra)
|
54
|
+
(git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
|
55
|
+
LC_ALL=C sort > $@+
|
56
|
+
cmp $@+ $@ || mv $@+ $@
|
57
|
+
$(RM) $@+
|
58
|
+
|
59
|
+
doc:: .document .olddoc.yml $(pkg_extra) $(PLACEHOLDERS)
|
60
|
+
-find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
|
61
|
+
-find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
|
62
|
+
$(RM) -r doc
|
63
|
+
$(RDOC) -f oldweb
|
64
|
+
$(OLDDOC) merge
|
65
|
+
if test -f COPYING; then install -m644 COPYING doc/COPYING; fi
|
66
|
+
install -m644 NEWS doc/NEWS
|
67
|
+
install -m644 NEWS.atom.xml doc/NEWS.atom.xml
|
68
|
+
install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
|
69
|
+
|
70
|
+
ifneq ($(VERSION),)
|
71
|
+
pkggem := pkg/$(rfpackage)-$(VERSION).gem
|
72
|
+
pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
|
73
|
+
|
74
|
+
# ensures we're actually on the tagged $(VERSION), only used for release
|
75
|
+
verify:
|
76
|
+
test x"$(shell umask)" = x0022
|
77
|
+
git rev-parse --verify refs/tags/v$(VERSION)^{}
|
78
|
+
git diff-index --quiet HEAD^0
|
79
|
+
test $$(git rev-parse --verify HEAD^0) = \
|
80
|
+
$$(git rev-parse --verify refs/tags/v$(VERSION)^{})
|
81
|
+
|
82
|
+
fix-perms:
|
83
|
+
-git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
|
84
|
+
-git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
|
85
|
+
|
86
|
+
gem: $(pkggem)
|
87
|
+
|
88
|
+
install-gem: $(pkggem)
|
89
|
+
gem install $(CURDIR)/$<
|
90
|
+
|
91
|
+
$(pkggem): manifest fix-perms
|
92
|
+
gem build $(rfpackage).gemspec
|
93
|
+
mkdir -p pkg
|
94
|
+
mv $(@F) $@
|
95
|
+
|
96
|
+
$(pkgtgz): distdir = $(basename $@)
|
97
|
+
$(pkgtgz): HEAD = v$(VERSION)
|
98
|
+
$(pkgtgz): manifest fix-perms
|
99
|
+
@test -n "$(distdir)"
|
100
|
+
$(RM) -r $(distdir)
|
101
|
+
mkdir -p $(distdir)
|
102
|
+
tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
|
103
|
+
cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
|
104
|
+
mv $@+ $@
|
105
|
+
|
106
|
+
package: $(pkgtgz) $(pkggem)
|
107
|
+
|
108
|
+
release:: verify package
|
109
|
+
# push gem to RubyGems.org
|
110
|
+
gem push $(pkggem)
|
111
|
+
else
|
112
|
+
gem install-gem: GIT-VERSION-FILE
|
113
|
+
$(MAKE) $@ VERSION=$(GIT_VERSION)
|
114
|
+
endif
|
115
|
+
|
116
|
+
all:: check
|
117
|
+
test_units := $(wildcard test/test_*.rb)
|
118
|
+
test: check
|
119
|
+
check: test-unit
|
120
|
+
test-unit: $(test_units)
|
121
|
+
$(test_units): build
|
122
|
+
$(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
|
123
|
+
|
124
|
+
# this requires GNU coreutils variants
|
125
|
+
ifneq ($(RSYNC_DEST),)
|
126
|
+
publish_doc:
|
127
|
+
-git set-file-times
|
128
|
+
$(MAKE) doc
|
129
|
+
$(MAKE) doc_gz
|
130
|
+
$(RSYNC) -av doc/ $(RSYNC_DEST)/
|
131
|
+
git ls-files | xargs touch
|
132
|
+
endif
|
133
|
+
|
134
|
+
# Create gzip variants of the same timestamp as the original so nginx
|
135
|
+
# "gzip_static on" can serve the gzipped versions directly.
|
136
|
+
doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
|
137
|
+
doc_gz:
|
138
|
+
for i in $(docs); do \
|
139
|
+
gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
|
140
|
+
check-warnings:
|
141
|
+
@(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
|
142
|
+
do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
|
143
|
+
|
144
|
+
ifneq ($(PLACEHOLDERS),)
|
145
|
+
$(PLACEHOLDERS):
|
146
|
+
echo olddoc_placeholder > $@
|
147
|
+
endif
|
148
|
+
|
149
|
+
.PHONY: all .FORCE-GIT-VERSION-FILE doc check test $(test_units) manifest
|
150
|
+
.PHONY: check-warnings
|
data/test/fresh.rb
CHANGED
@@ -7,24 +7,22 @@ require "net/http"
|
|
7
7
|
module TestFreshSetup
|
8
8
|
include TestExec
|
9
9
|
|
10
|
-
def setup
|
11
|
-
setup_mogilefs
|
12
|
-
end
|
13
|
-
|
14
10
|
def setup_mogilefs(plugins = nil)
|
11
|
+
@teardown_pid = $$
|
15
12
|
@test_host = "127.0.0.1"
|
16
13
|
setup_mogstored
|
17
14
|
@tracker = TCPServer.new(@test_host, 0)
|
18
15
|
@tracker_port = @tracker.addr[1]
|
19
16
|
|
20
|
-
@dbname = Tempfile.new(["mogfresh", ".sqlite3"])
|
21
|
-
@mogilefsd_conf = Tempfile.new(["mogilefsd", "conf"])
|
22
|
-
@mogilefsd_pid = Tempfile.new(["mogilefsd", "pid"])
|
17
|
+
@dbname = Tempfile.new(["mogfresh", ".sqlite3"], @docroot)
|
18
|
+
@mogilefsd_conf = Tempfile.new(["mogilefsd", "conf"], @docroot)
|
19
|
+
@mogilefsd_pid = Tempfile.new(["mogilefsd", "pid"], @docroot)
|
20
|
+
@dbpath = @dbname.path
|
23
21
|
|
24
|
-
cmd = %w(mogdbsetup --yes --type=SQLite --dbname) << @
|
22
|
+
cmd = %w(mogdbsetup --yes --type=SQLite --dbname) << @dbpath
|
25
23
|
x!(*cmd)
|
26
24
|
|
27
|
-
@mogilefsd_conf.puts "db_dsn DBI:SQLite
|
25
|
+
@mogilefsd_conf.puts "db_dsn DBI:SQLite:#@dbpath"
|
28
26
|
@mogilefsd_conf.write <<EOF
|
29
27
|
conf_port #@tracker_port
|
30
28
|
listen #@test_host
|
@@ -63,59 +61,6 @@ EOF
|
|
63
61
|
raise "#@test_host:#{port} never became ready"
|
64
62
|
end
|
65
63
|
|
66
|
-
def test_admin_setup_new_host_and_devices
|
67
|
-
assert_equal [], @admin.get_hosts
|
68
|
-
args = { :ip => @test_host, :port => @mogstored_http_port }
|
69
|
-
@admin.create_host("me", args)
|
70
|
-
yield_for_monitor_update { @admin.get_hosts.empty? or break }
|
71
|
-
hosts = @admin.get_hosts
|
72
|
-
assert_equal 1, hosts.size
|
73
|
-
host = @admin.get_hosts[0]
|
74
|
-
assert_equal "me", host["hostname"]
|
75
|
-
assert_equal @mogstored_http_port, host["http_port"]
|
76
|
-
assert_nil host["http_get_port"]
|
77
|
-
assert_equal @test_host, host["hostip"]
|
78
|
-
assert_kind_of Integer, host["hostid"]
|
79
|
-
assert_equal hosts, @admin.get_hosts(host["hostid"])
|
80
|
-
|
81
|
-
assert_equal [], @admin.get_devices
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_replicate_now
|
85
|
-
assert_equal({"count" => 0}, @admin.replicate_now)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_clear_cache
|
89
|
-
assert_nil @admin.clear_cache
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_create_update_delete_class
|
93
|
-
domain = "rbmogtest#{Time.now.strftime('%Y%m%d%H%M%S')}.#{uuid}"
|
94
|
-
@admin.create_domain(domain)
|
95
|
-
yield_for_monitor_update { @admin.get_domains.include?(domain) and break }
|
96
|
-
|
97
|
-
@admin.create_class(domain, "klassy", 1)
|
98
|
-
|
99
|
-
assert_raises(MogileFS::Backend::ClassExistsError) do
|
100
|
-
@admin.create_class(domain, "klassy", 1)
|
101
|
-
end
|
102
|
-
|
103
|
-
@admin.update_class(domain, "klassy",
|
104
|
-
:mindevcount => 1, :replpolicy => "MultipleHosts(1)")
|
105
|
-
|
106
|
-
tmp = nil
|
107
|
-
yield_for_monitor_update do
|
108
|
-
tmp = @admin.get_domains[domain]["klassy"]
|
109
|
-
break if tmp && tmp["replpolicy"] == "MultipleHosts(1)"
|
110
|
-
end
|
111
|
-
assert tmp, "domain did not show up"
|
112
|
-
assert_equal 1, tmp["mindevcount"]
|
113
|
-
assert_equal "MultipleHosts(1)", tmp["replpolicy"]
|
114
|
-
@admin.update_class(domain, "klassy", 2)
|
115
|
-
ensure
|
116
|
-
@admin.delete_class(domain, "klassy") rescue nil
|
117
|
-
end
|
118
|
-
|
119
64
|
def add_host_device_domain
|
120
65
|
assert_equal [], @admin.get_hosts
|
121
66
|
args = { :ip => @test_host, :port => @mogstored_http_port }
|
@@ -161,25 +106,8 @@ EOF
|
|
161
106
|
@domain = domain
|
162
107
|
end
|
163
108
|
|
164
|
-
def test_device_file_add
|
165
|
-
add_host_device_domain
|
166
|
-
client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
|
167
|
-
r, w = IO.pipe
|
168
|
-
thr = Thread.new do
|
169
|
-
(0..9).each do |i|
|
170
|
-
sleep 0.05
|
171
|
-
w.write("#{i}\n")
|
172
|
-
end
|
173
|
-
w.close
|
174
|
-
:ok
|
175
|
-
end
|
176
|
-
assert_equal 20, client.store_file("pipe", nil, r)
|
177
|
-
assert_equal :ok, thr.value
|
178
|
-
r.close
|
179
|
-
assert_equal "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n", client.get_file_data("pipe")
|
180
|
-
end
|
181
|
-
|
182
109
|
def teardown_mogilefs
|
110
|
+
return if $$ != @teardown_pid
|
183
111
|
if @mogstored_pid
|
184
112
|
pid = File.read(@mogstored_pid.path).to_i
|
185
113
|
Process.kill(:TERM, pid) if pid > 0
|
@@ -215,8 +143,8 @@ EOF
|
|
215
143
|
@mogstored_http = TCPServer.new(@test_host, 0)
|
216
144
|
@mogstored_mgmt_port = @mogstored_mgmt.addr[1]
|
217
145
|
@mogstored_http_port = @mogstored_http.addr[1]
|
218
|
-
@mogstored_conf = Tempfile.new(["mogstored", "conf"])
|
219
|
-
@mogstored_pid = Tempfile.new(["mogstored", "pid"])
|
146
|
+
@mogstored_conf = Tempfile.new(["mogstored", "conf"], @docroot)
|
147
|
+
@mogstored_pid = Tempfile.new(["mogstored", "pid"], @docroot)
|
220
148
|
@mogstored_conf.write <<EOF
|
221
149
|
pidfile = #{@mogstored_pid.path}
|
222
150
|
maxconns = 1000
|
data/test/setup.rb
CHANGED
@@ -58,13 +58,8 @@ require 'socket'
|
|
58
58
|
class TempServer
|
59
59
|
attr_reader :port, :pid
|
60
60
|
|
61
|
-
def self.destroy_all!
|
62
|
-
ObjectSpace.each_object(TempServer) { |t| t.destroy! }
|
63
|
-
end
|
64
|
-
|
65
|
-
at_exit { TempServer.destroy_all! }
|
66
|
-
|
67
61
|
def initialize(server_proc, port = nil)
|
62
|
+
@destroy_pid = $$
|
68
63
|
@pid = @sock = nil
|
69
64
|
@port = port
|
70
65
|
retries = 10
|
@@ -85,6 +80,7 @@ class TempServer
|
|
85
80
|
end
|
86
81
|
|
87
82
|
def destroy!
|
83
|
+
return if @destroy_pid != $$
|
88
84
|
@sock.close rescue nil
|
89
85
|
Process.kill('KILL', @pid) rescue nil
|
90
86
|
end
|
data/test/test_admin.rb
CHANGED
@@ -148,5 +148,29 @@ class TestMogileFS__Admin < TestMogileFS
|
|
148
148
|
assert_equal expected, @client.list_fids(0, 100)
|
149
149
|
end
|
150
150
|
|
151
|
+
def test_get_devices
|
152
|
+
@backend.get_devices = {
|
153
|
+
'dev1_utilization' => '5.5',
|
154
|
+
'dev1_devid' => '1',
|
155
|
+
'dev1_hostid' => '3',
|
156
|
+
'dev1_observed_state' => 'writable',
|
157
|
+
'dev1_reject_bad_md5' => '1',
|
158
|
+
'dev2_utilization' => nil,
|
159
|
+
'dev2_devid' => '2',
|
160
|
+
'dev2_hostid' => '4',
|
161
|
+
'dev2_observed_state' => nil,
|
162
|
+
'devices' => '2'
|
163
|
+
}
|
164
|
+
exp = [
|
165
|
+
{
|
166
|
+
'observed_state' => 'writable',
|
167
|
+
'devid' => 1,
|
168
|
+
'reject_bad_md5' => true,
|
169
|
+
'utilization' => 5.5,
|
170
|
+
'hostid' => 3,
|
171
|
+
},
|
172
|
+
{ 'devid' => 2, 'hostid' => 4 }
|
173
|
+
]
|
174
|
+
assert_equal exp, @client.get_devices
|
175
|
+
end
|
151
176
|
end
|
152
|
-
|