Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic-bgpcfgd] Call Python 3 version of sonic-cfggen for testing #5847

Merged
merged 5 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rules/sonic_bgpcfgd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(SONIC_BGPCFGD)_SRC_PATH = $(SRC_PATH)/sonic-bgpcfgd
# as part of its unit tests.
# TODO: Refactor unit tests so that these dependencies are not needed

$(SONIC_BGPCFGD)_DEPENDS += $(SONIC_PY_COMMON_PY2)
$(SONIC_BGPCFGD)_DEPENDS += $(SONIC_CONFIG_ENGINE_PY3)
$(SONIC_BGPCFGD)_DEBS_DEPENDS += $(PYTHON3_SWSSCOMMON)
$(SONIC_BGPCFGD)_PYTHON_VERSION = 3
SONIC_PYTHON_WHEELS += $(SONIC_BGPCFGD)
3 changes: 2 additions & 1 deletion src/sonic-bgpcfgd/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
tests_require = [
'pytest',
'pytest-cov'
'pytest-cov',
'sonic-config-engine'
]
)
13 changes: 3 additions & 10 deletions src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
!
! template: bgpd/bgpd.conf.j2
!
!
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/quagga/bgpd.conf.j2 with config DB data
! file: bgpd.conf
!
!
! template: common/daemons.common.conf.j2
!
hostname new_hostname
Expand All @@ -19,8 +17,6 @@ log facility local4
! end of template: common/daemons.common.conf.j2!
agentx
!
!
!
! template: bgpd/bgpd.main.conf.j2
!
! bgp multiple-instance
Expand All @@ -33,15 +29,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 5 permit fc01::/64
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
!
route-map HIDE_INTERNAL permit 10
set community local-AS
!
!
router bgp 55555
!
bgp log-neighbor-changes
Expand All @@ -61,11 +55,10 @@ router bgp 55555
network fc00::1/64
exit-address-family
!
network 10.10.10.1/24
address-family ipv6
network fc01::1/64
exit-address-family
network 10.10.10.1/24
!
!
address-family ipv4
redistribute connected route-map HIDE_INTERNAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 15 permit fc01::/64
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
!
route-map HIDE_INTERNAL permit 10
set community local-AS
!
!
router bgp 55555
!
bgp log-neighbor-changes
Expand All @@ -43,7 +41,6 @@ router bgp 55555
address-family ipv6
network fc01::1/64
exit-address-family
!
!
address-family ipv4
redistribute connected route-map HIDE_INTERNAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 15 permit fc01::/64
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
!
route-map HIDE_INTERNAL permit 10
set community local-AS
!
!
router bgp 55555
!
bgp log-neighbor-changes
Expand All @@ -43,7 +41,6 @@ router bgp 55555
address-family ipv6
network fc01::1/64
exit-address-family
!
!
address-family ipv4
redistribute connected route-map HIDE_INTERNAL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
!
! Vnet BGP instance
router bgp 555 vrf Second
router bgp 555 vrf First
no bgp default ipv4-unicast
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
bgp graceful-restart restart-time 240
bgp graceful-restart
bgp router-id 10.20.30.40
neighbor 20.20.20.1 remote-as 20
neighbor 20.20.20.1 description session2
neighbor 10.10.10.1 remote-as 10
neighbor 10.10.10.1 description session1
address-family ipv4 unicast
neighbor 20.20.20.1 activate
neighbor 20.20.20.1 soft-reconfiguration inbound
neighbor 10.10.10.1 activate
neighbor 10.10.10.1 soft-reconfiguration inbound
maximum-paths 64
exit-address-family
address-family l2vpn evpn
advertise ipv4 unicast
exit-address-family
router bgp 555 vrf First
router bgp 555 vrf Second
no bgp default ipv4-unicast
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
bgp graceful-restart restart-time 240
bgp graceful-restart
bgp router-id 10.20.30.40
neighbor 10.10.10.1 remote-as 10
neighbor 10.10.10.1 description session1
neighbor 20.20.20.1 remote-as 20
neighbor 20.20.20.1 description session2
address-family ipv4 unicast
neighbor 10.10.10.1 activate
neighbor 10.10.10.1 soft-reconfiguration inbound
neighbor 20.20.20.1 activate
neighbor 20.20.20.1 soft-reconfiguration inbound
maximum-paths 64
exit-address-family
address-family l2vpn evpn
Expand Down
16 changes: 5 additions & 11 deletions src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
! generated by templates/frr.conf.j2 with config DB data
! file: frr.conf
!
!
! template: common/daemons.common.conf.j2
!
hostname test_hostname
Expand All @@ -16,15 +15,13 @@ log facility local4
! end of template: common/daemons.common.conf.j2!
agentx
!
!
!
! Enable nht through default route
ip nht resolve-via-default
! Enable link-detect (default disabled)
interface Ethernet4
interface Ethernet0
link-detect
!
interface Ethernet0
interface Ethernet4
link-detect
!
interface PortChannel10
Expand All @@ -51,15 +48,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 5 permit fc01::/64
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
!
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
!
route-map HIDE_INTERNAL permit 10
set community local-AS
!
!
router bgp 55555
!
bgp log-neighbor-changes
Expand All @@ -79,11 +74,10 @@ router bgp 55555
network fc00::1/64
exit-address-family
!
network 10.10.10.1/24
address-family ipv6
network fc01::1/64
exit-address-family
network 10.10.10.1/24
!
!
address-family ipv4
redistribute connected route-map HIDE_INTERNAL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
!
!
! Enable nht through default route
ip nht resolve-via-default
! Enable link-detect (default disabled)
interface Ethernet4
interface Ethernet0
link-detect
!
interface Ethernet0
interface Ethernet4
link-detect
!
interface PortChannel10
Expand All @@ -15,4 +14,3 @@ link-detect
interface PortChannel20
link-detect
!
!
10 changes: 4 additions & 6 deletions src/sonic-bgpcfgd/tests/data/sonic-cfggen/zebra/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
! generated by templates/zebra/zebra.conf.j2 using config DB data
! file: zebra.conf
!
!
! template: common/daemons.common.conf.j2
!
hostname new_hostname
Expand All @@ -15,20 +14,19 @@ log facility local4
!
! end of template: common/daemons.common.conf.j2!
!
vrf Second
vni 20
!
vrf First
vni 10
!
vrf Second
vni 20
!
! Enable nht through default route
ip nht resolve-via-default
! Enable link-detect (default disabled)
interface Ethernet4
interface Ethernet0
link-detect
!
interface Ethernet0
interface Ethernet4
link-detect
!
interface PortChannel10
Expand Down
5 changes: 2 additions & 3 deletions src/sonic-bgpcfgd/tests/test_sonic-cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
def run_test(name, template_path, json_path, match_path):
template_path = os.path.join(TEMPLATE_PATH, template_path)
json_path = os.path.join(DATA_PATH, json_path)
cfggen = os.path.abspath("../sonic-config-engine/sonic-cfggen")
command = ['/usr/bin/python2.7', cfggen, "-T", TEMPLATE_PATH, "-t", template_path, "-y", json_path]
p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={"PYTHONPATH": "."})
command = ['sonic-cfggen', "-T", TEMPLATE_PATH, "-t", template_path, "-y", json_path]
p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
assert p.returncode == 0, "sonic-cfggen for %s test returned %d code. stderr='%s'" % (name, p.returncode, stderr)
raw_generated_result = stdout.decode("ascii")
Expand Down