Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Azure/sonic-mgmt into zero_ports_2
Browse files Browse the repository at this point in the history
resolve merge conflict of test_telemetry
  • Loading branch information
slutati1536 committed Aug 18, 2021
2 parents bc97af9 + f50ae15 commit a9f9453
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 72 deletions.
86 changes: 48 additions & 38 deletions ansible/roles/vm_set/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

# Need latest ubuntu 4.10 kernel to fix a openvswitch bug
# https://bugs.launchpad.net/ubuntu/+source/kernel-package/+bug/1685742
- name: Set the default variable package_installation
set_fact:
package_installation: true
when: package_installation is not defined

- name: get host distribution
shell: grep ^NAME /etc/os-release | awk -F '=' '{print $2}' | tr -d '"'
register: host_distribution
Expand Down Expand Up @@ -52,45 +57,49 @@
- name: Prompt for rebooting
fail:
msg: "Kernel upgraded, need to reboot!"
when: kernel_upgrade_needed is defined
when:
- kernel_upgrade_needed is defined
- package_installation|bool

- name: Install necessary packages
apt: pkg={{ item }} update_cache=yes cache_valid_time=86400
become: yes
with_items:
- ifupdown
- qemu
- openvswitch-switch
- net-tools
- bridge-utils
- util-linux
- iproute2
- vlan
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- libvirt-clients

- name:
apt:
pkg:
- python
- libvirt-bin
- python-libvirt
- python-pip
become: yes
when: host_distribution_version.stdout == "18.04"

- name:
apt:
pkg:
- python3-libvirt
- python3-pip
- libvirt-daemon-system
- qemu-system-x86
become: yes
when: host_distribution_version.stdout == "20.04"
- block:
- name: Install necessary packages
apt: pkg={{ item }} update_cache=yes cache_valid_time=86400
become: yes
with_items:
- ifupdown
- qemu
- openvswitch-switch
- net-tools
- bridge-utils
- util-linux
- iproute2
- vlan
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- libvirt-clients

- name:
apt:
pkg:
- python
- libvirt-bin
- python-libvirt
- python-pip
become: yes
when: host_distribution_version.stdout == "18.04"

- name:
apt:
pkg:
- python3-libvirt
- python3-pip
- libvirt-daemon-system
- qemu-system-x86
become: yes
when: host_distribution_version.stdout == "20.04"
when: package_installation|bool

- name: Get default pip_executable
set_fact:
Expand All @@ -103,6 +112,7 @@
when: pip_executable is not defined and host_distribution_version.stdout == "20.04"

- include_tasks: docker.yml
when: package_installation|bool

- name: Ensure {{ ansible_user }} in docker,sudo group
user:
Expand Down
4 changes: 4 additions & 0 deletions ansible/testbed_renumber_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
fail: msg="Define ptf_imagename variable with -e ptf_imagename=something"
when: ptf_imagename is not defined

- name: Disable package installation
set_fact:
package_installation: false

- name: Load topo variables
include_vars: "vars/topo_{{ topo }}.yml"

Expand Down
6 changes: 6 additions & 0 deletions tests/acl/null_route/test_null_route_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
]


@pytest.fixture(scope="module", autouse=True)
def skip_on_dualtor_testbed(tbinfo):
if 'dualtor' in tbinfo['topo']['name']:
pytest.skip("Skip running on dualtor testbed")


@pytest.fixture(scope="module")
def create_acl_table(rand_selected_dut, tbinfo):
"""
Expand Down
7 changes: 7 additions & 0 deletions tests/bgp/test_bgpmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
logger = logging.getLogger(__name__)


@pytest.fixture(scope="module", autouse=True)
def skip_test_bgpmon_on_backend(tbinfo):
"""Skip test_bgpmon over storage backend topologies."""
if "backend" in tbinfo["topo"]["name"]:
pytest.skip("Skipping test_bgpmon. Unsupported topology %s." % tbinfo["topo"]["name"])


def get_default_route_ports(host, tbinfo):
mg_facts = host.get_extended_minigraph_facts(tbinfo)
route_info = json.loads(host.shell("show ip route {} json".format(ZERO_ADDR))['stdout'])
Expand Down
3 changes: 2 additions & 1 deletion tests/common/plugins/sanity_check/recover.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def neighbor_vm_restore(duthost, nbrhosts, tbinfo):
vm_neighbors = mg_facts['minigraph_neighbors']
if vm_neighbors:
lag_facts = duthost.lag_facts(host = duthost.hostname)['ansible_facts']['lag_facts']

for lag_name in lag_facts['names']:
nbr_intf = lag_facts['lags'][lag_name]['po_config']['ports'].keys()[0]
peer_device = vm_neighbors[nbr_intf]['name']
Expand All @@ -121,5 +120,7 @@ def neighbor_vm_restore(duthost, nbrhosts, tbinfo):
for intf in intf_list:
nbr_host.no_shutdown(intf)
asn = nbrhosts[peer_device]['conf']['bgp']['asn']
# start BGPd
nbr_host.start_bgpd()
# restore BGP session
nbr_host.no_shutdown_bgp(asn)
24 changes: 0 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

from tests.common.connections.console_host import ConsoleHost

WAIT_FOR_COUNTERS_TIMEOUT = 190
WAIT_FOR_COUNTERS_INTERVAL = 10

logger = logging.getLogger(__name__)
cache = FactsCache()
Expand Down Expand Up @@ -1145,25 +1143,3 @@ def duts_minigraph_facts(duthosts, tbinfo):
}
"""
return duthosts.get_extended_minigraph_facts(tbinfo)

@pytest.fixture(scope='function')
def wait_for_counters(duthosts, rand_one_dut_hostname):
duthost = duthosts[rand_one_dut_hostname]
logger.info('Wait until all counters are enabled on the DUT')
counters = ['PORT_STAT', 'PORT_BUFFER_DROP', 'QUEUE_STAT', 'PG_WATERMARK_STAT', 'RIF_STAT']
current_attempt = 0
while current_attempt < WAIT_FOR_COUNTERS_TIMEOUT / WAIT_FOR_COUNTERS_INTERVAL:
output = duthost.shell("counterpoll show | sed '1,2d'", module_ignore_errors=True)
assert output.has_key('rc') and output['rc'] == 0, "Failed to get counters status"
counters_lines = output['stdout'].splitlines()
enabled_counters = 0
for line in counters_lines:
if any(counter in line for counter in counters) and 'enable' in line:
enabled_counters += 1
continue
if enabled_counters == len(counters):
return
else:
current_attempt += 1
time.sleep(WAIT_FOR_COUNTERS_INTERVAL)
assert False, "Not all counters are enabled after {} seconds".format(WAIT_FOR_COUNTERS_TIMEOUT)
12 changes: 12 additions & 0 deletions tests/platform_tests/test_auto_negotiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from tests.common.helpers.dut_ports import decode_dut_port_name
from tests.common.utilities import wait_until
from tests.platform_tests.link_flap.link_flap_utils import build_test_candidates
from tests.common.utilities import skip_version

pytestmark = [
pytest.mark.topology('any'),
Expand All @@ -37,6 +38,17 @@
# Key: dut host object, value: a list of candidate ports tuple
cadidate_test_ports = {}

@pytest.fixture(autouse=True, scope="module")
def check_image_version(duthost):
"""Skips this test if the SONiC image installed on DUT is older than 202106
Args:
duthost: Hostname of DUT.
Returns:
None.
"""
skip_version(duthost, ["201811", "201911", "202012"])

@pytest.fixture(scope='module', autouse=True)
def recover_ports(duthosts, enum_dut_portname_module_fixture, fanouthosts):
Expand Down
2 changes: 1 addition & 1 deletion tests/portstat/test_portstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def reset_portstat(duthosts, enum_rand_one_per_hwsku_frontend_hostname):


@pytest.mark.parametrize('command', ['portstat -c', 'portstat --clear'])
def test_portstat_clear(duthosts, enum_rand_one_per_hwsku_frontend_hostname, command, wait_for_counters):
def test_portstat_clear(duthosts, enum_rand_one_per_hwsku_frontend_hostname, command):
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
wait(30, 'Wait for DUT to receive/send some packets')
before_portstat = parse_portstat(duthost.command('portstat')['stdout_lines'])
Expand Down
4 changes: 0 additions & 4 deletions tests/snmp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ def setup_check_snmp_ready(duthosts):
for duthost in duthosts:
assert wait_until(300, 20, duthost.is_service_fully_started, "snmp"), "SNMP service is not running"

@pytest.fixture(scope="function", autouse=True)
def snmp_wait_for_counters(wait_for_counters):
return

def pytest_addoption(parser):
"""
Adds options to pytest that are used by the snmp tests.
Expand Down
4 changes: 2 additions & 2 deletions tests/snmp/test_snmp_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def collect_all_facts(duthost, ports_list, namespace=None):
result[portname].update({'adminstatus': admin})
oper = duthost.shell('{} APPL_DB HGET "PORT_TABLE:{}" "oper_status"'.format(sonic_db_cmd, name), module_ignore_errors=False)['stdout']
result[portname].update({'operstatus': oper})
result[portname].update({'description': config_facts.get('PORT', {})[name]['description']})
result[portname].update({'description': config_facts.get('PORT', {})[name].get('description', '')})
elif name.startswith("PortChannel"):
result.setdefault(name, {})
key_word = "PORTCHANNEL"
Expand All @@ -52,7 +52,7 @@ def collect_all_facts(duthost, ports_list, namespace=None):
result[name].update({'operstatus': oper['stdout']})
result[name].update({'description': config_facts.get(key_word, {})[name].get('description', '')})
else:
key_word = "MGMT_PORT"
key_word = "MGMT_PORT"
result.setdefault(name, {})
result[name].update({'mtu': str(setup[key]['mtu'])})
result[name].update({'type': if_type})
Expand Down
3 changes: 1 addition & 2 deletions tests/telemetry/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ def test_telemetry_enabledbydefault(duthosts, rand_one_dut_hostname):
pytest_assert(str(v) == status_expected, "Telemetry feature is not enabled")


def test_telemetry_ouput(duthosts, rand_one_dut_hostname, ptfhost, setup_streaming_telemetry, localhost, wait_for_counters, skip_if_no_data_port):

def test_telemetry_ouput(duthosts, rand_one_dut_hostname, ptfhost, setup_streaming_telemetry, localhost, skip_if_no_data_port):
"""Run pyclient from ptfdocker and show gnmi server outputself.
"""
duthost = duthosts[rand_one_dut_hostname]
Expand Down

0 comments on commit a9f9453

Please sign in to comment.