Skip to content

Commit 78ac446

Browse files
authored
Add events to host (#27)
Fix minor bugs
1 parent 2cd2385 commit 78ac446

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

files/build_templates/sonic_debian_extension.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-rsyslog-plugin_*.deb || \
324324
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
325325

326326
# Generate host conf for rsyslog_plugin
327-
j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/events_info.json > $BUILD_TEMPLATES/host_events.conf
328-
sudo mv $BUILD_TEMPLATES/host_events.conf $FILESYSTEM_ROOT_ETC/rsyslog.d/
327+
j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/events_info.json | sudo tee $FILESYSTEM_ROOT_ETC/rsyslog.d/host_events.conf
329328
sudo cp $BUILD_TEMPLATES/monit_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
330329
sudo cp $BUILD_TEMPLATES/sshd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
331330

src/sonic-eventd/tools/events_monit_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def map_dict_fvm(s, d):
6060
def test_receiver(event_obj, cnt):
6161
global rc_test_receive
6262

63-
sh = events_init_subscriber(false, RECEIVE_TIMEOUT, null)
63+
sh = events_init_subscriber(False, RECEIVE_TIMEOUT, None)
6464

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

78-
if rc > 0 && publish_cnt < 2:
78+
if rc > 0 and publish_cnt < 2:
7979
# ignore timeout as test code has not yet published an event yet
8080
continue
8181

8282
if rc != 0:
83-
log_notice("Failed to receive. {}/{} rc={}".format(i, cnt, rc))
83+
log_notice("Failed to receive. {}/{} rc={}".format(cnt_done, cnt, rc))
8484
break
8585

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

90-
exp_params["index"] = str(i)
90+
exp_params["index"] = str(cnt_done)
9191
rcv_params = {}
9292
map_dict_fvm(p.params, rcv_params)
9393

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

104104
if (rc != 0):
105-
log_notice("params mismatch {}/{}".format(i,cnt))
105+
log_notice("params mismatch {}/{}".format(cnt_done, cnt))
106106
break
107107

108108
if p.missed_cnt != 0:
109-
log_notice("Expect missed_cnt {} == 0 {}/{}".format(p.missed_cnt,i,cnt))
109+
log_notice("Expect missed_cnt {} == 0 {}/{}".format(p.missed_cnt, cnt_done, cnt))
110110
break
111111

112112
if p.publish_epoch_ms == 0:
113-
log_notice("Expect publish_epoch_ms != 0 {}/{}".format(i,cnt))
113+
log_notice("Expect publish_epoch_ms != 0 {}/{}".format(cnt_done, cnt))
114114
break
115115

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

119119
if (cnt_done == cnt):
120120
rc_test_receive = 0
@@ -127,6 +127,7 @@ def test_receiver(event_obj, cnt):
127127

128128

129129
def publish_events(cnt):
130+
global publish_cnt
130131
rc = -1
131132
ph = events_init_publisher(test_source)
132133
if not ph:
@@ -148,6 +149,7 @@ def publish_events(cnt):
148149
if (rc != 0):
149150
log_notice("Failed to publish. {}/{} rc={}".format(i, cnt, rc))
150151
break
152+
151153
log_debug("published: {}/{}".format(i+1, cnt))
152154
publish_cnt += 1
153155

0 commit comments

Comments
 (0)