[sonic-bgpcfgd] Call Python 3 version of sonic-cfggen for testing (#5847)
sonic-bgpcfgd build fails in the absence of Python 2, as it attempts to explicitly call sonic-cfggen using `/usr/bin/python2.7`. Also, it attempts to call sonic-cfggen using a local, relative path. Since the sonic-config-engine package is not installed, neither are its dependencies. Now, we configure the Python 3 sonic-config-engine as a dependency of sonic-bgpcfgd, which ensures the Python 3 sonic-config-engine package and its dependencies are installed before sonic-bgpcfgd is built/tested.
This commit is contained in:
parent
48822be2aa
commit
56fa3cf494
@ -7,7 +7,7 @@ $(SONIC_BGPCFGD)_SRC_PATH = $(SRC_PATH)/sonic-bgpcfgd
|
|||||||
# as part of its unit tests.
|
# as part of its unit tests.
|
||||||
# TODO: Refactor unit tests so that these dependencies are not needed
|
# 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)_DEBS_DEPENDS += $(PYTHON3_SWSSCOMMON)
|
||||||
$(SONIC_BGPCFGD)_PYTHON_VERSION = 3
|
$(SONIC_BGPCFGD)_PYTHON_VERSION = 3
|
||||||
SONIC_PYTHON_WHEELS += $(SONIC_BGPCFGD)
|
SONIC_PYTHON_WHEELS += $(SONIC_BGPCFGD)
|
||||||
|
@ -26,6 +26,7 @@ setuptools.setup(
|
|||||||
],
|
],
|
||||||
tests_require = [
|
tests_require = [
|
||||||
'pytest',
|
'pytest',
|
||||||
'pytest-cov'
|
'pytest-cov',
|
||||||
|
'sonic-config-engine'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
!
|
!
|
||||||
! template: bgpd/bgpd.conf.j2
|
! template: bgpd/bgpd.conf.j2
|
||||||
!
|
!
|
||||||
!
|
|
||||||
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
||||||
! generated by templates/quagga/bgpd.conf.j2 with config DB data
|
! generated by templates/quagga/bgpd.conf.j2 with config DB data
|
||||||
! file: bgpd.conf
|
! file: bgpd.conf
|
||||||
!
|
!
|
||||||
!
|
|
||||||
! template: common/daemons.common.conf.j2
|
! template: common/daemons.common.conf.j2
|
||||||
!
|
!
|
||||||
hostname new_hostname
|
hostname new_hostname
|
||||||
@ -19,8 +17,6 @@ log facility local4
|
|||||||
! end of template: common/daemons.common.conf.j2!
|
! end of template: common/daemons.common.conf.j2!
|
||||||
agentx
|
agentx
|
||||||
!
|
!
|
||||||
!
|
|
||||||
!
|
|
||||||
! template: bgpd/bgpd.main.conf.j2
|
! template: bgpd/bgpd.main.conf.j2
|
||||||
!
|
!
|
||||||
! bgp multiple-instance
|
! bgp multiple-instance
|
||||||
@ -33,15 +29,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
|||||||
!
|
!
|
||||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||||
!
|
!
|
||||||
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
|
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
|
||||||
!
|
|
||||||
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 5 permit fc01::/64
|
|
||||||
!
|
!
|
||||||
|
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
|
||||||
!
|
!
|
||||||
route-map HIDE_INTERNAL permit 10
|
route-map HIDE_INTERNAL permit 10
|
||||||
set community local-AS
|
set community local-AS
|
||||||
!
|
!
|
||||||
!
|
|
||||||
router bgp 55555
|
router bgp 55555
|
||||||
!
|
!
|
||||||
bgp log-neighbor-changes
|
bgp log-neighbor-changes
|
||||||
@ -61,11 +55,10 @@ router bgp 55555
|
|||||||
network fc00::1/64
|
network fc00::1/64
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
|
network 10.10.10.1/24
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
network fc01::1/64
|
network fc01::1/64
|
||||||
exit-address-family
|
exit-address-family
|
||||||
network 10.10.10.1/24
|
|
||||||
!
|
|
||||||
!
|
!
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
redistribute connected route-map HIDE_INTERNAL
|
redistribute connected route-map HIDE_INTERNAL
|
||||||
|
@ -11,15 +11,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
|||||||
!
|
!
|
||||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||||
!
|
!
|
||||||
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
|
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
|
||||||
!
|
|
||||||
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 15 permit fc01::/64
|
|
||||||
!
|
!
|
||||||
|
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
|
||||||
!
|
!
|
||||||
route-map HIDE_INTERNAL permit 10
|
route-map HIDE_INTERNAL permit 10
|
||||||
set community local-AS
|
set community local-AS
|
||||||
!
|
!
|
||||||
!
|
|
||||||
router bgp 55555
|
router bgp 55555
|
||||||
!
|
!
|
||||||
bgp log-neighbor-changes
|
bgp log-neighbor-changes
|
||||||
@ -43,7 +41,6 @@ router bgp 55555
|
|||||||
address-family ipv6
|
address-family ipv6
|
||||||
network fc01::1/64
|
network fc01::1/64
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
|
||||||
!
|
!
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
redistribute connected route-map HIDE_INTERNAL
|
redistribute connected route-map HIDE_INTERNAL
|
||||||
|
@ -11,15 +11,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
|||||||
!
|
!
|
||||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||||
!
|
!
|
||||||
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
|
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
|
||||||
!
|
|
||||||
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 15 permit fc01::/64
|
|
||||||
!
|
!
|
||||||
|
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
|
||||||
!
|
!
|
||||||
route-map HIDE_INTERNAL permit 10
|
route-map HIDE_INTERNAL permit 10
|
||||||
set community local-AS
|
set community local-AS
|
||||||
!
|
!
|
||||||
!
|
|
||||||
router bgp 55555
|
router bgp 55555
|
||||||
!
|
!
|
||||||
bgp log-neighbor-changes
|
bgp log-neighbor-changes
|
||||||
@ -43,7 +41,6 @@ router bgp 55555
|
|||||||
address-family ipv6
|
address-family ipv6
|
||||||
network fc01::1/64
|
network fc01::1/64
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
|
||||||
!
|
!
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
redistribute connected route-map HIDE_INTERNAL
|
redistribute connected route-map HIDE_INTERNAL
|
||||||
|
@ -1,23 +1,5 @@
|
|||||||
!
|
!
|
||||||
! Vnet BGP instance
|
! Vnet BGP instance
|
||||||
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 20.20.20.1 remote-as 20
|
|
||||||
neighbor 20.20.20.1 description session2
|
|
||||||
address-family ipv4 unicast
|
|
||||||
neighbor 20.20.20.1 activate
|
|
||||||
neighbor 20.20.20.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 First
|
||||||
no bgp default ipv4-unicast
|
no bgp default ipv4-unicast
|
||||||
bgp log-neighbor-changes
|
bgp log-neighbor-changes
|
||||||
@ -36,4 +18,22 @@ router bgp 555 vrf First
|
|||||||
address-family l2vpn evpn
|
address-family l2vpn evpn
|
||||||
advertise ipv4 unicast
|
advertise ipv4 unicast
|
||||||
exit-address-family
|
exit-address-family
|
||||||
|
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 20.20.20.1 remote-as 20
|
||||||
|
neighbor 20.20.20.1 description session2
|
||||||
|
address-family ipv4 unicast
|
||||||
|
neighbor 20.20.20.1 activate
|
||||||
|
neighbor 20.20.20.1 soft-reconfiguration inbound
|
||||||
|
maximum-paths 64
|
||||||
|
exit-address-family
|
||||||
|
address-family l2vpn evpn
|
||||||
|
advertise ipv4 unicast
|
||||||
|
exit-address-family
|
||||||
!
|
!
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
! generated by templates/frr.conf.j2 with config DB data
|
! generated by templates/frr.conf.j2 with config DB data
|
||||||
! file: frr.conf
|
! file: frr.conf
|
||||||
!
|
!
|
||||||
!
|
|
||||||
! template: common/daemons.common.conf.j2
|
! template: common/daemons.common.conf.j2
|
||||||
!
|
!
|
||||||
hostname test_hostname
|
hostname test_hostname
|
||||||
@ -16,15 +15,13 @@ log facility local4
|
|||||||
! end of template: common/daemons.common.conf.j2!
|
! end of template: common/daemons.common.conf.j2!
|
||||||
agentx
|
agentx
|
||||||
!
|
!
|
||||||
!
|
|
||||||
!
|
|
||||||
! Enable nht through default route
|
! Enable nht through default route
|
||||||
ip nht resolve-via-default
|
ip nht resolve-via-default
|
||||||
! Enable link-detect (default disabled)
|
! Enable link-detect (default disabled)
|
||||||
interface Ethernet4
|
interface Ethernet0
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
interface Ethernet0
|
interface Ethernet4
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
interface PortChannel10
|
interface PortChannel10
|
||||||
@ -51,15 +48,13 @@ ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
|||||||
!
|
!
|
||||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||||
!
|
!
|
||||||
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 10.10.10.0/24
|
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24
|
||||||
!
|
|
||||||
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 5 permit fc01::/64
|
|
||||||
!
|
!
|
||||||
|
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64
|
||||||
!
|
!
|
||||||
route-map HIDE_INTERNAL permit 10
|
route-map HIDE_INTERNAL permit 10
|
||||||
set community local-AS
|
set community local-AS
|
||||||
!
|
!
|
||||||
!
|
|
||||||
router bgp 55555
|
router bgp 55555
|
||||||
!
|
!
|
||||||
bgp log-neighbor-changes
|
bgp log-neighbor-changes
|
||||||
@ -79,11 +74,10 @@ router bgp 55555
|
|||||||
network fc00::1/64
|
network fc00::1/64
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
|
network 10.10.10.1/24
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
network fc01::1/64
|
network fc01::1/64
|
||||||
exit-address-family
|
exit-address-family
|
||||||
network 10.10.10.1/24
|
|
||||||
!
|
|
||||||
!
|
!
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
redistribute connected route-map HIDE_INTERNAL
|
redistribute connected route-map HIDE_INTERNAL
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
!
|
!
|
||||||
!
|
|
||||||
! Enable nht through default route
|
! Enable nht through default route
|
||||||
ip nht resolve-via-default
|
ip nht resolve-via-default
|
||||||
! Enable link-detect (default disabled)
|
! Enable link-detect (default disabled)
|
||||||
interface Ethernet4
|
interface Ethernet0
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
interface Ethernet0
|
interface Ethernet4
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
interface PortChannel10
|
interface PortChannel10
|
||||||
@ -15,4 +14,3 @@ link-detect
|
|||||||
interface PortChannel20
|
interface PortChannel20
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
!
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
! generated by templates/zebra/zebra.conf.j2 using config DB data
|
! generated by templates/zebra/zebra.conf.j2 using config DB data
|
||||||
! file: zebra.conf
|
! file: zebra.conf
|
||||||
!
|
!
|
||||||
!
|
|
||||||
! template: common/daemons.common.conf.j2
|
! template: common/daemons.common.conf.j2
|
||||||
!
|
!
|
||||||
hostname new_hostname
|
hostname new_hostname
|
||||||
@ -15,20 +14,19 @@ log facility local4
|
|||||||
!
|
!
|
||||||
! end of template: common/daemons.common.conf.j2!
|
! end of template: common/daemons.common.conf.j2!
|
||||||
!
|
!
|
||||||
vrf Second
|
|
||||||
vni 20
|
|
||||||
!
|
|
||||||
vrf First
|
vrf First
|
||||||
vni 10
|
vni 10
|
||||||
!
|
!
|
||||||
|
vrf Second
|
||||||
|
vni 20
|
||||||
!
|
!
|
||||||
! Enable nht through default route
|
! Enable nht through default route
|
||||||
ip nht resolve-via-default
|
ip nht resolve-via-default
|
||||||
! Enable link-detect (default disabled)
|
! Enable link-detect (default disabled)
|
||||||
interface Ethernet4
|
interface Ethernet0
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
interface Ethernet0
|
interface Ethernet4
|
||||||
link-detect
|
link-detect
|
||||||
!
|
!
|
||||||
interface PortChannel10
|
interface PortChannel10
|
||||||
|
@ -12,9 +12,8 @@ CONSTANTS_PATH = os.path.abspath('../../files/image_config/constants/constants.y
|
|||||||
def run_test(name, template_path, json_path, match_path):
|
def run_test(name, template_path, json_path, match_path):
|
||||||
template_path = os.path.join(TEMPLATE_PATH, template_path)
|
template_path = os.path.join(TEMPLATE_PATH, template_path)
|
||||||
json_path = os.path.join(DATA_PATH, json_path)
|
json_path = os.path.join(DATA_PATH, json_path)
|
||||||
cfggen = os.path.abspath("../sonic-config-engine/sonic-cfggen")
|
command = ['sonic-cfggen', "-T", TEMPLATE_PATH, "-t", template_path, "-y", json_path]
|
||||||
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)
|
||||||
p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={"PYTHONPATH": "."})
|
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
assert p.returncode == 0, "sonic-cfggen for %s test returned %d code. stderr='%s'" % (name, p.returncode, stderr)
|
assert p.returncode == 0, "sonic-cfggen for %s test returned %d code. stderr='%s'" % (name, p.returncode, stderr)
|
||||||
raw_generated_result = stdout.decode("ascii")
|
raw_generated_result = stdout.decode("ascii")
|
||||||
|
Loading…
Reference in New Issue
Block a user