Skip to content

Commit b0c75a4

Browse files
eddieruan-alibabaveronica-arista
authored andcommitted
Add test cases and infra changes for phoenixwing ptf test (sonic-net#13785)
What is the motivation for this PR? This changes are used for phoenix wing initiative, to provide 1. 5-node testbed for running existing test cases in sonic-mgmt 2. 7-node testbed for running srv6 test cases. The difference for this testbed is to use Cisco's ngdp as dataplane simulation. This type of vsonic would allow us to simulate both control plane and data plane in virtual testing environment. How did you do it? Based on Test doc sonic-net#13645 How did you verify/test it? Both sanity test cases are running daily for phoenix wing. Any platform specific information? cisco-8101-p4-32x100-vs Supported testbed topology if it's a new test case? 5-node and 7-node testbed listed in testplan sonic-net#13645. Documentation sonic-net#13645
1 parent e28350f commit b0c75a4

32 files changed

Lines changed: 4154 additions & 58 deletions

ansible/config_sonic_basedon_testbed.yml

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,14 @@
422422
- debug: msg="use_ptf_tacacs_server {{ use_ptf_tacacs_server }}"
423423

424424
- block:
425+
- name: Load variables from topology file for topo_{{ topo }}.yml
426+
include_vars: "vars/topo_{{ topo }}.yml"
427+
425428
- name: saved original minigraph file in SONiC DUT(ignore errors when file does not exist)
426429
shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.orig
427430
become: true
428431
ignore_errors: true
432+
when: init_cfg_profile is not defined
429433

430434
- name: Update TACACS server address to PTF IP
431435
set_fact:
@@ -438,6 +442,29 @@
438442
template: src=templates/minigraph_template.j2
439443
dest=/etc/sonic/minigraph.xml
440444
become: true
445+
when: init_cfg_profile is not defined
446+
447+
- block:
448+
- name: Load variables from vars/init_cfg_profiles.yml
449+
include_vars: "vars/init_cfg_profiles.yml"
450+
- name: set cfg_profile to {{ init_cfg_profile }}
451+
set_fact:
452+
cfg_profile: "{{ init_cfg_profile }}"
453+
- name: Set actual configuration value based on cfg_profile key
454+
set_fact:
455+
actual_config: "{{ lookup('vars', cfg_profile) }}"
456+
- name: Debug actual configuration value
457+
debug:
458+
msg: "The actual configuration value is: {{ actual_config }}"
459+
- name: Copy over config_db.json from file system for {{ cfg_profile }}
460+
copy :
461+
src: "{{ actual_config }}"
462+
dest: /tmp/config_db.json
463+
when: cfg_profile is defined
464+
- name: Overwrite config_db.json
465+
shell: cat /tmp/config_db.json > /etc/sonic/config_db.json
466+
become: yes
467+
when: init_cfg_profile is defined
441468

442469
- name: Test if configlet script exist
443470
stat:
@@ -509,6 +536,7 @@
509536
regexp: '^snmp_rocommunity:'
510537
line: 'snmp_rocommunity: {{ snmp_rocommunity }}'
511538
become: true
539+
when: init_cfg_profile is not defined
512540

513541
- name: docker status
514542
shell: docker ps
@@ -555,18 +583,33 @@
555583
port_index_map: "{{ port_index_map | default({}) }}"
556584
become: true
557585

558-
- name: execute cli "config load_minigraph --override_config -y" to apply new minigraph
559-
become: true
560-
shell: config load_minigraph --override_config -y
561-
register: load_minigraph_result
562-
failed_when:
563-
- load_minigraph_result.rc != 0
564-
- "'no such option: --override_config' not in load_minigraph_result.stderr"
586+
- name: Use minigraph case
587+
block:
588+
- name: execute cli "config load_minigraph --override_config -y" to apply new minigraph
589+
become: true
590+
shell: config load_minigraph --override_config -y
591+
register: load_minigraph_result
592+
failed_when:
593+
- load_minigraph_result.rc != 0
594+
- "'no such option: --override_config' not in load_minigraph_result.stderr"
565595

566-
- name: execute cli "config load_minigraph -y" to apply new minigraph
567-
become: true
568-
shell: config load_minigraph -y
569-
when: "'no such option: --override_config' in load_minigraph_result.stderr"
596+
- name: execute cli "config load_minigraph -y" to apply new minigraph
597+
become: true
598+
shell: config load_minigraph -y
599+
when: "'no such option: --override_config' in load_minigraph_result.stderr"
600+
601+
- name: remove DSCP_TO_TC_MAP for {{ hwsku }}. Some platform doesn't support this configuration
602+
become: true
603+
shell: redis-cli -n 4 del "DSCP_TO_TC_MAP|AZURE"
604+
when:
605+
- hwsku is defined
606+
- hwsku == 'cisco-8101-p4-32x100-vs'
607+
when: init_cfg_profile is not defined
608+
609+
- name: SONiC config reload to pick up config_db.json
610+
command: config reload -y
611+
become: yes
612+
when: init_cfg_profile is defined
570613

571614
- name: Wait for switch to become reachable again
572615
become: false

ansible/group_vars/all/creds.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ sonic_login: "admin"
1717
sonic_default_passwords:
1818
- "YourPaSsWoRd"
1919
- "password"
20+
- "admin"
2021
sonic_password: "password"
2122

2223
k8s_master_login: "ubuntu"

ansible/group_vars/all/labinfo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"Arista-7170-64C": "Arista",
1010
"Arista-VM": "Arista",
1111
"Nexus-3064-NX": "Nexus",
12+
"cisco-8101-p4-32x100-vs" : "Cisco",
1213
"Force10-S6100": "Force10",
1314
"Force10-S6000": "Force10"
1415
},
@@ -23,6 +24,11 @@
2324
"passwd": ["password", "123456"],
2425
"enable": ["", null]
2526
},
27+
"Cisco": {
28+
"user": "admin",
29+
"passwd": ["admin"],
30+
"enable": ["admin"]
31+
},
2632
"Force10": {
2733
"user": "admin",
2834
"passwd": ["password"],

ansible/group_vars/sonic/variables

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ barefoot_hwskus: [ "montara", "mavericks", "Arista-7170-64C", "newport", "Arista
3333
marvell_hwskus: [ "et6448m" ]
3434
innovium_tl7_hwskus: ["Wistron_sw_to3200k_32x100" , "Wistron_sw_to3200k"]
3535

36-
cisco_hwskus: ["Cisco-8102-C64", "Cisco-8111-O32", "Cisco-8111-O64", "Cisco-8122-O64", "Cisco-8800-LC-48H-C48"]
36+
cisco_hwskus: ["Cisco-8102-C64", "Cisco-8111-O32", "Cisco-8111-O64", "Cisco-8122-O64", "Cisco-8800-LC-48H-C48", "cisco-8101-p4-32x100-vs"]
3737
cisco-8000_gb_hwskus: ["Cisco-8102-C64", "Cisco-88-LC0-36FH-M-O36", "Cisco-8101-O8C48", "Cisco-8101-O32", "Cisco-88-LC0-36FH-O36"]
3838
cisco-8000_gr_hwskus: ["Cisco-8111-O32", "Cisco-8111-O64"]
3939
cisco-8000_gr2_hwskus: ["Cisco-8122-O64"]

ansible/lab

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ all:
1515
sonic_multi_asic_2:
1616
sonic_msft_sup:
1717
sonic_msft_lc_100G:
18+
sonic_cisco_vs:
1819
fanout:
1920
hosts:
2021
str-7260-10:
@@ -223,3 +224,13 @@ sonic_msft_lc_100G:
223224
loopback4096_ip: [3.3.3.7/32,3.3.3.8/32]
224225
loopback4096_ipv6: [2603:10e2:400::7/128,2603:10e2:400::8/128]
225226
ansible_host: 2.2.2.5
227+
228+
sonic_cisco_vs:
229+
vars:
230+
hwsku: cisco-8101-p4-32x100-vs
231+
iface_speed: 100000
232+
hosts:
233+
vlab-c-01:
234+
hwsku: cisco-8101-p4-32x100-vs
235+
ansible_host: 10.250.0.125
236+
ansible_hostv6: fec0::ffff:afa:13

ansible/library/topo_facts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ def parse_topo_defintion(self, topo_definition, po_map, dut_num, neigh_type='VMs
171171
vmconfig[vm]['peer_ipv6'][dut_index] = ipv6_addr.upper()
172172
vmconfig[vm]['ipv6mask'][dut_index] = ipv6_mask
173173
vmconfig[vm]['ip_intf'][dut_index] = intf
174+
175+
# Configuration is provided via init_cfg_profile, no need to go through the topo file
176+
if "init_cfg_profile" in topo_definition['configuration'][vm]:
177+
continue
178+
174179
# bgp
175180
vmconfig[vm]['bgp_asn'] = topo_definition['configuration'][vm]['bgp']['asn']
176181
dut_asn = topo_definition['configuration_properties']['common']['dut_asn']

ansible/module_utils/port_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ def get_port_alias_to_name_map(hwsku, asic_name=None):
429429
elif hwsku == "Arista-7060DX5-32":
430430
for i in range(1, 33):
431431
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 8)
432+
elif hwsku == "cisco-8101-p4-32x100-vs":
433+
# this device simulates 32 ports, with 4 as the step for port naming.
434+
for i in range(0, 32, 4):
435+
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
432436
else:
433437
if "Arista-7800" in hwsku:
434438
assert False, "Please add port_alias_to_name_map for new modular SKU %s." % hwsku

ansible/roles/sonic/handlers/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This is also the case for handlers using listen.
33

44
- name: SONiC update config db
5-
command: config reload -y
5+
command: config reload -y -f
66
become: yes
77
listen: "Update config db"
88

ansible/roles/sonic/tasks/vsonic.yml

Lines changed: 85 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,96 @@
99

1010
- name: Set SONiC backplane port name
1111
set_fact: bp_ifname="Ethernet{{ fp_num.stdout|int + 1 }}"
12+
when: '"hwsku" not in configuration[hostname]'
13+
14+
- name: Set SONiC backplane port name for cisco-8101-p4-32x100-vs
15+
set_fact: bp_ifname="Ethernet{{ fp_num.stdout|int *4 }}"
16+
when: '"hwsku" in configuration[hostname] and configuration[hostname]["hwsku"]=="cisco-8101-p4-32x100-vs"'
1217

1318
- set_fact:
1419
mgmt_ip: "{{ ansible_host }}/{{ mgmt_prefixlen }}"
1520
mgmt_gw: "{{ vm_mgmt_gw | default(mgmt_gw) }}"
1621

17-
- name: create mgmt config
18-
template: src="configdb-mgmt.j2"
19-
dest=config-mgmt.json
20-
when: hostname in configuration
21-
22-
- name: create device metadata config
23-
shell: >
24-
sonic-cfggen -H -k Force10-S6000 --preset empty
25-
| jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"'
26-
| jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"'
27-
| jq '.DEVICE_METADATA.localhost.deployment_id="1"'
28-
> config-metadata.json
29-
when: hostname in configuration
30-
31-
- name: create interface config
32-
shell: >
33-
sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini -k SONiC-VM --print-data
34-
| jq '.PORT[].admin_status |= "up"'
35-
> config-port.json
36-
when: hostname in configuration
37-
38-
- name: create topo config
39-
template: src="configdb.j2"
40-
dest=config-topo.json
41-
when: hostname in configuration
42-
43-
- name: create config db json
44-
shell: |
45-
set -e
46-
sonic-cfggen -j config-mgmt.json -j config-metadata.json -j config-port.json -j config-topo.json --print-data > /etc/sonic/config_db.json
47-
rm -f config-mgmt.json config-metadata.json config-port.json config-topo.json
48-
become: yes
49-
when: hostname in configuration
50-
notify:
51-
- Update config db
52-
- wait for SONiC update config db to finish
22+
- name: create config via mininet config
23+
block:
24+
- name: create mgmt config
25+
template: src="configdb-mgmt.j2"
26+
dest=config-mgmt.json
27+
28+
- name: create device metadata config for {{ configuration[hostname]['hwsku'] }}
29+
shell: >
30+
sonic-cfggen -H -k {{ configuration[hostname]['hwsku'] }} --preset empty
31+
| jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"'
32+
| jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"'
33+
| jq '.DEVICE_METADATA.localhost.deployment_id="1"'
34+
> config-metadata.json
35+
when: '"hwsku" in configuration[hostname]'
36+
37+
- name: create device metadata config
38+
shell: >
39+
sonic-cfggen -H -k Force10-S6000 --preset empty
40+
| jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"'
41+
| jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"'
42+
| jq '.DEVICE_METADATA.localhost.deployment_id="1"'
43+
> config-metadata.json
44+
when: '"hwsku" not in configuration[hostname]'
45+
46+
- name: create interface config for {{ configuration[hostname]['hwsku'] }}
47+
shell: >
48+
sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/{{ configuration[hostname]['hwsku'] }}/port_config.ini -k {{ configuration[hostname]['hwsku'] }} --print-data
49+
| jq '.PORT[].admin_status |= "up"'
50+
> config-port.json
51+
when: '"hwsku" in configuration[hostname]'
52+
53+
- name: create interface config
54+
shell: >
55+
sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini -k SONiC-VM --print-data
56+
| jq '.PORT[].admin_status |= "up"'
57+
> config-port.json
58+
when: '"hwsku" not in configuration[hostname]'
59+
60+
- name: create topo config
61+
template: src="configdb.j2"
62+
dest=config-topo.json
63+
64+
- name: create config db json
65+
shell: |
66+
set -e
67+
sonic-cfggen -j config-mgmt.json -j config-metadata.json -j config-port.json -j config-topo.json --print-data > /etc/sonic/config_db.json
68+
rm -f config-mgmt.json config-metadata.json config-port.json config-topo.json
69+
become: yes
70+
notify:
71+
- Update config db
72+
- wait for SONiC update config db to finish
73+
when: hostname in configuration and "init_cfg_profile" not in configuration[hostname]
74+
75+
- name: Update config via provided json
76+
block:
77+
- name: Get playbook directory
78+
debug:
79+
msg: "The playbook dir {{ playbook_dir }}"
80+
- name: Load variables from vars/init_cfg_profiles.yml
81+
include_vars: "vars/init_cfg_profiles.yml"
82+
- name: set cfg_profile to {{ configuration[hostname].init_cfg_profile }}
83+
set_fact:
84+
cfg_profile: "{{ configuration[hostname].init_cfg_profile }}"
85+
- name: Set actual configuration value based on cfg_profile key
86+
set_fact:
87+
actual_config: "{{ lookup('vars', cfg_profile) }}"
88+
- name: Debug actual configuration value
89+
debug:
90+
msg: "The actual configuration value is: {{ actual_config }}"
91+
- name: Copy over config_db.json from file system
92+
copy :
93+
src: "{{ playbook_dir }}/{{ actual_config }}"
94+
dest: /tmp/config_db.json
95+
- name: Overwrite config_db.json
96+
shell: cat /tmp/config_db.json > /etc/sonic/config_db.json
97+
become: yes
98+
notify:
99+
- Update config db
100+
- wait for SONiC update config db to finish
101+
when: hostname in configuration and configuration[hostname]['init_cfg_profile'] is defined
53102

54103
- name: Load PTF image
55104
block:

ansible/roles/vm_set/library/sonic_kickstart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def login(self, user, passwords):
5656
break
5757

5858
for password in passwords:
59-
index = self.pair(user, [r'assword:', r'\$'])
59+
index = self.pair(user, [r'assword:', r'\$', r'\#'])
6060
if index == 0:
61-
index = self.pair(password, [r'login:', r'\$'])
61+
index = self.pair(password, [r'login:', r'\$', r'\#'])
6262
if index == 1:
6363
break
6464

@@ -73,7 +73,7 @@ def configure(self, seq):
7373
else:
7474
(action, wait_for, timeout) = cmd
7575
self.pair(action, wait_for, timeout)
76-
self.pair('exit', [r'\$'])
76+
self.pair('exit', [r'\$', r'\#'])
7777

7878
return
7979

0 commit comments

Comments
 (0)