TA events implementaion#56
Conversation
a54a613 to
c22696a
Compare
rcf_free_usrreq is a pair function for rcf_alloc_usrreq. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
TA event is used to notify TEST or any RCF client about unpredictable event on TA side. tapi_ta_events_cb is used to handle these events. Based on the result, we can continue the client's work or terminate it. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
TE_RCF should have an information about RCF clients that subscribe to TA events to be able to forward TA events. These messages are used to notify TE_RCF about these RCF clients. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
TE_RCF should have a table with unique RCF clients to be able to forward TA events to suitable clients. Without this table we will send TA events to all RCF clients. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
…f interest Configuration tree is used to restore this information after agent restart. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
This function is useful to debug TA events or raise TA event from test. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
Here we add TA events messages with common prefix "SID ${RCF_TA_EVENTS_SID} "
between TE_RCF and TA:
- trigger event command: "ta_events trigger_event ${event_name} ${value}"
- trigger event reply: "${rc} trigger_event"
Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
Here we add TA events messages with common prefix "SID ${RCF_TA_EVENTS_SID} "
between TE_RCF and TA:
- event reply: "${rc} event ${rcf_clients} ${event_name} ${value}"
Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
reply from TA with TA event contains list of RCF clients. This patch is used to split this list into separate RCF clients. And configure RCF message to forward TA event to exact TEST or RCF client. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
Here we add to RCF API additional handler for TA event RCF messages (RCF messages with with TA events opcode and special EVENT type). This handler returns status code and non-zero status code causes termination the related command. Note: rcf_trpoll contains more complex logic and cannot be completed instantly. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
This test is used to validate random order of subscribe/unsubscribe operations. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
This test contains two independent TA events: - good: that shouldn't stop RPC call; - bad: that must stop RPC call. Additionally here we check the number of TA events handled in this test. Signed-off-by: Oleg Sadakov <Oleg.Sadakov@arknetworks.am>
c22696a to
2af1aae
Compare
| #endif | ||
|
|
||
| /** Event callback to process TA events. */ | ||
| typedef bool (*tapi_ta_events_cb)(const char *ta, char *name, char *value); |
There was a problem hiding this comment.
Please, define it without * before type name. It would allow to use it as:
static tapi_ta_events_cb my_func;
static bool
my_func(const char *ta, char *name, char *value)
to highlight that function matches the proto and fail build proto changes and current instance it lost.
| typedef bool (*tapi_ta_events_cb)(const char *ta, char *name, char *value); | ||
|
|
||
| /** TA events handle */ | ||
| typedef unsigned tapi_ta_events_handle; |
There was a problem hiding this comment.
No plain unsigned, please, 'unsigned int'
| * Register new handler, that will be executed to process TA events. | ||
| * | ||
| * @param ta Agent from which we want to receive TA events | ||
| * @param events Comma separated list of events to receive |
There was a problem hiding this comment.
I dislike comma-separated strings. What is the motivation to use such format? Can we use an array or vector instead?
| /** | ||
| * Register new handler, that will be executed to process TA events. | ||
| * | ||
| * @param ta Agent from which we want to receive TA events |
There was a problem hiding this comment.
If I'm not mistaken coding standard requires full stop here if parameter description starts from capital letter.
Similar cases below.
| extern te_errno tapi_ta_events_subscribe(const char *ta, const char *events, | ||
| tapi_ta_events_cb callback, | ||
| tapi_ta_events_handle *handle); |
There was a problem hiding this comment.
alignment of parameters does not look consistent. It should be either intended for each parameter or no indent at all.
| #include <libxml/xmlmemory.h> | ||
| #include <libxml/parser.h> | ||
| #include <libxml/xinclude.h> | ||
|
|
There was a problem hiding this comment.
I don't understand what is TE_RCF in the patch summary. IMHO, summary should look like:
engine/rcf: register client for TA events
| /** RCF client to receive TA events */ | ||
| typedef struct ta_events_client { | ||
| int refcnt; /**< Number of active TA events patterns for this client */ | ||
| char *name; /**< Unique name for this client (${pid}_${tid}) */ |
There was a problem hiding this comment.
Can't ipc_server_client to the job?
| #include "cs_common.h" | ||
| #include "logger_api.h" | ||
| #include "comm_agent.h" | ||
| #include "rcf_ch_api.h" |
There was a problem hiding this comment.
summary is obviously too long
|
|
||
| buf[0] = '\0'; | ||
|
|
||
| SLIST_FOREACH (param, &ta_events_params, links) |
There was a problem hiding this comment.
unnecessary space after SLIST_FOREACH
| is set, current value is adjusted too. | ||
| Name: empty | ||
|
|
||
| - oid: "/agent/ta_events" |
There was a problem hiding this comment.
IMHO it is weird. RCF should care about it itself. It restarts the agent and it may subscribe to events using RCF protocol just after restart. Usage of CS here just makes the picture more and more complicated.
If you which to expose the information (make it clear which events are subscribed to), you may do it (read-only volatile).
This PR is used to add asynchronous TA events. Such events can be processed inside any RCF client (e.g: TEST). RCF command can be interrupted based on the process result.
List of TAPI functions added in this PR:
Additionally we have a function to trigger TA event:
Testing done:
../test-environment/suites/selftest/run.sh \ --cfg=localhost \ --tester-run=ts/tapi/ta_events ... Platform linux build - pass Simple RCF consistency check succeeded --->>> Starting Logger...done --->>> Starting RCF...done --->>> Starting Configurator...done --->>> Start Tester Starting package ts Starting test prologue pass Starting package tapi Starting package ta_events Starting test sample pass Starting test trigger pass Starting test trigger pass Done package ta_events pass Done package tapi pass Done package ts pass --->>> Shutdown Configurator...done --->>> Flush Logs --->>> Shutdown RCF...done --->>> Shutdown Logger...done --->>> Logs conversion...done Run (total) 4 Passed, as expected 3 Failed, as expected 0 Passed unexpectedly 1 Failed unexpectedly 0 Aborted (no useful result) 0 New (expected result is not known) 0 Not Run (total) 154 Skipped, as expected 0 Skipped unexpectedly 0