Skip to content

Commit

Permalink
add testlog for all tests
Browse files Browse the repository at this point in the history
Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan committed Oct 22, 2018
1 parent a2d9be4 commit e04bd2d
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 75 deletions.
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,9 @@ def dvs(request):
dvs = DockerVirtualSwitch(name)
yield dvs
dvs.destroy()

@pytest.yield_fixture
def testlog(request, dvs):
dvs.runcmd("logger === start test %s ===" % request.node.name)
yield testlog
dvs.runcmd("logger === finish test %s ===" % request.node.name)
42 changes: 21 additions & 21 deletions tests/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def verify_acl_lag_binding(self, adb, lag_ids):
assert len(port_groups) == len(lag_ids)
assert set(port_groups) == set(acl_table_groups)

def test_AclTableCreation(self, dvs):
def test_AclTableCreation(self, dvs, testlog):
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)

Expand Down Expand Up @@ -159,7 +159,7 @@ def test_AclTableCreation(self, dvs):
# check port binding
self.verify_acl_port_binding(dvs, adb, bind_ports)

def test_AclRuleL4SrcPort(self, dvs):
def test_AclRuleL4SrcPort(self, dvs, testlog):
"""
hmset ACL_RULE|test|acl_test_rule priority 55 PACKET_ACTION FORWARD L4_SRC_PORT 65000
"""
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_AclRuleL4SrcPort(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_AclRuleInOutPorts(self, dvs):
def test_AclRuleInOutPorts(self, dvs, testlog):
"""
hmset ACL_RULE|test|acl_test_rule priority 55 PACKET_ACTION FORWARD IN_PORTS Ethernet0,Ethernet4 OUT_PORTS Ethernet8,Ethernet12
"""
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_AclRuleInOutPorts(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_AclTableDeletion(self, dvs):
def test_AclTableDeletion(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand All @@ -286,7 +286,7 @@ def test_AclTableDeletion(self, dvs):
# only the default table was left along with DTel tables
assert len(keys) >= 1

def test_V6AclTableCreation(self, dvs):
def test_V6AclTableCreation(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_V6AclTableCreation(self, dvs):

assert set(port_groups) == set(acl_table_groups)

def test_V6AclRuleIPv6Any(self, dvs):
def test_V6AclRuleIPv6Any(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule1 priority 1000 PACKET_ACTION FORWARD IPv6Any
"""
Expand Down Expand Up @@ -410,7 +410,7 @@ def test_V6AclRuleIPv6Any(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleIPv6AnyDrop(self, dvs):
def test_V6AclRuleIPv6AnyDrop(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule2 priority 1002 PACKET_ACTION DROP IPv6Any
"""
Expand Down Expand Up @@ -461,7 +461,7 @@ def test_V6AclRuleIPv6AnyDrop(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleIpProtocol(self, dvs):
def test_V6AclRuleIpProtocol(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule3 priority 1003 PACKET_ACTION DROP IP_PROTOCOL 6
"""
Expand Down Expand Up @@ -512,7 +512,7 @@ def test_V6AclRuleIpProtocol(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleSrcIPv6(self, dvs):
def test_V6AclRuleSrcIPv6(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule4 priority 1004 PACKET_ACTION DROP SRC_IPV6 2777::0/64
"""
Expand Down Expand Up @@ -563,7 +563,7 @@ def test_V6AclRuleSrcIPv6(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleDstIPv6(self, dvs):
def test_V6AclRuleDstIPv6(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule5 priority 1005 PACKET_ACTION DROP DST_IPV6 2002::2/128
"""
Expand Down Expand Up @@ -614,7 +614,7 @@ def test_V6AclRuleDstIPv6(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleL4SrcPort(self, dvs):
def test_V6AclRuleL4SrcPort(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule6 priority 1006 PACKET_ACTION DROP L4_SRC_PORT 65000
"""
Expand Down Expand Up @@ -665,7 +665,7 @@ def test_V6AclRuleL4SrcPort(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleL4DstPort(self, dvs):
def test_V6AclRuleL4DstPort(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule7 priority 1007 PACKET_ACTION DROP L4_DST_PORT 65001
"""
Expand Down Expand Up @@ -716,7 +716,7 @@ def test_V6AclRuleL4DstPort(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleTCPFlags(self, dvs):
def test_V6AclRuleTCPFlags(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule8 priority 1008 PACKET_ACTION DROP TCP_FLAGS 0x7/0x3f
"""
Expand Down Expand Up @@ -767,7 +767,7 @@ def test_V6AclRuleTCPFlags(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleL4SrcPortRange(self, dvs):
def test_V6AclRuleL4SrcPortRange(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule9 priority 1009 PACKET_ACTION DROP L4_SRC_PORT_RANGE 1-100
"""
Expand Down Expand Up @@ -832,7 +832,7 @@ def test_V6AclRuleL4SrcPortRange(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclRuleL4DstPortRange(self, dvs):
def test_V6AclRuleL4DstPortRange(self, dvs, testlog):
"""
hmset ACL_RULE|test-aclv6|test_rule10 priority 1010 PACKET_ACTION DROP L4_DST_PORT_RANGE 101-200
"""
Expand Down Expand Up @@ -897,7 +897,7 @@ def test_V6AclRuleL4DstPortRange(self, dvs):
(status, fvs) = atbl.get(acl_entry[0])
assert status == False

def test_V6AclTableDeletion(self, dvs):
def test_V6AclTableDeletion(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down Expand Up @@ -928,7 +928,7 @@ def check_rule_existence(self, entry, rules, verifs):
#did not find the rule
return False

def test_InsertAclRuleBetweenPriorities(self, dvs):
def test_InsertAclRuleBetweenPriorities(self, dvs, testlog):
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)

Expand Down Expand Up @@ -1026,7 +1026,7 @@ def test_InsertAclRuleBetweenPriorities(self, dvs):
# only the default table was left
assert len(keys) >= 1

def test_RulesWithDiffMaskLengths(self, dvs):
def test_RulesWithDiffMaskLengths(self, dvs, testlog):
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)

Expand Down Expand Up @@ -1111,7 +1111,7 @@ def test_RulesWithDiffMaskLengths(self, dvs):
keys = atbl.getKeys()
assert len(keys) >= 1

def test_AclTableCreationOnLAGMember(self, dvs):
def test_AclTableCreationOnLAGMember(self, dvs, testlog):
# prepare db and tables
self.clean_up_left_over(dvs)
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
Expand Down Expand Up @@ -1139,7 +1139,7 @@ def test_AclTableCreationOnLAGMember(self, dvs):
# verify test result - ACL table creation should fail
assert self.verify_if_any_acl_table_created(dvs, adb) == False

def test_AclTableCreationOnLAG(self, dvs):
def test_AclTableCreationOnLAG(self, dvs, testlog):
# prepare db and tables
self.clean_up_left_over(dvs)
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
Expand Down Expand Up @@ -1189,7 +1189,7 @@ def test_AclTableCreationOnLAG(self, dvs):
tbl = swsscommon.Table(db, "ACL_TABLE")
tbl._del("test_LAG")

def test_AclTableCreationBeforeLAG(self, dvs):
def test_AclTableCreationBeforeLAG(self, dvs, testlog):
# prepare db and tables
self.clean_up_left_over(dvs)
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setReadOnlyAttr(dvs, obj, attr, val):
ntf.send("set_ro", key, fvp)


def test_CrmFdbEntry(dvs):
def test_CrmFdbEntry(dvs, testlog):

dvs.runcmd("crm config polling interval 1")

Expand Down Expand Up @@ -92,7 +92,7 @@ def test_CrmFdbEntry(dvs):
assert new_avail_counter == avail_counter


def test_CrmIpv4Route(dvs):
def test_CrmIpv4Route(dvs, testlog):

dvs.runcmd("ifconfig Ethernet0 10.0.0.0/31 up")

Expand Down Expand Up @@ -141,7 +141,7 @@ def test_CrmIpv4Route(dvs):
assert new_avail_counter == avail_counter


def test_CrmIpv6Route(dvs):
def test_CrmIpv6Route(dvs, testlog):

# Enable IPv6 routing
dvs.runcmd("sysctl net.ipv6.conf.all.disable_ipv6=0")
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_CrmIpv6Route(dvs):
assert new_avail_counter == avail_counter


def test_CrmIpv4Nexthop(dvs):
def test_CrmIpv4Nexthop(dvs, testlog):

dvs.runcmd("ifconfig Ethernet0 10.0.0.0/31 up")

Expand Down Expand Up @@ -238,7 +238,7 @@ def test_CrmIpv4Nexthop(dvs):
assert new_avail_counter == avail_counter


def test_CrmIpv6Nexthop(dvs):
def test_CrmIpv6Nexthop(dvs, testlog):

# Enable IPv6 routing
dvs.runcmd("sysctl net.ipv6.conf.all.disable_ipv6=0")
Expand Down Expand Up @@ -283,7 +283,7 @@ def test_CrmIpv6Nexthop(dvs):
assert new_avail_counter == avail_counter


def test_CrmIpv4Neighbor(dvs):
def test_CrmIpv4Neighbor(dvs, testlog):

dvs.runcmd("ifconfig Ethernet0 10.0.0.0/31 up")

Expand Down Expand Up @@ -324,7 +324,7 @@ def test_CrmIpv4Neighbor(dvs):
assert new_avail_counter == avail_counter


def test_CrmIpv6Neighbor(dvs):
def test_CrmIpv6Neighbor(dvs, testlog):

# Enable IPv6 routing
dvs.runcmd("sysctl net.ipv6.conf.all.disable_ipv6=0")
Expand Down Expand Up @@ -369,7 +369,7 @@ def test_CrmIpv6Neighbor(dvs):
assert new_avail_counter == avail_counter


def test_CrmNexthopGroup(dvs):
def test_CrmNexthopGroup(dvs, testlog):

dvs.runcmd("ifconfig Ethernet0 10.0.0.0/31 up")
dvs.runcmd("ifconfig Ethernet4 10.0.0.2/31 up")
Expand Down Expand Up @@ -421,7 +421,7 @@ def test_CrmNexthopGroup(dvs):
assert new_avail_counter == avail_counter


def test_CrmNexthopGroupMember(dvs):
def test_CrmNexthopGroupMember(dvs, testlog):

# down, then up to generate port up signal
dvs.servers[0].runcmd("ip link set down dev eth0") == 0
Expand Down Expand Up @@ -479,7 +479,7 @@ def test_CrmNexthopGroupMember(dvs):
assert new_avail_counter == avail_counter


def test_CrmAcl(dvs):
def test_CrmAcl(dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dirbcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import json

def test_DirectedBroadcast(dvs):
def test_DirectedBroadcast(dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_dtel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import json

class TestDtel(object):
def test_DtelGlobalAttribs(self, dvs):
def test_DtelGlobalAttribs(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_DtelGlobalAttribs(self, dvs):
tbl._del("QUEUE_REPORT")
tbl._del("SINK_PORT_LIST")

def test_DtelReportSessionAttribs(self, dvs):
def test_DtelReportSessionAttribs(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_DtelReportSessionAttribs(self, dvs):

tbl._del("RS-1")

def test_DtelINTSessionAttribs(self, dvs):
def test_DtelINTSessionAttribs(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_DtelINTSessionAttribs(self, dvs):

tbl._del("INT-1")

def test_DtelQueueReportAttribs(self, dvs):
def test_DtelQueueReportAttribs(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_DtelQueueReportAttribs(self, dvs):
tbl._del("Ethernet0|0")


def test_DtelEventAttribs(self, dvs):
def test_DtelEventAttribs(self, dvs, testlog):

db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fdb_cold.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def how_many_entries_exist(db, table):
tbl = swsscommon.Table(db, table)
return len(tbl.getKeys())

def test_FDBAddedAfterMemberCreated(dvs):
def test_FDBAddedAfterMemberCreated(dvs, testlog):
dvs.setup_db()

dvs.runcmd("sonic-clear fdb all")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fdb_warm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def how_many_entries_exist(db, table):
tbl = swsscommon.Table(db, table)
return len(tbl.getKeys())

def test_fdb_notifications(dvs):
def test_fdb_notifications(dvs, testlog):
dvs.setup_db()

dvs.runcmd("sonic-clear fdb all")
Expand Down
8 changes: 4 additions & 4 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def set_mtu(self, interface, mtu):
tbl.set(interface, fvs)
time.sleep(1)

def test_InterfaceAddRemoveIpv4Address(self, dvs):
def test_InterfaceAddRemoveIpv4Address(self, dvs, testlog):
self.setup_db(dvs)

# assign IP to interface
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_InterfaceAddRemoveIpv4Address(self, dvs):
if route["dest"] == "10.0.0.4/32":
assert False

def test_InterfaceSetMtu(self, dvs):
def test_InterfaceSetMtu(self, dvs, testlog):
self.setup_db(dvs)

# assign IP to interface
Expand Down Expand Up @@ -175,7 +175,7 @@ def set_mtu(self, interface, mtu):
tbl.set(interface, fvs)
time.sleep(1)

def test_InterfaceAddRemoveIpv4Address(self, dvs):
def test_InterfaceAddRemoveIpv4Address(self, dvs, testlog):
self.setup_db(dvs)

# create port channel
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_InterfaceAddRemoveIpv4Address(self, dvs):
self.remove_port_channel(dvs, "PortChannel001")


def test_InterfaceSetMtu(self, dvs):
def test_InterfaceSetMtu(self, dvs, testlog):
self.setup_db(dvs)

# create port channel
Expand Down
Loading

0 comments on commit e04bd2d

Please sign in to comment.