@@ -25,13 +25,13 @@ def test_connect(self):
2525 ' ip : "1.2.3.4"\n ' \
2626 ' port: 830\n ' \
2727 ' username: admin\n ' \
28- ' password: admin\n '
28+ ' password: admin\n ' \
2929
3030 testbed = loader .load (yaml )
3131 device = testbed .devices ['dummy' ]
3232 with patch ('yang.connector.gnmi.grpc.insecure_channel' ) as mock_grpc :
3333 device .connect (alias = 'gnmi' , via = 'Gnmi' )
34- mock_grpc .assert_called_with ('1.2.3.4:830' )
34+ mock_grpc .assert_called_with ('1.2.3.4:830' , [( 'grpc.max_receive_message_length' , 1000000000 ), ( 'grpc.max_send_message_length' , 1000000000 )] )
3535
3636 def test_re_connect (self ):
3737
@@ -46,16 +46,16 @@ def test_re_connect(self):
4646 ' ip : "1.2.3.4"\n ' \
4747 ' port: 830\n ' \
4848 ' username: admin\n ' \
49- ' password: admin\n '
49+ ' password: admin\n ' \
5050
5151 testbed = loader .load (yaml )
5252 device = testbed .devices ['dummy' ]
5353 with patch ('yang.connector.gnmi.grpc.insecure_channel' ) as mock_grpc :
5454 device .connect ()
55- mock_grpc .assert_called_with ('1.2.3.4:830' )
55+ mock_grpc .assert_called_with ('1.2.3.4:830' , [( 'grpc.max_receive_message_length' , 1000000000 ), ( 'grpc.max_send_message_length' , 1000000000 )] )
5656 device .disconnect ()
5757 device .connect (alias = 'gnmi' , via = 'Gnmi' )
58- mock_grpc .assert_called_with ('1.2.3.4:830' )
58+ mock_grpc .assert_called_with ('1.2.3.4:830' , [( 'grpc.max_receive_message_length' , 1000000000 ), ( 'grpc.max_send_message_length' , 1000000000 )] )
5959
6060 def test_connect_proxy (self ):
6161 yaml = \
@@ -91,7 +91,7 @@ def test_connect_proxy(self):
9191 mock_tunnel .side_effect = ['830' ]
9292 device .connections ['Gnmi' ].sshtunnel = AttrDict ({'tunnel_ip' : '4.3.2.1' })
9393 device .connect (alias = 'gnmi' , via = 'Gnmi' )
94- mock_grpc .assert_called_with ('4.3.2.1:830' )
94+ mock_grpc .assert_called_with ('4.3.2.1:830' , [( 'grpc.max_receive_message_length' , 1000000000 ), ( 'grpc.max_send_message_length' , 1000000000 )] )
9595 request = {
9696 "namespace" : {"oc-acl" : "http://openconfig.net/yang/acl" },
9797 "nodes" : [
@@ -159,6 +159,29 @@ def test_get_prefix(self):
159159 path = xpath_util .get_prefix ('rfc7951' )
160160 self .assertIsInstance (path , proto .gnmi_pb2 .Path )
161161
162+ def test_connect_grcp_length (self ):
163+ yaml = \
164+ 'devices:\n ' \
165+ ' dummy:\n ' \
166+ ' type: dummy_device\n ' \
167+ ' connections:\n ' \
168+ ' Gnmi:\n ' \
169+ ' class: yang.connector.Gnmi\n ' \
170+ ' protocol: gnmi\n ' \
171+ ' ip : "1.2.3.4"\n ' \
172+ ' port: 830\n ' \
173+ ' username: admin\n ' \
174+ ' password: admin\n ' \
175+ ' settings:\n ' \
176+ ' GRPC_MAX_RECEIVE_MESSAGE_LENGTH: 100\n ' \
177+ ' GRPC_MAX_SEND_MESSAGE_LENGTH: 100\n ' \
178+
179+ testbed = loader .load (yaml )
180+ device = testbed .devices ['dummy' ]
181+ with patch ('yang.connector.gnmi.grpc.insecure_channel' ) as mock_grpc :
182+ device .connect (alias = 'gnmi' , via = 'Gnmi' )
183+ mock_grpc .assert_called_with ('1.2.3.4:830' , [('grpc.max_receive_message_length' , 100 ), ('grpc.max_send_message_length' , 100 )])
184+
162185
163186if __name__ == '__main__' :
164187 unittest .main ()
0 commit comments