diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 94ff94e8b80..d0b204bf185 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -61,14 +61,34 @@ connection: local - block: + - name: get platform info + shell: show platform summary | grep 'Platform' | awk '{print $2}' + register: platform_name + become: yes + + - name: platform_name + debug: var=platform_name.stdout + + - name: get image info + shell: ls /host/ | grep 'image' + register: image_name + become: yes + + - name: image_name + debug: var=image_name.stdout + - name: saved original minigraph file (if original file may don't exist, then ignore errors) - shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.orig + shell: mv /usr/share/sonic/device/{{ platform_name.stdout }}/minigraph.xml /usr/share/sonic/device/{{ platform_name.stdout }}/minigraph.xml.orig become: true ignore_errors: true - name: create minigraph file for SONiC device template: src=templates/topo/{{ template_name }}.j2 - dest=/etc/sonic/minigraph.xml + dest=/usr/share/sonic/device/{{ platform_name.stdout }}/minigraph.xml + become: true + + - name: set the status of dut as first time configuration + shell: touch /host/{{ image_name.stdout }}/platform/firsttime become: true - name: disable automatic minigraph update if we are deploying new minigraph into SONiC diff --git a/ansible/roles/test/files/ptftests/IP_decap_test.py b/ansible/roles/test/files/ptftests/IP_decap_test.py index 274526e88ff..dd91dfe4e7e 100644 --- a/ansible/roles/test/files/ptftests/IP_decap_test.py +++ b/ansible/roles/test/files/ptftests/IP_decap_test.py @@ -142,6 +142,9 @@ def runTest(self): """ # IPv4 Test for ip_range in self.fib.ipv4_ranges(): + # add this to skip default route 0.0.0.0/0 + if str(ip_range.get_first_ip()) == "0.0.0.0": + continue # Get the expected list of ports that would receive the packets exp_port_list = self.fib[ip_range.get_first_ip()].get_next_hop_list() # Choose random one source port from all ports excluding the expected ones diff --git a/ansible/roles/test/files/ptftests/fib.py b/ansible/roles/test/files/ptftests/fib.py index d4dc005f9e5..bd9624dc6f8 100644 --- a/ansible/roles/test/files/ptftests/fib.py +++ b/ansible/roles/test/files/ptftests/fib.py @@ -44,12 +44,15 @@ def get_next_hop_list(self): # Initialize FIB with FIB file def __init__(self, file_path): self._ipv4_lpm_dict = LpmDict() - for ip in EXCLUDE_IPV4_PREFIXES: - self._ipv4_lpm_dict[ip] = self.NextHop() + # no need to add EXCLUDE_IPV4_PREFIXES into test + # for ip in EXCLUDE_IPV4_PREFIXES: + # os.system("echo NH: " + str(ip) + " >> ~/ip_decap.txt") + # self._ipv4_lpm_dict[ip] = self.NextHop() self._ipv6_lpm_dict = LpmDict(ipv4=False) - for ip in EXCLUDE_IPV6_PREFIXES: - self._ipv6_lpm_dict[ip] = self.NextHop() + # no need to add EXCLUDE_IPV^_PREFIXES into test + # for ip in EXCLUDE_IPV6_PREFIXES: + # self._ipv6_lpm_dict[ip] = self.NextHop() with open(file_path, 'r') as f: for line in f.readlines(): diff --git a/ansible/roles/test/files/ptftests/lpm.py b/ansible/roles/test/files/ptftests/lpm.py index f30fdcef4e9..56feac56ac9 100644 --- a/ansible/roles/test/files/ptftests/lpm.py +++ b/ansible/roles/test/files/ptftests/lpm.py @@ -1,5 +1,4 @@ import random - from ipaddress import ip_address, ip_network from SubnetTree import SubnetTree @@ -101,5 +100,7 @@ def ranges(self): interval = self.IpInterval(sorted_boundaries[index], ip_address(u'255.255.255.255')) else: interval = self.IpInterval(sorted_boundaries[index], ip_address(u'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')) - ranges.append(interval) + # add this to prevent incorrect intervals generated by IpInterval + if index % 2 == 1: + ranges.append(interval) return ranges