@@ -25,13 +25,16 @@ 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 ' \
29+ ' settings:\n ' \
30+ ' GRPC_MAX_RECEIVE_MESSAGE_LENGTH: 100\n ' \
31+ ' GRPC_MAX_SEND_MESSAGE_LENGTH: 100\n ' \
2932
3033 testbed = loader .load (yaml )
3134 device = testbed .devices ['dummy' ]
3235 with patch ('yang.connector.gnmi.grpc.insecure_channel' ) as mock_grpc :
3336 device .connect (alias = 'gnmi' , via = 'Gnmi' )
34- mock_grpc .assert_called_with ('1.2.3.4:830' )
37+ mock_grpc .assert_called_with ('1.2.3.4:830' , [( 'grpc.max_receive_message_length' , 100 ), ( 'grpc.max_send_message_length' , 100 )] )
3538
3639 def test_re_connect (self ):
3740
@@ -46,16 +49,19 @@ def test_re_connect(self):
4649 ' ip : "1.2.3.4"\n ' \
4750 ' port: 830\n ' \
4851 ' username: admin\n ' \
49- ' password: admin\n '
52+ ' password: admin\n ' \
53+ ' settings:\n ' \
54+ ' GRPC_MAX_RECEIVE_MESSAGE_LENGTH: 100\n ' \
55+ ' GRPC_MAX_SEND_MESSAGE_LENGTH: 100\n ' \
5056
5157 testbed = loader .load (yaml )
5258 device = testbed .devices ['dummy' ]
5359 with patch ('yang.connector.gnmi.grpc.insecure_channel' ) as mock_grpc :
5460 device .connect ()
55- mock_grpc .assert_called_with ('1.2.3.4:830' )
61+ mock_grpc .assert_called_with ('1.2.3.4:830' , [( 'grpc.max_receive_message_length' , 100 ), ( 'grpc.max_send_message_length' , 100 )] )
5662 device .disconnect ()
5763 device .connect (alias = 'gnmi' , via = 'Gnmi' )
58- mock_grpc .assert_called_with ('1.2.3.4:830' )
64+ mock_grpc .assert_called_with ('1.2.3.4:830' , [( 'grpc.max_receive_message_length' , 100 ), ( 'grpc.max_send_message_length' , 100 )] )
5965
6066 def test_connect_proxy (self ):
6167 yaml = \
@@ -83,6 +89,9 @@ def test_connect_proxy(self):
8389 ' sshtunnel:\n ' \
8490 ' host: jumphost\n ' \
8591 ' tunnel_ip: 830\n ' \
92+ ' settings:\n ' \
93+ ' GRPC_MAX_RECEIVE_MESSAGE_LENGTH: 100\n ' \
94+ ' GRPC_MAX_SEND_MESSAGE_LENGTH: 100\n ' \
8695
8796 testbed = loader .load (yaml )
8897 device = testbed .devices ['dummy' ]
@@ -91,7 +100,7 @@ def test_connect_proxy(self):
91100 mock_tunnel .side_effect = ['830' ]
92101 device .connections ['Gnmi' ].sshtunnel = AttrDict ({'tunnel_ip' : '4.3.2.1' })
93102 device .connect (alias = 'gnmi' , via = 'Gnmi' )
94- mock_grpc .assert_called_with ('4.3.2.1:830' )
103+ mock_grpc .assert_called_with ('4.3.2.1:830' , [( 'grpc.max_receive_message_length' , 100 ), ( 'grpc.max_send_message_length' , 100 )] )
95104 request = {
96105 "namespace" : {"oc-acl" : "http://openconfig.net/yang/acl" },
97106 "nodes" : [
@@ -159,6 +168,29 @@ def test_get_prefix(self):
159168 path = xpath_util .get_prefix ('rfc7951' )
160169 self .assertIsInstance (path , proto .gnmi_pb2 .Path )
161170
171+ def test_connect_grcp_length (self ):
172+ yaml = \
173+ 'devices:\n ' \
174+ ' dummy:\n ' \
175+ ' type: dummy_device\n ' \
176+ ' connections:\n ' \
177+ ' Gnmi:\n ' \
178+ ' class: yang.connector.Gnmi\n ' \
179+ ' protocol: gnmi\n ' \
180+ ' ip : "1.2.3.4"\n ' \
181+ ' port: 830\n ' \
182+ ' username: admin\n ' \
183+ ' password: admin\n ' \
184+ ' settings:\n ' \
185+ ' GRPC_MAX_RECEIVE_MESSAGE_LENGTH: 100\n ' \
186+ ' GRPC_MAX_SEND_MESSAGE_LENGTH: 100\n ' \
187+
188+ testbed = loader .load (yaml )
189+ device = testbed .devices ['dummy' ]
190+ with patch ('yang.connector.gnmi.grpc.insecure_channel' ) as mock_grpc :
191+ device .connect (alias = 'gnmi' , via = 'Gnmi' )
192+ mock_grpc .assert_called_with ('1.2.3.4:830' , [('grpc.max_receive_message_length' , 100 ), ('grpc.max_send_message_length' , 100 )])
193+
162194
163195if __name__ == '__main__' :
164196 unittest .main ()
0 commit comments