Skip to content

Commit

Permalink
Dynamic Port Cfg - VS test
Browse files Browse the repository at this point in the history
Signed-off-by: tomeri <tomeri@nvidia.com>
  • Loading branch information
tomer-israel committed Nov 18, 2021
1 parent 6797c0f commit 853a422
Showing 1 changed file with 125 additions and 0 deletions.
125 changes: 125 additions & 0 deletions tests/test_port_add_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the port to be removed and add
PORT = "Ethernet0"

@pytest.mark.usefixtures('dvs_port_manager')
class TestPortAddRemove(object):

def test_remove_port_with_buffer_cfg(self, dvs, testlog):
Expand Down Expand Up @@ -54,3 +55,127 @@ def test_remove_port_with_buffer_cfg(self, dvs, testlog):

# verify that the port was removed properly since all buffer configuration was removed also
assert len(num) == num_of_ports - 1

config_db.create_entry("PORT",PORT, port_info)

def test_add_remove_a_port(self, dvs, testlog):
config_db = dvs.get_config_db()
asic_db = dvs.get_asic_db()

# get port info
port_info = config_db.get_entry("PORT", PORT)

# # get the number of ports before removal
# num_of_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT"))
#
# # try to remove this port
# config_db.delete_entry('PORT', PORT)
# num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
# num_of_ports-1,
# polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = False))
#
# # verify that the port wasn't removed since we still have buffer cfg
# assert len(num) == num_of_ports


# remove buffer pg cfg for the port
pgs = config_db.get_keys('BUFFER_PG')
for key in pgs:
if PORT in key:
config_db.delete_entry('BUFFER_PG', key)

# remove buffer queue cfg for the port
pgs = config_db.get_keys('BUFFER_QUEUE')
for key in pgs:
if PORT in key:
config_db.delete_entry('BUFFER_QUEUE', key)


# get the number of ports before removal
num_of_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT"))

for i in range(1,10):
# try to remove this port
config_db.delete_entry('PORT', PORT)
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
num_of_ports-1,
polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = True))

# verify that the port wasn't removed since we still have buffer cfg
assert len(num) == num_of_ports - 1

time.sleep((i+1)%3)

config_db.create_entry("PORT",PORT, port_info)

num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
num_of_ports)

# verify that the port wasn't removed since we still have buffer cfg
assert len(num) == num_of_ports

time.sleep(i%3)

def test_add_remove_all_the_ports(self, dvs, testlog):
config_db = dvs.get_config_db()
asic_db = dvs.get_asic_db()

# get the number of ports before removal
num_of_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT"))

# remove buffer pg cfg for the port
ports = config_db.get_keys('PORT')
ports_info = {}

for i in range(10):

for key in ports:

# read port info and save it
ports_info[key] = config_db.get_entry("PORT", key)

# remove a port
self.dvs_port.remove_port(key)

num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
num_of_ports-len(ports))
assert len(num) == num_of_ports-len(ports)

time.sleep((i%3)+1)
for key in ports:
# add port
config_db.create_entry("PORT",key, ports_info[key])

num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
num_of_ports)
assert len(num) == num_of_ports

time.sleep((i%2)+2)

dvs.setup_db()
dvs.create_vlan("6")
dvs.create_vlan_member("6", "Ethernet64")
dvs.create_vlan_member("6", "Ethernet68")
dvs.set_interface_status("Vlan6", "up")
dvs.add_ip_address("Vlan6", "6.6.6.1/24")
dvs.set_interface_status("Ethernet68", "up")
dvs.set_interface_status("Ethernet64", "up")

dvs.servers[16].runcmd("ifconfig eth0 6.6.6.6/24 up")
dvs.servers[16].runcmd("ip route add default via 6.6.6.1")
dvs.servers[17].runcmd("ifconfig eth0 6.6.6.7/24 up")
dvs.servers[17].runcmd("ip route add default via 6.6.6.1")

time.sleep(2)

rc = dvs.servers[16].runcmd("ping -c 1 6.6.6.7")
assert rc == 0

rc = dvs.servers[17].runcmd("ping -c 1 6.6.6.6")
assert rc == 0






0 comments on commit 853a422

Please sign in to comment.