swiftiply 0.6.1.1 → 1.0.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/CONTRIBUTORS +2 -0
- data/README.md +62 -0
- data/bin/{mongrel_rails → evented_mongrel_rails} +6 -14
- data/bin/swiftiplied_mongrel_rails +246 -0
- data/bin/swiftiply +136 -116
- data/bin/swiftiply_mongrel_rails +2 -2
- data/bin/swiftiplyctl +283 -0
- data/cleanup.sh +5 -0
- data/ext/deque/extconf.rb +162 -0
- data/ext/deque/swiftcore/rubymain.cpp +435 -0
- data/ext/fastfilereader/extconf.rb +2 -2
- data/ext/fastfilereader/mapper.cpp +2 -0
- data/ext/map/extconf.rb +161 -0
- data/ext/map/rubymain.cpp +500 -0
- data/ext/splaytree/extconf.rb +161 -0
- data/ext/splaytree/swiftcore/rubymain.cpp +580 -0
- data/ext/splaytree/swiftcore/splay_map.h +635 -0
- data/ext/splaytree/swiftcore/splay_set.h +575 -0
- data/ext/splaytree/swiftcore/splay_tree.h +1127 -0
- data/external/httpclient.rb +231 -0
- data/external/package.rb +13 -13
- data/setup.rb +18 -2
- data/src/swiftcore/Swiftiply.rb +417 -773
- data/src/swiftcore/Swiftiply/backend_protocol.rb +213 -0
- data/src/swiftcore/Swiftiply/cache_base.rb +49 -0
- data/src/swiftcore/Swiftiply/cache_base_mixin.rb +52 -0
- data/src/swiftcore/Swiftiply/cluster_managers/rest_based_cluster_manager.rb +9 -0
- data/src/swiftcore/Swiftiply/cluster_protocol.rb +70 -0
- data/src/swiftcore/Swiftiply/config.rb +370 -0
- data/src/swiftcore/Swiftiply/config/rest_updater.rb +26 -0
- data/src/swiftcore/Swiftiply/constants.rb +101 -0
- data/src/swiftcore/Swiftiply/content_cache_entry.rb +44 -0
- data/src/swiftcore/Swiftiply/content_response.rb +45 -0
- data/src/swiftcore/Swiftiply/control_protocol.rb +49 -0
- data/src/swiftcore/Swiftiply/dynamic_request_cache.rb +41 -0
- data/src/swiftcore/Swiftiply/etag_cache.rb +64 -0
- data/src/swiftcore/Swiftiply/file_cache.rb +46 -0
- data/src/swiftcore/Swiftiply/hash_cache_base.rb +22 -0
- data/src/swiftcore/Swiftiply/http_recognizer.rb +267 -0
- data/src/swiftcore/Swiftiply/loggers/Analogger.rb +21 -0
- data/src/swiftcore/Swiftiply/loggers/stderror.rb +13 -0
- data/src/swiftcore/Swiftiply/mocklog.rb +10 -0
- data/src/swiftcore/Swiftiply/proxy.rb +15 -0
- data/src/swiftcore/Swiftiply/proxy_backends/keepalive.rb +286 -0
- data/src/swiftcore/Swiftiply/proxy_backends/traditional.rb +286 -0
- data/src/swiftcore/Swiftiply/proxy_backends/traditional/redis_directory.rb +87 -0
- data/src/swiftcore/Swiftiply/proxy_backends/traditional/static_directory.rb +69 -0
- data/src/swiftcore/Swiftiply/proxy_bag.rb +716 -0
- data/src/swiftcore/Swiftiply/rest_based_cluster_manager.rb +15 -0
- data/src/swiftcore/Swiftiply/splay_cache_base.rb +21 -0
- data/src/swiftcore/Swiftiply/support_pagecache.rb +6 -3
- data/src/swiftcore/Swiftiply/swiftiply_2_http_proxy.rb +7 -0
- data/src/swiftcore/Swiftiply/swiftiply_client.rb +20 -5
- data/src/swiftcore/Swiftiply/version.rb +5 -0
- data/src/swiftcore/evented_mongrel.rb +26 -8
- data/src/swiftcore/hash.rb +43 -0
- data/src/swiftcore/method_builder.rb +28 -0
- data/src/swiftcore/streamer.rb +46 -0
- data/src/swiftcore/swiftiplied_mongrel.rb +91 -23
- data/src/swiftcore/types.rb +20 -3
- data/swiftiply.gemspec +14 -8
- data/test/TC_Deque.rb +152 -0
- data/test/TC_ProxyBag.rb +147 -166
- data/test/TC_Swiftiply.rb +576 -169
- data/test/TC_Swiftiply/mongrel/evented_hello.rb +1 -1
- data/test/TC_Swiftiply/mongrel/swiftiplied_hello.rb +1 -1
- data/test/TC_Swiftiply/test_serve_static_file_xsendfile/sendfile_client.rb +27 -0
- data/test/TC_Swiftiply/test_ssl/bin/validate_ssl_capability.rb +21 -0
- data/test/TC_Swiftiply/test_ssl/test.cert +16 -0
- data/test/TC_Swiftiply/test_ssl/test.key +15 -0
- data/{bin → test/bin}/echo_client +0 -0
- metadata +136 -94
- data/README +0 -126
- data/ext/swiftiply_parse/parse.rl +0 -90
data/src/swiftcore/types.rb
CHANGED
@@ -1022,13 +1022,23 @@ application/vnd.mozilla.xul+xml @xul 'IANA,[McDaniel]
|
|
1022
1022
|
application/vnd.ms-artgalry @cil 'IANA,[Slawson]
|
1023
1023
|
application/vnd.ms-asf @asf 'IANA,[Fleischman]
|
1024
1024
|
application/vnd.ms-cab-compressed @cab 'IANA,[Scarborough]
|
1025
|
-
application/vnd.ms-excel @xls,xlt :base64 'IANA,[Gill]
|
1025
|
+
application/vnd.ms-excel @xls,xlt,xla :base64 'IANA,[Gill]
|
1026
|
+
application/vnd.ms-excel.sheet.binary.macroEnabled.12 @xlsb 'IANA,[Chris_Rae]
|
1027
|
+
application/vnd.ms-excel.addin.macroEnabled.12 @xlam 'IANA,[Chris_Rae]
|
1028
|
+
application/vnd.ms-excel.sheet.macroEnabled.12 @xlsm 'IANA,[Chris_Rae]
|
1029
|
+
application/vnd.ms-excel.template.macroEnabled.12 @xltm 'IANA,[Chris_Rae]
|
1026
1030
|
application/vnd.ms-fontobject 'IANA,[Scarborough]
|
1027
1031
|
application/vnd.ms-ims 'IANA,[Ledoux]
|
1028
1032
|
application/vnd.ms-lrm @lrm 'IANA,[Ledoux]
|
1029
|
-
application/vnd.ms-powerpoint @ppt,pps,pot :base64 'IANA,[Gill]
|
1033
|
+
application/vnd.ms-powerpoint @ppt,pps,pot,ppa :base64 'IANA,[Gill]
|
1034
|
+
application/vnd.ms-powerpoint.addin.macroEnabled.12 @ppam 'IANA,[Chris_Rae]
|
1035
|
+
application/vnd.ms-powerpoint.presentation.macroEnabled.12 @pptm 'IANA,[Chris_Rae]
|
1036
|
+
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 @ppsm 'IANA,[Chris_Rae]
|
1037
|
+
application/vnd.ms-powerpoint.template.macroEnabled.12 @potm 'IANA,[Chris_Rae]
|
1030
1038
|
application/vnd.ms-project @mpp :base64 'IANA,[Gill]
|
1031
1039
|
application/vnd.ms-tnef :base64 'IANA,[Gill]
|
1040
|
+
application/vnd.ms-word.document.macroEnabled.12 @docm 'IANA,[Chris_Rae]
|
1041
|
+
application/vnd.ms-word.template.macroEnabled.12 @dotm 'IANA,[Chris_Rae]
|
1032
1042
|
application/vnd.ms-works :base64 'IANA,[Gill]
|
1033
1043
|
application/vnd.ms-wpl @wpl :base64 'IANA,[Plastina]
|
1034
1044
|
application/vnd.mseq @mseq 'IANA,[Le Bodic]
|
@@ -1052,6 +1062,13 @@ application/vnd.obn 'IANA,[Hessling]
|
|
1052
1062
|
application/vnd.omads-email+xml 'IANA,[OMA Data Synchronization Working Group]
|
1053
1063
|
application/vnd.omads-file+xml 'IANA,[OMA Data Synchronization Working Group]
|
1054
1064
|
application/vnd.omads-folder+xml 'IANA,[OMA Data Synchronization Working Group]
|
1065
|
+
application/vnd.openxmlformats-officedocument.presentationml.presentation @pptx 'IANA,[Makoto_Murata]
|
1066
|
+
application/vnd.openxmlformats-officedocument.presentationml.slideshow @ppsx 'IANA,[Makoto_Murata]
|
1067
|
+
application/vnd.openxmlformats-officedocument.presentationml.template @potx 'IANA,[Makoto_Murata]
|
1068
|
+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet @xlsx 'IANA,[Makoto_Murata]
|
1069
|
+
application/vnd.openxmlformats-officedocument.spreadsheetml.template @xltx 'IANA,[Makoto_Murata]
|
1070
|
+
application/vnd.openxmlformats-officedocument.wordprocessingml.document @docx 'IANA,[Makoto_Murata]
|
1071
|
+
application/vnd.openxmlformats-officedocument.wordprocessingml.template @dotx 'IANA,[Makoto_Murata]
|
1055
1072
|
application/vnd.osa.netdeploy 'IANA,[Klos]
|
1056
1073
|
application/vnd.osgi.dp 'IANA,[Kriens]
|
1057
1074
|
application/vnd.palm @prc,pdb,pqa,oprc :base64 'IANA,[Peacock]
|
@@ -1552,7 +1569,7 @@ _re = %r{
|
|
1552
1569
|
$
|
1553
1570
|
}x
|
1554
1571
|
|
1555
|
-
data_mime_type.
|
1572
|
+
data_mime_type.each_line do |i|
|
1556
1573
|
item = i.chomp.strip.gsub(%r{#.*}o, '')
|
1557
1574
|
next if item.empty?
|
1558
1575
|
|
data/swiftiply.gemspec
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
#####
|
2
|
-
# Swiftcore
|
3
|
-
# http://
|
4
|
-
# Copyright 2007 Kirk Haines
|
2
|
+
# Swiftcore Swiftiply
|
3
|
+
# http://swiftiply.swiftcore.org
|
4
|
+
# Copyright 2007-2017 Kirk Haines
|
5
|
+
# wyhaines@gmail.com
|
5
6
|
#
|
6
7
|
# Licensed under the Ruby License. See the README for details.
|
7
8
|
#
|
8
9
|
#####
|
10
|
+
lib = File.expand_path('../src', __FILE__)
|
11
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
12
|
+
require 'swiftcore/Swiftiply/version'
|
9
13
|
|
10
14
|
spec = Gem::Specification.new do |s|
|
11
15
|
s.name = 'swiftiply'
|
12
16
|
s.author = %q(Kirk Haines)
|
13
17
|
s.email = %q(wyhaines@gmail.com)
|
14
|
-
s.version =
|
18
|
+
s.version = Swiftcore::Swiftiply::VERSION
|
15
19
|
s.summary = %q(A fast clustering proxy for web applications.)
|
16
20
|
s.platform = Gem::Platform::RUBY
|
17
21
|
|
18
22
|
s.has_rdoc = true
|
19
|
-
s.rdoc_options = %w(--title Swiftcore::Swiftiply --main README --line-numbers)
|
20
|
-
s.extra_rdoc_files = %w(README)
|
23
|
+
s.rdoc_options = %w(--title Swiftcore::Swiftiply --main README.md --line-numbers)
|
24
|
+
s.extra_rdoc_files = %w(README.md)
|
21
25
|
s.extensions << 'ext/fastfilereader/extconf.rb'
|
26
|
+
s.extensions << 'ext/deque/extconf.rb'
|
27
|
+
s.extensions << 'ext/splaytree/extconf.rb'
|
22
28
|
s.files = Dir['**/*']
|
23
|
-
s.executables = %w(swiftiply
|
29
|
+
s.executables = %w(swiftiply swiftiplied_mongrel_rails evented_mongrel_rails swiftiply_mongrel_rails)
|
24
30
|
s.require_paths = %w(src)
|
25
31
|
|
26
32
|
s.requirements << "Eventmachine 0.8.1 or higher."
|
@@ -30,7 +36,7 @@ spec = Gem::Specification.new do |s|
|
|
30
36
|
s.rubyforge_project = %q(swiftiply)
|
31
37
|
s.homepage = %q(http://swiftiply.swiftcore.org/)
|
32
38
|
description = []
|
33
|
-
File.open("README") do |file|
|
39
|
+
File.open("README.md") do |file|
|
34
40
|
file.each do |line|
|
35
41
|
line.chomp!
|
36
42
|
break if line.empty?
|
data/test/TC_Deque.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'external/test_support'
|
3
|
+
SwiftcoreTestSupport.set_src_dir
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'swiftcore/deque'
|
6
|
+
|
7
|
+
class TC_Deque < Minitest::Test
|
8
|
+
@@testdir = SwiftcoreTestSupport.test_dir(__FILE__)
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Dir.chdir(@@testdir)
|
12
|
+
SwiftcoreTestSupport.announce(:proxybag,"ProxyBag")
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
GC.start
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_a_new
|
20
|
+
dq = nil
|
21
|
+
dq = Swiftcore::Deque.new
|
22
|
+
assert_kind_of(Swiftcore::Deque,dq)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_b_unshift
|
26
|
+
dq = Swiftcore::Deque.new
|
27
|
+
|
28
|
+
dq.unshift "a"
|
29
|
+
dq.unshift "b"
|
30
|
+
dq.unshift "c"
|
31
|
+
|
32
|
+
assert_equal('["c","b","a"]',dq.inspect)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_c_shift
|
36
|
+
dq = Swiftcore::Deque.new
|
37
|
+
dq.unshift "a"
|
38
|
+
dq.unshift "b"
|
39
|
+
dq.unshift "c"
|
40
|
+
assert_equal("c",dq.shift)
|
41
|
+
assert_equal("b",dq.shift)
|
42
|
+
assert_equal("a",dq.shift)
|
43
|
+
assert_equal(nil,dq.shift)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_d_push
|
47
|
+
dq = Swiftcore::Deque.new
|
48
|
+
dq.push "a"
|
49
|
+
dq.push "b"
|
50
|
+
dq.push "c"
|
51
|
+
|
52
|
+
assert_equal('["a","b","c"]',dq.inspect)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_e_pop
|
56
|
+
dq = Swiftcore::Deque.new
|
57
|
+
dq.push "a"
|
58
|
+
dq.push "b"
|
59
|
+
dq.push "c"
|
60
|
+
assert_equal("c",dq.pop)
|
61
|
+
assert_equal("b",dq.pop)
|
62
|
+
assert_equal("a",dq.pop)
|
63
|
+
assert_equal(nil,dq.pop)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_f_size
|
67
|
+
dq = Swiftcore::Deque.new
|
68
|
+
dq.push "a"
|
69
|
+
dq.push "b"
|
70
|
+
dq.push "c"
|
71
|
+
assert_equal(3,dq.size)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_g_max_size
|
75
|
+
dq = Swiftcore::Deque.new
|
76
|
+
dq.max_size
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_h_clear
|
80
|
+
dq = Swiftcore::Deque.new
|
81
|
+
dq.push "a"
|
82
|
+
dq.push "b"
|
83
|
+
dq.push "c"
|
84
|
+
dq.clear
|
85
|
+
assert_equal(0,dq.size)
|
86
|
+
assert_equal("[]",dq.inspect)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_i_empty
|
90
|
+
dq = Swiftcore::Deque.new
|
91
|
+
dq.push "a"
|
92
|
+
assert(!dq.empty?)
|
93
|
+
dq.clear
|
94
|
+
assert(dq.empty?)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_j_to_s
|
98
|
+
dq = Swiftcore::Deque.new
|
99
|
+
dq.push "a"
|
100
|
+
dq.push "b"
|
101
|
+
dq.push "c"
|
102
|
+
assert_equal("abc",dq.to_s)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_k_to_a
|
106
|
+
dq = Swiftcore::Deque.new
|
107
|
+
dq.push "a"
|
108
|
+
dq.push "b"
|
109
|
+
dq.push "c"
|
110
|
+
assert_equal(["a","b","c"],dq.to_a)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_l_first
|
114
|
+
dq = Swiftcore::Deque.new
|
115
|
+
dq.push "a"
|
116
|
+
dq.push "b"
|
117
|
+
dq.push "c"
|
118
|
+
assert_equal("a",dq.first)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_m_last
|
122
|
+
dq = Swiftcore::Deque.new
|
123
|
+
dq.push "a"
|
124
|
+
dq.push "b"
|
125
|
+
dq.push "c"
|
126
|
+
assert_equal("c",dq.last)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_n_at
|
130
|
+
dq = Swiftcore::Deque.new
|
131
|
+
dq.push "a"
|
132
|
+
dq.push "b"
|
133
|
+
dq.push "c"
|
134
|
+
assert_equal("a",dq.at(0))
|
135
|
+
assert_equal("a",dq[0])
|
136
|
+
assert_equal("b",dq.at(1))
|
137
|
+
assert_equal("b",dq[1])
|
138
|
+
assert_equal("c",dq.at(2))
|
139
|
+
assert_equal("c",dq[2])
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_o_index
|
143
|
+
dq = Swiftcore::Deque.new
|
144
|
+
dq.push "a"
|
145
|
+
dq.push :b
|
146
|
+
dq.push 37
|
147
|
+
assert_equal(0,dq.index("a"))
|
148
|
+
assert_equal(1,dq.index(:b))
|
149
|
+
assert_equal(2,dq.index(37))
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
data/test/TC_ProxyBag.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'minitest/autorun'
|
2
2
|
require 'external/test_support'
|
3
3
|
SwiftcoreTestSupport.set_src_dir
|
4
4
|
require 'rbconfig'
|
@@ -6,14 +6,14 @@ require 'net/http'
|
|
6
6
|
require 'swiftcore/Swiftiply'
|
7
7
|
require 'yaml'
|
8
8
|
|
9
|
-
class TC_ProxyBag < Test
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
class TC_ProxyBag < Minitest::Test
|
10
|
+
@@testdir = SwiftcoreTestSupport.test_dir(__FILE__)
|
11
|
+
Ruby = File.join(::RbConfig::CONFIG['bindir'],::RbConfig::CONFIG['ruby_install_name']) << ::RbConfig::CONFIG['EXEEXT']
|
12
|
+
|
13
|
+
DeleteQueue = []
|
14
|
+
KillQueue = []
|
15
|
+
|
16
|
+
ConfBase = YAML.load(<<ECONF)
|
17
17
|
cluster_address: 127.0.0.1
|
18
18
|
cluster_port: 29998
|
19
19
|
daemonize: false
|
@@ -25,161 +25,142 @@ map:
|
|
25
25
|
default: true
|
26
26
|
redeployable: false
|
27
27
|
ECONF
|
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
|
-
|
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
|
-
end
|
167
|
-
|
168
|
-
def test_server_unavailable_timeout
|
169
|
-
pb = Swiftcore::Swiftiply::ProxyBag
|
170
|
-
assert_nothing_raised do
|
171
|
-
pb.server_unavailable_timeout = 3
|
172
|
-
end
|
173
|
-
assert_equal(3,pb.instance_variable_get('@server_unavailable_timeout'))
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_find_static_file
|
177
|
-
dr = Dir.pwd
|
178
|
-
path_info = "testfile#{Time.now.to_i}"
|
179
|
-
File.open(path_info,'w') {|fh| fh.puts "alfalfa leafcutter bee"}
|
180
|
-
assert_equal(File.join(dr,path_info),Swiftcore::Swiftiply::ProxyBag.find_static_file(dr,path_info,'foo'))
|
181
|
-
assert_nil(Swiftcore::Swiftiply::ProxyBag.find_static_file(dr,'xyzzy','foo'))
|
182
|
-
File.delete(path_info)
|
183
|
-
end
|
184
|
-
|
28
|
+
|
29
|
+
def get_url(hostname,port,url)
|
30
|
+
Net::HTTP.start(hostname,port) {|http| http.get(url)}
|
31
|
+
end
|
32
|
+
|
33
|
+
def post_url(hostname,port,url,data = nil)
|
34
|
+
Net::HTTP.start(hostname,port) {|http| http.post(url,data)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete_url(hostname,port,url)
|
38
|
+
Net::HTTP.start(hostname,port) {|http| http.delete(url)}
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup
|
42
|
+
Dir.chdir(@@testdir)
|
43
|
+
SwiftcoreTestSupport.announce(:proxybag,"ProxyBag")
|
44
|
+
end
|
45
|
+
|
46
|
+
def teardown
|
47
|
+
while f = DeleteQueue.pop do
|
48
|
+
File.delete f if f
|
49
|
+
end
|
50
|
+
|
51
|
+
while p = KillQueue.pop do
|
52
|
+
Process.kill("SIGKILL",p) if p
|
53
|
+
Process.wait p if p
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_update_ctime
|
58
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
59
|
+
t = pb.update_ctime
|
60
|
+
assert_instance_of(String,t)
|
61
|
+
pt = nil
|
62
|
+
pt = Time.parse(t)
|
63
|
+
assert_instance_of(Time,pt)
|
64
|
+
if Time === pt
|
65
|
+
delta = Time.now - pt
|
66
|
+
assert(delta < 2)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_now
|
71
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
72
|
+
n = pb.update_ctime
|
73
|
+
assert_instance_of(Time,pb.now)
|
74
|
+
#assert_equal(Time.parse(n).asctime,pb.now.asctime)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_set_key
|
78
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
79
|
+
pb.set_key(:a,'abc')
|
80
|
+
assert_equal('abc',pb.instance_variable_get('@keys')[:a])
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_get_key
|
84
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
85
|
+
pb.set_key(:b,'def')
|
86
|
+
assert_equal('def',pb.get_key(:b))
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_add_id
|
90
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
91
|
+
pb.add_id(:abcdef,12345)
|
92
|
+
assert_equal(12345,pb.instance_variable_get('@id_map')[:abcdef])
|
93
|
+
assert_equal(:abcdef,pb.instance_variable_get('@reverse_id_map')[12345])
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_remove_id
|
97
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
98
|
+
pb.remove_id(:abcdef)
|
99
|
+
assert_nil(pb.instance_variable_get('@id_map')[:abcdef])
|
100
|
+
assert_nil(pb.instance_variable_get('@reverse_id_map')[12345])
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_add_incoming_mapping
|
104
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
105
|
+
pb.add_incoming_mapping(:abcdef,12345)
|
106
|
+
assert_equal(:abcdef,pb.instance_variable_get('@incoming_map')[12345])
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_remove_incoming_mapping
|
110
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
111
|
+
pb.remove_incoming_mapping(12345)
|
112
|
+
assert_nil(pb.instance_variable_get('@incoming_map')[12345])
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_add_incoming_docroot
|
116
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
117
|
+
pb.add_docroot('/abc/123',:abcdef)
|
118
|
+
assert_equal('/abc/123',pb.instance_variable_get('@docroot_map')[:abcdef])
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_remove_incoming_docroot
|
122
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
123
|
+
pb.remove_docroot(:abcdef)
|
124
|
+
assert_nil(pb.instance_variable_get('@docroot_map')[:abcdef])
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_add_incoming_redeployable
|
128
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
129
|
+
pb.add_redeployable(16384,:abcdef)
|
130
|
+
assert_equal(16384,pb.instance_variable_get('@redeployable_map')[:abcdef])
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_remove_incoming_redeployable
|
134
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
135
|
+
pb.remove_redeployable(:abcdef)
|
136
|
+
assert_nil(pb.instance_variable_get('@redeployable_map')[:abcdef])
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_add_log
|
140
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
141
|
+
pb.add_log('/foo/bar',:abcdef)
|
142
|
+
assert_equal(['/foo/bar',1],pb.instance_variable_get('@log_map')[:abcdef])
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_default_name
|
146
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
147
|
+
pb.default_name = 'test'
|
148
|
+
assert_equal('test',pb.instance_variable_get('@default_name'))
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_server_unavailable_timeout
|
152
|
+
pb = Swiftcore::Swiftiply::ProxyBag
|
153
|
+
pb.server_unavailable_timeout = 3
|
154
|
+
assert_equal(3,pb.instance_variable_get('@server_unavailable_timeout'))
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_find_static_file
|
158
|
+
dr = Dir.pwd
|
159
|
+
path_info = "testfile#{Time.now.to_i}"
|
160
|
+
File.open(path_info,'w') {|fh| fh.puts "alfalfa leafcutter bee"}
|
161
|
+
assert_equal(File.join(dr,path_info),Swiftcore::Swiftiply::ProxyBag.find_static_file(dr,path_info,'foo'))
|
162
|
+
assert_equal(nil,Swiftcore::Swiftiply::ProxyBag.find_static_file(dr,'xyzzy','foo'))
|
163
|
+
File.delete(path_info)
|
164
|
+
end
|
165
|
+
|
185
166
|
end
|