Test Odoo & SQL ping using Curl command or python script


#1

Hi,

Is there a way we can perform the odoo and sql ping test using a curl command or python script?

Regards,
Dilip


#2

In web-admin, 99% of its core backend functionality is represented by Zato admin services. That is, web-admin is a mere client of Zato services, it does not modify configuration in a cluster’s SQL database directly.

This means that when you ping a connection, web-admin invokes a service to ping the connection and returns the response to you.

You can invoke any service from command line using zato service invoke.

The easiest way to discover what web-admin does is to open file admin.log, each server has it, and then to trigger the desired functionality in web-admin, e.g. SQL ping.

Below, you can note what admin.log says in my case when I did it:

INFO - name:[zato.outgoing.sql.ping], SIO request:[{u'id': 1}]
INFO - name:`zato.outgoing.sql.ping`, response:`{"zato_outgoing_sql_ping_response": {"response_time": "0.000918865203857"}}`

That is, web-admin invoked service zato.outgoing.sql.ping, giving it the connection ID (1) on input. The response corresponds to the request.

Now, you can use the same approach to invoke any service from command line with zato service invoke.


#3

Hi dscuch,

We are receiving the following error on service invoke

zato@zato3:~$ zato service invoke /opt/zato/perch/server1/ zato.outgoing.sql.ping
Traceback (most recent call last):
File “/opt/zato/3.0/code/zato-server/src/zato/server/connection/http_soap/channel.py”, line 268, in dispatch
payload, worker_store, self.simple_io_config, post_data, path_info, soap_action)
File “/opt/zato/3.0/code/zato-server/src/zato/server/connection/http_soap/channel.py”, line 502, in handle
params_priority=channel_item.params_pri)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 476, in update_handle
self._invoke(service, channel)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 398, in invoke
service.handle()
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/internal/service.py”, line 311, in handle
response = func(id
, payload, channel, data_format, transport, serialize=True)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 601, in invoke
return self.invoke_by_impl_name(self.server.service_store.name_to_impl_name[name], *args, **kwargs)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 583, in invoke_by_impl_name
return self.update_handle(*invoke_args, **kwargs)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 443, in update_handle
wmq_ctx=kwargs.get(‘wmq_ctx’))
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 944, in update
service._init(channel_type in _wsgi_channels)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/internal/init.py”, line 71, in _init
super(AdminService, self)._init(is_http)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/init.py”, line 353, in _init
self.server.encrypt)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/reqresp/init.py”, line 141, in init
self.init_flat_sio(cid, sio, data_format, transport, wsgi_environ, required_list)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/reqresp/init.py”, line 184, in init_flat_sio
required_list, use_channel_params_only, path_prefix, default_value, use_text))
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/reqresp/init.py”, line 220, in get_params
raise ParsingException(msg)
ParsingException: <ParsingException at 0x7fe809df8640 cid:Caught an exception, param:id, params_to_visit:(u’id’,), has_simple_io_config:True, e:Traceback (most recent call last):
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/reqresp/init.py”, line 213, in get_params
True, self.encrypt_func, self.encrypt_secrets, self.params_priority)
File “/opt/zato/3.0/code/zato-server/src/zato/server/service/reqresp/sio.py”, line 519, in convert_param
raise ParsingException(cid, msg)
ParsingException: <ParsingException at 0x7fe809df88c0 cid:None, msg:Required input element:idnot found, value:ZATO_NONE, data_format:json, payload:None, channel_params:{}>, msg:None>

Not sure of the root cause.

On a side note does the following command be helpful for odoo ping test?
zato service invoke /opt/zato/perch/server1/ zato.outgoing.odoo.ping

Regards,
Sai Bhargav


#4

This is a parsing exception - the service you invoked expected an element called id on input but it was not provided.

Yes, that is correct. The easiest way really is to repeat the same what you find in admin.log.