From 09e2e767fe19426fcfcbde6b038c2c2c3c15849e Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Sun, 4 Nov 2018 15:39:02 +0100 Subject: [PATCH] nchan stream tests --- lib/src/clixon_stream.c | 9 ++++++--- test/test_stream.sh | 21 +-------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/lib/src/clixon_stream.c b/lib/src/clixon_stream.c index 1659956e..3fc8c914 100644 --- a/lib/src/clixon_stream.c +++ b/lib/src/clixon_stream.c @@ -847,12 +847,14 @@ url_post(char *url, /*! Stream callback for example stream notification * Push via curl_post to publish stream event * @param[in] h Clicon handle + * @param[in] op Operation: 0 OK, 1 Close * @param[in] event Event as XML * @param[in] arg Extra argument provided in stream_ss_add * @see stream_ss_add */ static int stream_publish_cb(clicon_handle h, + int op, cxobj *event, void *arg) { @@ -864,7 +866,8 @@ stream_publish_cb(clicon_handle h, char *stream = (char*)arg; clicon_debug(1, "%s", __FUNCTION__); - + if (op != 0) + goto ok; /* Create pub url */ if ((u = cbuf_new()) == NULL){ clicon_err(OE_XML, errno, "cbuf_new"); @@ -874,7 +877,6 @@ stream_publish_cb(clicon_handle h, clicon_err(OE_CFG, ENOENT, "CLICON_STREAM_PUB not defined"); goto done; } - cprintf(u, "%s/%s", pub_prefix, stream); /* Create XML data as string */ if ((d = cbuf_new()) == NULL){ @@ -889,6 +891,7 @@ stream_publish_cb(clicon_handle h, goto done; if (result) clicon_debug(1, "%s: %s", __FUNCTION__, result); + ok: retval = 0; done: if (u) @@ -910,7 +913,7 @@ stream_publish(clicon_handle h, #ifdef CLIXON_PUBLISH_STREAMS int retval = -1; - if (stream_ss_add(h, stream, NULL, stream_publish_cb, (void*)stream) < 0) + if (stream_ss_add(h, stream, NULL, NULL, NULL, stream_publish_cb, (void*)stream) < 0) goto done; retval = 0; done: diff --git a/test/test_stream.sh b/test/test_stream.sh index 3ee3cc6b..7529911e 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -275,26 +275,7 @@ rm -rf $dir exit # DONT REMOVE MANUAL TESTING #-------------------------------------------------------------------- -# Need manual testing -new "restconf monitor streams native NEEDS manual testing" -if false; then - # url -H "Accept: text/event-stream" http://localhost/streams/EXAMPLE - # Expect: - # data: 2018-10-21T19:22:11.381827faultEthernet0major - # - # data: 2018-10-21T19:22:16.387228faultEthernet0major - -new "restconf monitor event ok stream" -expectwait 'curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" http://localhost/streams/EXAMPLE' 0 'foo' 5 - -new "restconf monitor event starttime" -NOW=$(date +"%Y-%m-%dT%H%%3A%M%%3A%S") -sleep 10 -expectwait "curl -s -X GET -H \"Accept: text/event-stream\" -H \"Cache-Control: no-cache\" -H \"Connection: keep-alive\" http://localhost/streams/EXAMPLE?start-time=$NOW" 0 'foo' 2 -fi - -# Restconf stream subscription RFC8040 Sec 6.3 - Nginx nchan solution -# Need manual testing +# NCHAN Need manual testing new "restconf monitor streams nchan NEEDS manual testing" if false; then # url -H "Accept: text/event-stream" http://localhost/streams/EXAMPLE