forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support share image for gnmi and telemetry (sonic-net#10348)
What is the motivation for this PR? We will share docker image to support gnmi and telemetry. So we need to update minigraph, gnmi and telemetry test to support this change. How did you do it? For telemetry test, check telemetry container at first, if there's no telemetry container, use gnmi container. For gnmi test, check gnmi container at first, if there's no gnmi container, use telemetry container. For minigraph test, check feature status to choose service. How did you verify/test it? Run end to end test.
- Loading branch information
Showing
9 changed files
with
212 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from functools import lru_cache | ||
import pytest | ||
|
||
|
||
@lru_cache(maxsize=None) | ||
class GNMIEnvironment(object): | ||
TELEMETRY_MODE = 0 | ||
GNMI_MODE = 1 | ||
|
||
def __init__(self, duthost, mode): | ||
if mode == self.TELEMETRY_MODE: | ||
ret = self.generate_telemetry_config(duthost) | ||
if ret: | ||
return | ||
ret = self.generate_gnmi_config(duthost) | ||
if ret: | ||
return | ||
elif mode == self.GNMI_MODE: | ||
ret = self.generate_gnmi_config(duthost) | ||
if ret: | ||
return | ||
ret = self.generate_telemetry_config(duthost) | ||
if ret: | ||
return | ||
pytest.fail("Can't generate GNMI/TELEMETRY configuration, mode %d" % mode) | ||
|
||
def generate_gnmi_config(self, duthost): | ||
cmd = "docker images | grep -w sonic-gnmi" | ||
if duthost.shell(cmd, module_ignore_errors=True)['rc'] == 0: | ||
cmd = "docker ps | grep -w gnmi" | ||
if duthost.shell(cmd, module_ignore_errors=True)['rc'] == 0: | ||
self.gnmi_config_table = "GNMI" | ||
self.gnmi_container = "gnmi" | ||
self.gnmi_program = "gnmi-native" | ||
self.gnmi_port = 50052 | ||
return True | ||
else: | ||
pytest.fail("GNMI is not running") | ||
return False | ||
|
||
def generate_telemetry_config(self, duthost): | ||
cmd = "docker images | grep -w sonic-telemety" | ||
if duthost.shell(cmd, module_ignore_errors=True)['rc'] == 0: | ||
cmd = "docker ps | grep -w telemety" | ||
if duthost.shell(cmd, module_ignore_errors=True)['rc'] == 0: | ||
self.gnmi_config_table = "TELEMETRY" | ||
self.gnmi_container = "telemetry" | ||
self.gnmi_program = "telemetry" | ||
self.gnmi_port = 50051 | ||
return True | ||
else: | ||
pytest.fail("Telemetry is not running") | ||
return False |
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
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
Oops, something went wrong.