Skip to content

Commit

Permalink
Merge remote-tracking branch 'Azure/master'
Browse files Browse the repository at this point in the history
Conflicts:
	tests/conftest.py
	tests/show_techsupport/test_techsupport.py
  • Loading branch information
noaOrMlnx committed Apr 6, 2020
2 parents 3f22a4c + 051c9f2 commit 4c24e68
Show file tree
Hide file tree
Showing 827 changed files with 98,906 additions and 3,179 deletions.
12 changes: 9 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ Fixes # (issue)

### Type of change

- [] Bug fix
- [] Testbed and Framework(new/improvement)
- [] Test case(new/improvement)
<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] Test case(new/improvement)

### Approach
#### How did you do it?
Expand Down
11 changes: 11 additions & 0 deletions ansible/README.test.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ ansible-playbook test_sonic.yml -i {INVENTORY} --limit {DUT_NAME} -e testcase_na
```
- Requires switch connected to a PTF testbed

##### ECMP test
```
ansible-playbook test_sonic_by_tag.yml -i inventory --limit {DUT_NAME}, --become --tags ecmp --extra-vars "testbed_type={TESTBED_TYPE} vm_hosts=[DESTINATION_VMS] vm_source={SOURCE_VM} [ipv6=True]"
```
- Requires switch connected to a VM testbed (t1); default IPv4

##### ECN WRED test
```
ansible-playbook test_sonic.yml -i {INVENTORY} --limit {DUT_NAME} -e testcase_name=ecn_wred -e testbed_name={TESTBED_NAME}
Expand Down Expand Up @@ -210,6 +216,11 @@ ansible-playbook test_sonic.yml -i {INVENTORY} --limit {DUT_NAME} -e testcase_na
```
- Requires switch connected to a VM set or PTF testbed

### SNMP memory test
```
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME}, --become --tags snmp_memory -e "tolerance=0.05" -e "min_memory_size=512000"
```

##### NTP test
```
ansible-playbook test_sonic.yml -i {INVENTORY} --limit {DUT_NAME} -e testcase_name=ntp -e testbed_name={TESTBED_NAME}
Expand Down
51 changes: 26 additions & 25 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# config file for ansible -- http://ansible.com/
# ==============================================

# nearly all parameters can be overridden in ansible-playbook
# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
Expand All @@ -23,6 +23,7 @@ sudo_user = root
transport = smart
#remote_port = 22
module_lang = C
max_diff_size = 512000

# plays will gather facts by default, which contain information about
# the remote system.
Expand Down Expand Up @@ -73,22 +74,22 @@ log_path = $HOME/ansible.log
# list any Jinja2 extensions to enable here:
#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n

# if set, always use this private key file for authentication, same as
# if set, always use this private key file for authentication, same as
# if passing --private-key to ansible or ansible-playbook
#private_key_file = /path/to/file

# format of string {{ ansible_managed }} available within Jinja2
# format of string {{ ansible_managed }} available within Jinja2
# templates indicates to users editing templates files will be replaced.
# replacing {file}, {host} and {uid} and strftime codes with proper values.
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}

# by default, ansible-playbook will display "Skipping [host]" if it determines a task
# should not be run on a host. Set this to "False" if you don't want to see these "Skipping"
# messages. NOTE: the task header will still be shown regardless of whether or not the
# should not be run on a host. Set this to "False" if you don't want to see these "Skipping"
# messages. NOTE: the task header will still be shown regardless of whether or not the
# task is skipped.
#display_skipped_hosts = True

# by default (as of 1.3), Ansible will raise errors when attempting to dereference
# by default (as of 1.3), Ansible will raise errors when attempting to dereference
# Jinja2 variables that are not set in templates or action lines. Uncomment this line
# to revert the behavior to pre-1.3.
#error_on_undefined_vars = False
Expand All @@ -107,7 +108,7 @@ deprecation_warnings = False
# (as of 1.8), Ansible can optionally warn when usage of the shell and
# command module appear to be simplified by using a default Ansible module
# instead. These warnings can be silenced by adjusting the following
# setting or adding warn=yes or warn=no to the end of the command line
# setting or adding warn=yes or warn=no to the end of the command line
# parameter string. This will for example suggest using the git module
# instead of shelling out to the git command.
# command_warnings = False
Expand All @@ -123,30 +124,30 @@ filter_plugins = plugins/filter
callback_whitelist = profile_tasks

# by default callbacks are not loaded for /bin/ansible, enable this if you
# want, for example, a notification or logging callback to also apply to
# want, for example, a notification or logging callback to also apply to
# /bin/ansible runs
#bin_ansible_callbacks = False


# don't like cows? that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
#nocows = 1

# don't like colors either?
# set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1
#nocolor = 1

# the CA certificate path used for validating SSL certs. This path
# the CA certificate path used for validating SSL certs. This path
# should exist on the controlling node, not the target nodes
# common locations:
# RHEL/CentOS: /etc/pki/tls/certs/ca-bundle.crt
# Fedora : /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
# Ubuntu : /usr/share/ca-certificates/cacert.org/cacert.org.crt
#ca_file_path =
#ca_file_path =

# the http user-agent string to use when fetching urls. Some web server
# operators block the default urllib user agent as it is frequently used
# by malicious attacks/scripts, so we set it to something unique to
# by malicious attacks/scripts, so we set it to something unique to
# avoid issues.
#http_user_agent = ansible-agent

Expand All @@ -155,7 +156,7 @@ callback_whitelist = profile_tasks
# wanting to use, for example, IP information from one group of servers
# without having to talk to them in the same playbook run to get their
# current IP information.
fact_caching = jsonfile
fact_caching = memory
fact_caching_connection = ~/.ansible/cache
fact_caching_timeout = 86400

Expand Down Expand Up @@ -184,33 +185,33 @@ become_method='sudo'
[ssh_connection]

# ssh arguments to use
# Leaving off ControlPersist will result in poor performance, so use
# Leaving off ControlPersist will result in poor performance, so use
# paramiko on older platforms rather than removing it
ssh_args = -o ControlMaster=auto -o ControlPersist=120s -o UserKnownHostsFile=/dev/null
ssh_args = -o ControlMaster=auto -o ControlPersist=120s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no


# The path to use for the ControlPath sockets. This defaults to
# "%(directory)s/ansible-ssh-%%h-%%p-%%r", however on some systems with
# very long hostnames or very long path names (caused by long user names or
# very long hostnames or very long path names (caused by long user names or
# deeply nested home directories) this can exceed the character limit on
# file socket names (108 characters for most platforms). In that case, you
# file socket names (108 characters for most platforms). In that case, you
# may wish to shorten the string below.
#
# Example:
#
# Example:
# control_path = %(directory)s/%%h-%%r
#control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r

# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# first disable 'requiretty' in /etc/sudoers
#
# By default, this option is disabled to preserve compatibility with
# sudoers configurations that have requiretty (the default on many distros).
#
#
pipelining = True

# if True, make ansible use scp if the connection type is ssh
# if True, make ansible use scp if the connection type is ssh
# (default is sftp)
#scp_if_ssh = True

Expand All @@ -221,7 +222,7 @@ accelerate_connect_timeout = 5.0

# The daemon timeout is measured in minutes. This time is measured
# from the last activity to the accelerate daemon.
accelerate_daemon_timeout = 30
accelerate_daemon_timeout = 30

# If set to yes, accelerate_multi_key will allow multiple
# private keys to be uploaded to it, though each user must
Expand Down
42 changes: 36 additions & 6 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# -e topo=t0 - the name of topology to generate minigraph file
# -e testbed_name=vms1-1 - the testbed name specified in testbed.csv file
# (if you give 'testbed_name' option, will use info from testbed and ignore topo and vm_base options)
# -e vm_file=veos - the virtual machine file name
# -e deploy=True - if deploy the newly generated minigraph to the targent DUT, default is false if not defined
# -e save=True - if save the newly generated minigraph to the targent DUT as starup-config, default is false if not defined
#
Expand Down Expand Up @@ -60,12 +61,17 @@
- topo_facts: topo={{ topo }}
delegate_to: localhost

- name: set default vm file path
set_fact:
vm_file: veos
when: vm_file is not defined

- set_fact:
VM_topo: "{% if 'ptf' in topo %}False{% else %}True{% endif %}"
remote_dut: "{{ ansible_ssh_host }}"

- name: gather testbed VM informations
testbed_vm_info: base_vm={{ testbed_facts['vm_base'] }} topo={{ testbed_facts['topo'] }}
testbed_vm_info: base_vm={{ testbed_facts['vm_base'] }} topo={{ testbed_facts['topo'] }} vm_file={{ vm_file }}
delegate_to: localhost
when: "VM_topo | bool"

Expand All @@ -80,7 +86,15 @@
set_fact:
vlan_intfs: "{{ vlan_intfs|default([])}} + ['{{ port_alias[item] }}' ]"
with_items: "{{ host_if_indexes }}"
when: ("'host_interfaces' in vm_topo_config") and ("'tor' in vm_topo_config['dut_type'] | lower")
when: "('host_interfaces' in vm_topo_config) and ('tor' in vm_topo_config['dut_type'] | lower)"

- name: find all vlan configurations for T0 topology
vlan_config:
vm_topo_config: "{{ vm_topo_config }}"
port_alias: "{{ port_alias }}"
vlan_config: "{{ vlan_config | default(None) }}"
delegate_to: localhost
when: "('host_interfaces' in vm_topo_config) and ('tor' in vm_topo_config['dut_type'] | lower)"

- name: find all interface indexes mapping connecting to VM
set_fact:
Expand Down Expand Up @@ -114,11 +128,21 @@
dest=/etc/sonic/minigraph.xml
become: true

- name: Copy corresponding configlet files if apply_configlet=true
- name: Test if configlet script exist
stat:
path: vars/configlet/{{ topo }}/apply_clet.sh
register: stat_result
delegate_to: localhost

- name: debug print stat_result
debug:
msg: Stat result is {{ stat_result }}

- name: Copy corresponding configlet files if exist
copy: src=vars/configlet/{{ topo }}/
dest=/etc/sonic/
become: true
when: apply_configlet is defined and apply_configlet|bool == true
when: stat_result.stat.exists is defined and stat_result.stat.exists

- name: Replace snmp community string
lineinfile:
Expand All @@ -142,6 +166,12 @@
state: restarted
when: updategraph_conf.changed

- name: docker status
shell: docker ps
register: docker_status

- debug: msg={{ docker_status.stdout_lines }}

- name: execute cli "config load_minigraph -y" to apply new minigraph
become: true
shell: config load_minigraph -y
Expand All @@ -152,8 +182,8 @@

- name: execute configlet application script, which applies configlets in strict order.
become: true
shell: bash -c "/etc/sonic/apply_clet.sh"
when: apply_configlet is defined and apply_configlet|bool == true
shell: bash "/etc/sonic/apply_clet.sh"
when: stat_result.stat.exists is defined and stat_result.stat.exists

- name: execute cli "config save -y" to save current minigraph as startup-config
become: true
Expand Down
2 changes: 1 addition & 1 deletion ansible/doc/README.new.testbed.Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Like the veos_groups section, this section contains information about the server
Confirm the following:
- root_path - server's root path to building the VMs
- cd_image_filename - you should be able to locate "Aboot-veos-serial-8.0.0.iso"
- hdd_image_file: you should also be able to locate "vEOS-lab-4.15.10M.vmdk"
- hdd_image_file: you should also be able to locate "vEOS-lab-4.20.15M.vmdk"

Define:
- vm_console_base - if you are running multiple sets of sonic-mgmt VMs, define a conflict-free vm_console_base
Expand Down
4 changes: 2 additions & 2 deletions ansible/doc/README.testbed.Cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

## Add/Remove topo
```
# uniq-name,testbed-name,topo,ptf_image_name,ptf_ip,server,vm_base,dut,owner
# conf-name,testbed-name,topo,ptf_image_name,ptf_ip,server,vm_base,dut,owner
vms1-1-t1,vms1-1,t1,docker-ptf-sai-mlnx,10.0.10.5/23,server_1,VM0100,str-msn2700-11,t1 tests
vms1-1-t1-lag,vms1-1,t1-lag,docker-ptf-sai-mlnx,10.0.10.5/23,server_1,VM0100,str-msn2700-11,t1-lag tests
Expand All @@ -32,7 +32,7 @@ Caveat: Have to remember what was the initial topology. Should be fixed in futur

# Renumber topo
```
# uniq-name,testbed-name,topo,ptf_image_name,ptf_ip,server,vm_base,dut,owner
# conf-name,testbed-name,topo,ptf_image_name,ptf_ip,server,vm_base,dut,owner
vms2-2-b,vms2-2,t1,docker-ptf-sai-brcm,10.0.10.7/23,server_1,VM0100,str-d6000-05,brcm test
vms2-2-m,vms2-2,t1,docker-ptf-sai-mlnx,10.0.10.7/23,server_1,VM0100,str-msn2700-5,mlnx test
Expand Down
4 changes: 2 additions & 2 deletions ansible/doc/README.testbed.Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ vms-t1-lag,vms1-1,t1-lag,docker-ptf-sai-mlnx,10.255.0.178/24,server_1,VM0100,str

### ```testbed.csv``` consistency rules
```
# uniq-name,testbed-name,topo,ptf_image_name,ptf_ip,server,vm_base,dut,owner
# conf-name,testbed-name,topo,ptf_image_name,ptf_ip,server,vm_base,dut,owner
vms2-2-b,vms2-2,t1,docker-ptf-sai-brcm,10.0.10.7/23,server_1,VM0100,str-d6000-05,brcm test
vms2-2-m,vms2-2,t1,docker-ptf-sai-mlnx,10.0.10.7/23,server_1,VM0100,str-msn2700-5,mlnx test
```
Must be strictly checked in code reviews
- uniq-name must be unique
- conf-name must be unique
- All testbed records with the same testbed-name must have the same:
- ptf_ip
- server
Expand Down
Loading

0 comments on commit 4c24e68

Please sign in to comment.