Skip to content

Commit

Permalink
[pytest] Convert interface naming mode test to pytest (#1702)
Browse files Browse the repository at this point in the history
* [pytest] Convert interface naming mode test to pytest

* [pytest] Interface naming mode: Change logging level to INFO, remove ansible playbooks
  • Loading branch information
ArunSaravananBalachandran authored Jun 12, 2020
1 parent a77d45a commit e15df26
Show file tree
Hide file tree
Showing 19 changed files with 841 additions and 937 deletions.
85 changes: 3 additions & 82 deletions ansible/roles/test/tasks/iface_naming_mode.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,4 @@
# Tests for interface_naming_mode feature
- include_vars: roles/test/tasks/iface_naming_mode/vars/iface_naming_vars.yml

- name: Gathering minigraph facts about the device
minigraph_facts: host={{inventory_hostname}}

- name: find interface name mapping
port_alias: hwsku="{{hwsku}}"

# Get the default interface names list
- set_fact:
default_interfaces: "{{port_name_map | list}}"

#Get the configured ports which are up from minigraph facts and get its alias name
- set_fact:
up_ports: "{{minigraph_ports | list}}"

- name: Change port alias names in redis db for make it common to all platforms
command: "redis-cli -n 4 HSET 'PORT|{{item.1}}' alias TestAlias{{item.0}}"
with_indexed_items: "{{ default_interfaces }}"

- name: rewrite port alias list, port name map dict, port alias map dict
set_fact:
port_alias: []
port_name_map: {}
port_alias_map: {}

- name: create list of new port alias names
set_fact:
port_alias: "{{ port_alias | default([]) | union( [ 'TestAlias%s' | format(item.0) ] ) }}"
with_indexed_items: "{{ default_interfaces }}"

- name: create dict of new port name map
set_fact:
port_name_map: "{{ port_name_map | default({}) | combine( { item.0 : item.1 } ) }}"
port_alias_map: "{{ port_alias_map | default({}) | combine( { item.1 : item.0 } ) }}"
with_together:
- "{{ default_interfaces }}"
- "{{ port_alias }}"

- name: create list of port speed values
set_fact:
port_speed_values: "{{ port_speed.values() | list }}"

- name: rewrite port speed dict
set_fact:
port_speed: {}

- name: create dict of new port speed
set_fact:
port_speed: "{{ port_speed | default({}) | combine( { item.1 : item.0 } ) }}"
with_together:
- "{{ port_speed_values }}"
- "{{ port_alias }}"

# Reassign up port alias list
- set_fact:
upport_alias_list: "{{ port_alias }}"

#Sample Test interface name and its alias
- set_fact:
interface: "{{minigraph_ports | sort | first}}"
- set_fact:
interface_alias: "{{port_name_map[interface]}}"

#############################################################
######################## START OF TESTS #####################
#############################################################

# All tests run for user guest in alias mode as well as in default mode

- name: Test Interface naming mode feature in alias mode
include_tasks: "roles/test/tasks/iface_naming_mode/iface_naming_mode_tests.yml"
- name: run test
include_tasks: roles/test/tasks/pytest_runner.yml
vars:
mode: alias

- name: Test Interface naming mode feature in default mode
include_tasks: "roles/test/tasks/iface_naming_mode/iface_naming_mode_tests.yml"
vars:
mode: default

- name: Reboot dut after all test passed to return default port alias name
include_tasks: "common_tasks/reboot_sonic.yml"
test_node: iface_namingmode/test_iface_namingmode.py
10 changes: 0 additions & 10 deletions ansible/roles/test/tasks/iface_naming_mode/add_user.yml

This file was deleted.

25 changes: 0 additions & 25 deletions ansible/roles/test/tasks/iface_naming_mode/check_userifmode.yml

This file was deleted.

This file was deleted.

113 changes: 0 additions & 113 deletions ansible/roles/test/tasks/iface_naming_mode/interface_config.yml

This file was deleted.

19 changes: 0 additions & 19 deletions ansible/roles/test/tasks/iface_naming_mode/show_acl.yml

This file was deleted.

28 changes: 0 additions & 28 deletions ansible/roles/test/tasks/iface_naming_mode/show_arp.yml

This file was deleted.

Loading

0 comments on commit e15df26

Please sign in to comment.