Skip to content

Commit

Permalink
Add events to host (sonic-net#27)
Browse files Browse the repository at this point in the history
Fix minor bugs
  • Loading branch information
zbud-msft authored Sep 16, 2022
1 parent 2cd2385 commit 78ac446
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-rsyslog-plugin_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f

# Generate host conf for rsyslog_plugin
j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/events_info.json > $BUILD_TEMPLATES/host_events.conf
sudo mv $BUILD_TEMPLATES/host_events.conf $FILESYSTEM_ROOT_ETC/rsyslog.d/
j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/events_info.json | sudo tee $FILESYSTEM_ROOT_ETC/rsyslog.d/host_events.conf
sudo cp $BUILD_TEMPLATES/monit_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/sshd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/

Expand Down
18 changes: 10 additions & 8 deletions src/sonic-eventd/tools/events_monit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def map_dict_fvm(s, d):
def test_receiver(event_obj, cnt):
global rc_test_receive

sh = events_init_subscriber(false, RECEIVE_TIMEOUT, null)
sh = events_init_subscriber(False, RECEIVE_TIMEOUT, None)

# Sleep ASYNC_CONN_WAIT to ensure async connectivity is complete.
time.sleep(ASYNC_CONN_WAIT/1000)
Expand All @@ -75,19 +75,19 @@ def test_receiver(event_obj, cnt):
p = event_receive_op_t()
rc = event_receive(sh, p)

if rc > 0 && publish_cnt < 2:
if rc > 0 and publish_cnt < 2:
# ignore timeout as test code has not yet published an event yet
continue

if rc != 0:
log_notice("Failed to receive. {}/{} rc={}".format(i, cnt, rc))
log_notice("Failed to receive. {}/{} rc={}".format(cnt_done, cnt, rc))
break

if test_event_key != p.key:
# received a different event than published
continue

exp_params["index"] = str(i)
exp_params["index"] = str(cnt_done)
rcv_params = {}
map_dict_fvm(p.params, rcv_params)

Expand All @@ -102,19 +102,19 @@ def test_receiver(event_obj, cnt):
rc = -1

if (rc != 0):
log_notice("params mismatch {}/{}".format(i,cnt))
log_notice("params mismatch {}/{}".format(cnt_done, cnt))
break

if p.missed_cnt != 0:
log_notice("Expect missed_cnt {} == 0 {}/{}".format(p.missed_cnt,i,cnt))
log_notice("Expect missed_cnt {} == 0 {}/{}".format(p.missed_cnt, cnt_done, cnt))
break

if p.publish_epoch_ms == 0:
log_notice("Expect publish_epoch_ms != 0 {}/{}".format(i,cnt))
log_notice("Expect publish_epoch_ms != 0 {}/{}".format(cnt_done, cnt))
break

cnt_done += 1
log_debug("Received {}/{}".format(i+1, cnt))
log_debug("Received {}/{}".format(cnt_done + 1, cnt))

if (cnt_done == cnt):
rc_test_receive = 0
Expand All @@ -127,6 +127,7 @@ def test_receiver(event_obj, cnt):


def publish_events(cnt):
global publish_cnt
rc = -1
ph = events_init_publisher(test_source)
if not ph:
Expand All @@ -148,6 +149,7 @@ def publish_events(cnt):
if (rc != 0):
log_notice("Failed to publish. {}/{} rc={}".format(i, cnt, rc))
break

log_debug("published: {}/{}".format(i+1, cnt))
publish_cnt += 1

Expand Down

0 comments on commit 78ac446

Please sign in to comment.