thrift 0.24.0 → 0.25.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.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +107 -4
  3. data/ext/binary_protocol_accelerated.c +52 -17
  4. data/ext/compact_protocol.c +135 -70
  5. data/ext/constants.h +3 -0
  6. data/ext/extconf.rb +4 -4
  7. data/ext/macros.h +11 -0
  8. data/ext/memory_buffer.c +35 -17
  9. data/ext/struct.c +185 -64
  10. data/ext/thrift_native.c +6 -0
  11. data/lib/thrift/bytes.rb +2 -2
  12. data/lib/thrift/client.rb +31 -22
  13. data/lib/thrift/exceptions.rb +10 -8
  14. data/lib/thrift/multiplexed_processor.rb +5 -6
  15. data/lib/thrift/processor.rb +24 -3
  16. data/lib/thrift/protocol/base_protocol.rb +53 -27
  17. data/lib/thrift/protocol/binary_protocol.rb +54 -40
  18. data/lib/thrift/protocol/binary_protocol_accelerated.rb +6 -2
  19. data/lib/thrift/protocol/compact_protocol.rb +193 -88
  20. data/lib/thrift/protocol/header_protocol.rb +14 -3
  21. data/lib/thrift/protocol/json_protocol.rb +146 -104
  22. data/lib/thrift/protocol/multiplexed_protocol.rb +2 -3
  23. data/lib/thrift/protocol/protocol_decorator.rb +5 -2
  24. data/lib/thrift/serializer/serializer.rb +6 -0
  25. data/lib/thrift/server/base_server.rb +10 -2
  26. data/lib/thrift/server/nonblocking_server.rb +49 -26
  27. data/lib/thrift/server/rack_application.rb +69 -0
  28. data/lib/thrift/server/simple_server.rb +27 -23
  29. data/lib/thrift/server/thin_http_server.rb +20 -44
  30. data/lib/thrift/server/thread_pool_server.rb +20 -17
  31. data/lib/thrift/server/threaded_server.rb +22 -26
  32. data/lib/thrift/struct.rb +33 -18
  33. data/lib/thrift/struct_union.rb +36 -30
  34. data/lib/thrift/transport/base_transport.rb +23 -5
  35. data/lib/thrift/transport/buffered_transport.rb +4 -4
  36. data/lib/thrift/transport/framed_transport.rb +32 -7
  37. data/lib/thrift/transport/header_transport.rb +130 -50
  38. data/lib/thrift/transport/http_client_transport.rb +27 -14
  39. data/lib/thrift/transport/io_stream_transport.rb +2 -1
  40. data/lib/thrift/transport/memory_buffer_transport.rb +8 -10
  41. data/lib/thrift/transport/server_socket.rb +4 -5
  42. data/lib/thrift/transport/socket.rb +20 -22
  43. data/lib/thrift/transport/ssl_server_socket.rb +64 -4
  44. data/lib/thrift/transport/ssl_socket.rb +32 -5
  45. data/lib/thrift/transport/unix_server_socket.rb +1 -1
  46. data/lib/thrift/transport/unix_socket.rb +4 -6
  47. data/lib/thrift/types.rb +22 -22
  48. data/lib/thrift/union.rb +20 -11
  49. data/lib/thrift/uuid.rb +8 -8
  50. data/lib/thrift.rb +39 -39
  51. metadata +5 -230
  52. data/benchmark/Benchmark.thrift +0 -24
  53. data/benchmark/benchmark.rb +0 -286
  54. data/benchmark/client.rb +0 -118
  55. data/benchmark/server.rb +0 -121
  56. data/benchmark/thin_server.rb +0 -46
  57. data/lib/thrift/server/mongrel_http_server.rb +0 -61
  58. data/spec/BaseService.thrift +0 -27
  59. data/spec/ExtendedService.thrift +0 -25
  60. data/spec/Referenced.thrift +0 -44
  61. data/spec/ThriftNamespacedSpec.thrift +0 -53
  62. data/spec/ThriftSpec.thrift +0 -203
  63. data/spec/base_protocol_spec.rb +0 -244
  64. data/spec/base_transport_spec.rb +0 -428
  65. data/spec/binary_protocol_accelerated_spec.rb +0 -47
  66. data/spec/binary_protocol_spec.rb +0 -73
  67. data/spec/binary_protocol_spec_shared.rb +0 -509
  68. data/spec/bytes_spec.rb +0 -117
  69. data/spec/client_spec.rb +0 -167
  70. data/spec/compact_protocol_spec.rb +0 -295
  71. data/spec/constants_demo_spec.rb +0 -102
  72. data/spec/exception_spec.rb +0 -141
  73. data/spec/flat_spec.rb +0 -63
  74. data/spec/header_protocol_spec.rb +0 -476
  75. data/spec/header_transport_spec.rb +0 -431
  76. data/spec/http_client_spec.rb +0 -160
  77. data/spec/json_protocol_spec.rb +0 -574
  78. data/spec/multiplexed_processor_spec.rb +0 -75
  79. data/spec/namespaced_spec.rb +0 -67
  80. data/spec/nonblocking_server_spec.rb +0 -429
  81. data/spec/processor_spec.rb +0 -80
  82. data/spec/recursion_depth_spec.rb +0 -223
  83. data/spec/serializer_spec.rb +0 -67
  84. data/spec/server_socket_spec.rb +0 -121
  85. data/spec/server_spec.rb +0 -238
  86. data/spec/socket_spec.rb +0 -174
  87. data/spec/socket_spec_shared.rb +0 -168
  88. data/spec/spec_helper.rb +0 -70
  89. data/spec/ssl_server_socket_spec.rb +0 -85
  90. data/spec/ssl_socket_spec.rb +0 -248
  91. data/spec/struct_nested_containers_spec.rb +0 -191
  92. data/spec/struct_spec.rb +0 -398
  93. data/spec/support/header_protocol_helper.rb +0 -55
  94. data/spec/thin_http_server_spec.rb +0 -127
  95. data/spec/types_spec.rb +0 -118
  96. data/spec/union_spec.rb +0 -273
  97. data/spec/unix_socket_spec.rb +0 -131
  98. data/spec/uuid_validation_spec.rb +0 -239
  99. data/test/fuzz/Makefile +0 -779
  100. data/test/fuzz/Makefile.am +0 -173
  101. data/test/fuzz/Makefile.in +0 -775
  102. data/test/fuzz/README.md +0 -149
  103. data/test/fuzz/fuzz_common.rb +0 -96
  104. data/test/fuzz/fuzz_parse_binary_protocol.rb +0 -23
  105. data/test/fuzz/fuzz_parse_binary_protocol_accelerated.rb +0 -23
  106. data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +0 -23
  107. data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +0 -23
  108. data/test/fuzz/fuzz_parse_compact_protocol.rb +0 -23
  109. data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +0 -23
  110. data/test/fuzz/fuzz_parse_json_protocol.rb +0 -23
  111. data/test/fuzz/fuzz_parse_json_protocol_harness.rb +0 -23
  112. data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +0 -23
  113. data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +0 -23
  114. data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +0 -23
  115. data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +0 -23
  116. data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +0 -23
  117. data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +0 -23
  118. data/test/fuzz/fuzz_roundtrip_json_protocol.rb +0 -23
  119. data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +0 -23
  120. data/test/fuzz/fuzz_tracer.rb +0 -29
@@ -1,248 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Licensed to the Apache Software Foundation (ASF) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The ASF licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
- #
20
-
21
- require 'spec_helper'
22
- require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
23
-
24
- describe 'SSLSocket' do
25
- describe Thrift::SSLSocket do
26
- before(:each) do
27
- @context = OpenSSL::SSL::SSLContext.new
28
- @socket = Thrift::SSLSocket.new
29
- @addrinfo = double("Addrinfo")
30
- @simple_socket_handle = double("Handle", :closed? => false)
31
- allow(@simple_socket_handle).to receive(:close)
32
- allow(@simple_socket_handle).to receive(:setsockopt)
33
- allow(@simple_socket_handle).to receive(:wait_readable)
34
- allow(@simple_socket_handle).to receive(:wait_writable)
35
-
36
- @handle = double("SSLHandle", :closed? => false)
37
- allow(@handle).to receive(:connect).and_return(true)
38
- allow(@handle).to receive(:connect_nonblock).and_return(@handle)
39
- allow(@handle).to receive(:close)
40
- allow(@handle).to receive(:post_connection_check)
41
- allow(@handle).to receive(:sync_close=)
42
- allow(@handle).to receive(:to_io).and_return(@simple_socket_handle)
43
-
44
- allow(@addrinfo).to receive(:connect).and_return(@simple_socket_handle)
45
- allow(Addrinfo).to receive(:foreach).and_yield(@addrinfo)
46
- allow(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(@handle)
47
- end
48
-
49
- it_should_behave_like "a socket"
50
-
51
- it "should raise a TransportException when it cannot open a ssl socket" do
52
- allow(Addrinfo).to receive(:foreach).and_raise(SocketError.new("lookup failed"))
53
- expect { @socket.open }.to raise_error(Thrift::TransportException) do |e|
54
- expect(e.type).to eq(Thrift::TransportException::NOT_OPEN)
55
- expect(e.message).to eq("Could not connect to localhost:9090")
56
- expect(e.cause).to be_a(SocketError)
57
- end
58
- end
59
-
60
- it "should open a ::Socket with default args" do
61
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
62
- expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(@simple_socket_handle, nil).and_return(@handle)
63
- expect(@handle).to receive(:sync_close=).with(true)
64
- expect(@handle).to receive(:connect).and_return(true)
65
- expect(@handle).to receive(:post_connection_check).with('localhost')
66
- @socket.open
67
- end
68
-
69
- it "should accept host/port options" do
70
- handle = double("Handle", :closed? => false)
71
- allow(handle).to receive(:close)
72
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 100.0)
73
- expect(handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
74
- expect(Addrinfo).to receive(:foreach).with("my.domain", 1234, nil, :STREAM).and_yield(@addrinfo)
75
- expect(@addrinfo).to receive(:connect).with(timeout: 6000).and_return(handle)
76
- expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(handle, nil).and_return(@handle)
77
- expect(@handle).to receive(:sync_close=).with(true)
78
- expect(@handle).to receive(:connect_nonblock).with(exception: false).and_return(@handle)
79
- expect(@handle).to receive(:post_connection_check).with('my.domain')
80
- Thrift::SSLSocket.new('my.domain', 1234, 6000, nil).open
81
- end
82
-
83
- it "should accept an optional timeout" do
84
- expect(Thrift::SSLSocket.new('localhost', 8080, 5).timeout).to eq(5)
85
- end
86
-
87
- it "should accept an optional context" do
88
- expect(Thrift::SSLSocket.new('localhost', 8080, 5, @context).ssl_context).to eq(@context)
89
- end
90
-
91
- it "should treat zero timeout as blocking for open and handshake" do
92
- @socket.timeout = 0
93
-
94
- expect(@addrinfo).to receive(:connect).with(no_args).and_return(@simple_socket_handle)
95
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
96
- expect(@handle).to receive(:sync_close=).with(true)
97
- expect(@handle).to receive(:connect).and_return(true)
98
- expect(@handle).not_to receive(:connect_nonblock)
99
- expect(@handle).to receive(:post_connection_check).with('localhost')
100
-
101
- expect(@socket.open).to eq(@handle)
102
- end
103
-
104
- it "should use the remaining timeout across ssl wait states" do
105
- @socket.timeout = 5
106
-
107
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0, 102.0, 104.0)
108
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_return(@simple_socket_handle)
109
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
110
- expect(@handle).to receive(:sync_close=).with(true)
111
- expect(@handle).to receive(:connect_nonblock).with(exception: false).ordered.and_return(:wait_readable)
112
- expect(@simple_socket_handle).to receive(:wait_readable).with(3.0).ordered.and_return(true)
113
- expect(@handle).to receive(:connect_nonblock).with(exception: false).ordered.and_return(:wait_writable)
114
- expect(@simple_socket_handle).to receive(:wait_writable).with(1.0).ordered.and_return(true)
115
- expect(@handle).to receive(:connect_nonblock).with(exception: false).ordered.and_return(@handle)
116
- expect(@handle).to receive(:post_connection_check).with('localhost')
117
-
118
- expect(@socket.open).to eq(@handle)
119
- end
120
-
121
- it "should share one timeout budget across tcp fallback and the ssl handshake" do
122
- @socket.timeout = 5
123
- second_addrinfo = double("Addrinfo")
124
-
125
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0, 102.0, 103.0)
126
- expect(Addrinfo).to receive(:foreach).with("localhost", 9090, nil, :STREAM).and_yield(@addrinfo).and_yield(second_addrinfo)
127
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_raise(Errno::ECONNREFUSED)
128
- expect(second_addrinfo).to receive(:connect).with(timeout: 3.0).and_return(@simple_socket_handle)
129
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
130
- expect(@handle).to receive(:sync_close=).with(true)
131
- expect(@handle).to receive(:connect_nonblock).with(exception: false).ordered.and_return(:wait_readable)
132
- expect(@simple_socket_handle).to receive(:wait_readable).with(2.0).ordered.and_return(true)
133
- expect(@handle).to receive(:connect_nonblock).with(exception: false).ordered.and_return(@handle)
134
- expect(@handle).to receive(:post_connection_check).with('localhost')
135
-
136
- expect(@socket.open).to eq(@handle)
137
- end
138
-
139
- it "should continue to the next address after a tcp connect timeout during ssl open" do
140
- @socket.timeout = 5
141
- second_addrinfo = double("Addrinfo")
142
-
143
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0, 103.0)
144
- expect(Addrinfo).to receive(:foreach).with("localhost", 9090, nil, :STREAM).and_yield(@addrinfo).and_yield(second_addrinfo)
145
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_raise(Errno::ETIMEDOUT)
146
- expect(second_addrinfo).to receive(:connect).with(timeout: 2.0).and_return(@simple_socket_handle)
147
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
148
- expect(@handle).to receive(:sync_close=).with(true)
149
- expect(@handle).to receive(:connect_nonblock).with(exception: false).and_return(@handle)
150
- expect(@handle).to receive(:post_connection_check).with('localhost')
151
-
152
- expect(@socket.open).to eq(@handle)
153
- end
154
-
155
- it "should raise TIMED_OUT when ssl handshake wait times out" do
156
- @socket.timeout = 5
157
-
158
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0, 102.0)
159
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_return(@simple_socket_handle)
160
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
161
- expect(@handle).to receive(:sync_close=).with(true)
162
- expect(@handle).to receive(:connect_nonblock).with(exception: false).and_return(:wait_readable)
163
- expect(@simple_socket_handle).to receive(:wait_readable).with(3.0).and_return(nil)
164
- expect(@handle).to receive(:close)
165
-
166
- expect { @socket.open }.to raise_error(Thrift::TransportException) do |e|
167
- expect(e.type).to eq(Thrift::TransportException::TIMED_OUT)
168
- expect(e.message).to eq("SSL socket: Timed out establishing session with localhost:9090")
169
- end
170
- end
171
-
172
- it "should surface tcp open timeout before starting ssl" do
173
- @socket.timeout = 5
174
-
175
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0)
176
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_raise(Errno::ETIMEDOUT)
177
- expect(OpenSSL::SSL::SSLSocket).not_to receive(:new)
178
-
179
- expect { @socket.open }.to raise_error(Thrift::TransportException) do |e|
180
- expect(e.type).to eq(Thrift::TransportException::TIMED_OUT)
181
- expect(e.message).to eq("Socket: Timed out opening connection to localhost:9090")
182
- end
183
- end
184
-
185
- it "should close the raw socket if ssl wrapper creation fails" do
186
- @socket.timeout = 5
187
-
188
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0)
189
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_return(@simple_socket_handle)
190
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
191
- expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(@simple_socket_handle, nil).and_raise(StandardError.new("ssl init failed"))
192
- expect(@simple_socket_handle).to receive(:close)
193
-
194
- expect { @socket.open }.to raise_error(Thrift::TransportException) do |e|
195
- expect(e.type).to eq(Thrift::TransportException::NOT_OPEN)
196
- expect(e.message).to eq("Could not connect to localhost:9090")
197
- expect(e.cause.message).to eq("ssl init failed")
198
- end
199
- end
200
-
201
- it "should close the ssl socket when post connection check fails" do
202
- @socket.timeout = 5
203
-
204
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0)
205
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_return(@simple_socket_handle)
206
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
207
- expect(@handle).to receive(:sync_close=).with(true)
208
- expect(@handle).to receive(:connect_nonblock).with(exception: false).and_return(@handle)
209
- expect(@handle).to receive(:post_connection_check).with('localhost').and_raise(StandardError.new("hostname mismatch"))
210
- expect(@handle).to receive(:close)
211
-
212
- expect { @socket.open }.to raise_error(Thrift::TransportException) do |e|
213
- expect(e.type).to eq(Thrift::TransportException::NOT_OPEN)
214
- expect(e.message).to eq("Could not connect to localhost:9090")
215
- expect(e.cause.message).to eq("hostname mismatch")
216
- end
217
- end
218
-
219
- it "should close the ssl socket on an unexpected nonblocking handshake result" do
220
- @socket.timeout = 5
221
-
222
- expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(100.0, 101.0)
223
- expect(@addrinfo).to receive(:connect).with(timeout: 4.0).and_return(@simple_socket_handle)
224
- expect(@simple_socket_handle).to receive(:setsockopt).with(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
225
- expect(@handle).to receive(:sync_close=).with(true)
226
- expect(@handle).to receive(:connect_nonblock).with(exception: false).and_return(:unexpected)
227
- expect(@handle).to receive(:close)
228
-
229
- expect { @socket.open }.to raise_error(Thrift::TransportException) do |e|
230
- expect(e.type).to eq(Thrift::TransportException::NOT_OPEN)
231
- expect(e.message).to include("unexpected SSL connect result")
232
- end
233
- end
234
-
235
- it "should delegate to_io to the underlying SSL socket handle" do
236
- @socket.open
237
- expect(@socket.to_io).to eq(@simple_socket_handle)
238
- end
239
-
240
- it "should raise IOError when to_io is called on a closed stream" do
241
- expect { @socket.to_io }.to raise_error(IOError, 'closed stream')
242
- end
243
-
244
- it "should provide a reasonable to_s" do
245
- expect(Thrift::SSLSocket.new('myhost', 8090).to_s).to eq("ssl(socket(myhost:8090))")
246
- end
247
- end
248
- end
@@ -1,191 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Licensed to the Apache Software Foundation (ASF) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The ASF licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
- #
20
-
21
- require 'spec_helper'
22
-
23
- describe 'StructNestedContainers' do
24
- def with_type_checking
25
- saved_type_checking, Thrift.type_checking = Thrift.type_checking, true
26
- begin
27
- yield
28
- ensure
29
- Thrift.type_checking = saved_type_checking
30
- end
31
- end
32
-
33
- describe Thrift::Struct do
34
- # Nested container tests, see THRIFT-369.
35
- it "should support nested lists inside lists" do
36
- with_type_checking do
37
- a, b = SpecNamespace::NestedListInList.new, SpecNamespace::NestedListInList.new
38
- [a, b].each do |thrift_struct|
39
- thrift_struct.value = [ [1, 2, 3], [2, 3, 4] ]
40
- thrift_struct.validate
41
- end
42
- expect(a).to eq(b)
43
- b.value.push [3, 4, 5]
44
- expect(a).not_to eq(b)
45
- end
46
- end
47
-
48
- it "should support nested lists inside sets" do
49
- with_type_checking do
50
- a, b = SpecNamespace::NestedListInSet.new, SpecNamespace::NestedListInSet.new
51
- [a, b].each do |thrift_struct|
52
- thrift_struct.value = [ [1, 2, 3], [2, 3, 4] ].to_set
53
- thrift_struct.validate
54
- end
55
- expect(a).to eq(b)
56
- b.value.add [3, 4, 5]
57
- expect(a).not_to eq(b)
58
- end
59
- end
60
-
61
- it "should support nested lists in map keys" do
62
- with_type_checking do
63
- a, b = SpecNamespace::NestedListInMapKey.new, SpecNamespace::NestedListInMapKey.new
64
- [a, b].each do |thrift_struct|
65
- thrift_struct.value = { [1, 2, 3] => 1, [2, 3, 4] => 2 }
66
- thrift_struct.validate
67
- end
68
- expect(a).to eq(b)
69
- b.value[[3, 4, 5]] = 3
70
- expect(a).not_to eq(b)
71
- end
72
- end
73
-
74
- it "should support nested lists in map values" do
75
- with_type_checking do
76
- a, b = SpecNamespace::NestedListInMapValue.new, SpecNamespace::NestedListInMapValue.new
77
- [a, b].each do |thrift_struct|
78
- thrift_struct.value = { 1 => [1, 2, 3], 2 => [2, 3, 4] }
79
- thrift_struct.validate
80
- end
81
- expect(a).to eq(b)
82
- b.value[3] = [3, 4, 5]
83
- expect(a).not_to eq(b)
84
- end
85
- end
86
-
87
- it "should support nested sets inside lists" do
88
- with_type_checking do
89
- a, b = SpecNamespace::NestedSetInList.new, SpecNamespace::NestedSetInList.new
90
- [a, b].each do |thrift_struct|
91
- thrift_struct.value = [ [1, 2, 3].to_set, [2, 3, 4].to_set ]
92
- thrift_struct.validate
93
- end
94
- expect(a).to eq(b)
95
- b.value.push([3, 4, 5].to_set)
96
- expect(a).not_to eq(b)
97
- end
98
- end
99
-
100
- it "should support nested sets inside sets" do
101
- with_type_checking do
102
- a, b = SpecNamespace::NestedSetInSet.new, SpecNamespace::NestedSetInSet.new
103
- [a, b].each do |thrift_struct|
104
- thrift_struct.value = [ [1, 2, 3].to_set, [2, 3, 4].to_set ].to_set
105
- thrift_struct.validate
106
- end
107
- expect(a).to eq(b)
108
- b.value.add([3, 4, 5].to_set)
109
- expect(a).not_to eq(b)
110
- end
111
- end
112
-
113
- it "should support nested sets in map keys" do
114
- with_type_checking do
115
- a, b = SpecNamespace::NestedSetInMapKey.new, SpecNamespace::NestedSetInMapKey.new
116
- [a, b].each do |thrift_struct|
117
- thrift_struct.value = { [1, 2, 3].to_set => 1, [2, 3, 4].to_set => 2 }
118
- thrift_struct.validate
119
- end
120
- expect(a).to eq(b)
121
- b.value[[3, 4, 5].to_set] = 3
122
- expect(a).not_to eq(b)
123
- end
124
- end
125
-
126
- it "should support nested sets in map values" do
127
- with_type_checking do
128
- a, b = SpecNamespace::NestedSetInMapValue.new, SpecNamespace::NestedSetInMapValue.new
129
- [a, b].each do |thrift_struct|
130
- thrift_struct.value = { 1 => [1, 2, 3].to_set, 2 => [2, 3, 4].to_set }
131
- thrift_struct.validate
132
- end
133
- expect(a).to eq(b)
134
- b.value[3] = [3, 4, 5].to_set
135
- expect(a).not_to eq(b)
136
- end
137
- end
138
-
139
- it "should support nested maps inside lists" do
140
- with_type_checking do
141
- a, b = SpecNamespace::NestedMapInList.new, SpecNamespace::NestedMapInList.new
142
- [a, b].each do |thrift_struct|
143
- thrift_struct.value = [ {1 => 2, 3 => 4}, {2 => 3, 4 => 5} ]
144
- thrift_struct.validate
145
- end
146
- expect(a).to eq(b)
147
- b.value.push({ 3 => 4, 5 => 6 })
148
- expect(a).not_to eq(b)
149
- end
150
- end
151
-
152
- it "should support nested maps inside sets" do
153
- with_type_checking do
154
- a, b = SpecNamespace::NestedMapInSet.new, SpecNamespace::NestedMapInSet.new
155
- [a, b].each do |thrift_struct|
156
- thrift_struct.value = [ {1 => 2, 3 => 4}, {2 => 3, 4 => 5} ].to_set
157
- thrift_struct.validate
158
- end
159
- expect(a).to eq(b)
160
- b.value.add({ 3 => 4, 5 => 6 })
161
- expect(a).not_to eq(b)
162
- end
163
- end
164
-
165
- it "should support nested maps in map keys" do
166
- with_type_checking do
167
- a, b = SpecNamespace::NestedMapInMapKey.new, SpecNamespace::NestedMapInMapKey.new
168
- [a, b].each do |thrift_struct|
169
- thrift_struct.value = { { 1 => 2, 3 => 4} => 1, {2 => 3, 4 => 5} => 2 }
170
- thrift_struct.validate
171
- end
172
- expect(a).to eq(b)
173
- b.value[{3 => 4, 5 => 6}] = 3
174
- expect(a).not_to eq(b)
175
- end
176
- end
177
-
178
- it "should support nested maps in map values" do
179
- with_type_checking do
180
- a, b = SpecNamespace::NestedMapInMapValue.new, SpecNamespace::NestedMapInMapValue.new
181
- [a, b].each do |thrift_struct|
182
- thrift_struct.value = { 1 => { 1 => 2, 3 => 4}, 2 => {2 => 3, 4 => 5} }
183
- thrift_struct.validate
184
- end
185
- expect(a).to eq(b)
186
- b.value[3] = { 3 => 4, 5 => 6 }
187
- expect(a).not_to eq(b)
188
- end
189
- end
190
- end
191
- end