-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored test_events to use gnmi_cli_py client running in docker-ptf to make more stable
- Loading branch information
Showing
6 changed files
with
92 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import logging | ||
|
||
from run_events_test import run_test | ||
|
||
logger = logging.getLogger(__name__) | ||
tag = "sonic-events-eventd" | ||
|
||
|
||
def test_event(duthost, gnxi_path, ptfhost, data_dir, validate_yang): | ||
logger.info("Beginning to test eventd heartbeat") | ||
run_test(duthost, gnxi_path, ptfhost, data_dir, validate_yang, None, | ||
"heartbeat.json", "sonic-events-eventd:heartbeat", tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import json | ||
import logging | ||
import os | ||
|
||
|
||
from telemetry_utils import listen_for_events | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def run_test(duthost, gnxi_path, ptfhost, data_dir, validate_yang, trigger, json_file, | ||
filter_event_regex, tag): | ||
op_file = os.path.join(data_dir, json_file) | ||
heartbeat = trigger is None | ||
if not heartbeat: # no trigger for heartbeat | ||
trigger(duthost) # add events to cache | ||
listen_for_events(duthost, gnxi_path, ptfhost, filter_event_regex, op_file) # listen from cache | ||
data = {} | ||
with open(op_file, "r") as f: | ||
data = json.load(f) | ||
assert len(data) > 0, "Did not parse regex from output: {}".format(filter_event_regex) | ||
logger.info("events received: ({})".format(json.dumps(data, indent=4))) | ||
if heartbeat: # no yang validation for heartbeat | ||
return | ||
dest = "/tmp/" + json_file | ||
duthost.copy(src=op_file, dest=dest) | ||
validate_yang(duthost, dest, tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters