diff --git a/ansible/roles/test/tasks/acl/acltb_test_rules-del.json b/ansible/roles/test/tasks/acl/acltb_test_rules-del.json new file mode 100644 index 00000000000..71ba44005e9 --- /dev/null +++ b/ansible/roles/test/tasks/acl/acltb_test_rules-del.json @@ -0,0 +1,9 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + } + } + } +} + diff --git a/ansible/roles/test/tasks/acl/acltb_test_rules.json b/ansible/roles/test/tasks/acl/acltb_test_rules.json new file mode 100644 index 00000000000..3766d494bf7 --- /dev/null +++ b/ansible/roles/test/tasks/acl/acltb_test_rules.json @@ -0,0 +1,194 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + "dataacl": { + "acl-entries": { + "acl-entry": { + "1": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 1 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.2/32" + } + } + }, + "2": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 2 + }, + "ip": { + "config": { + "source-ip-address": "192.168.0.16/32" + } + } + }, + "3": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 3 + }, + "transport": { + "config": { + "source-port": "4661" + } + } + }, + "4": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 4 + }, + "ip": { + "config": { + "protocol": 126 + } + } + }, + "5": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 5 + }, + "transport": { + "config": { + "tcp-flags": ["TCP_ACK", "TCP_SYN"] + } + } + }, + "6": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 6 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.3/32" + } + } + }, + "7": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 7 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.3/32" + } + } + }, + "8": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 8 + }, + "transport": { + "config": { + "destination-port": "4661" + } + } + }, + "9": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 9 + }, + "l2": { + "config": { + "ethertype": "4660" + } + } + }, + "10": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 10 + }, + "transport": { + "config": { + "source-port": "4656..4671" + } + } + }, + "11": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 11 + }, + "transport": { + "config": { + "destination-port": "4640..4687" + } + } + }, + "12": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 12 + }, + "l2": { + "config": { + "ethertype": "ETHERTYPE_IPV4" + } + } + } + } + } + } + } + } + } +} diff --git a/ansible/roles/test/tasks/acl/acltb_test_rules_allow_all.json b/ansible/roles/test/tasks/acl/acltb_test_rules_allow_all.json new file mode 100644 index 00000000000..072653ba557 --- /dev/null +++ b/ansible/roles/test/tasks/acl/acltb_test_rules_allow_all.json @@ -0,0 +1,29 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + "dataacl": { + "acl-entries": { + "acl-entry": { + "1": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 1 + }, + "l2": { + "config": { + "ethertype": "2048" + } + } + } + } + } + } + } + } + } +} diff --git a/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json b/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json new file mode 100644 index 00000000000..9f83e024473 --- /dev/null +++ b/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json @@ -0,0 +1,74 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + "dataacl": { + "acl-entries": { + "acl-entry": { + "1": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 1 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.2/32" + } + } + }, + "2": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 2 + }, + "ip": { + "config": { + "source-ip-address": "192.168.0.16/32" + } + } + }, + "3": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 3 + }, + "transport": { + "config": { + "source-port": "4661" + } + } + }, + "13": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 13 + }, + "l2": { + "config": { + "ethertype": "ETHERTYPE_IPV4" + } + } + } + } + } + } + } + } + } +} diff --git a/ansible/roles/test/tasks/acl/acltb_test_rules_part_2.json b/ansible/roles/test/tasks/acl/acltb_test_rules_part_2.json new file mode 100644 index 00000000000..3766d494bf7 --- /dev/null +++ b/ansible/roles/test/tasks/acl/acltb_test_rules_part_2.json @@ -0,0 +1,194 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + "dataacl": { + "acl-entries": { + "acl-entry": { + "1": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 1 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.2/32" + } + } + }, + "2": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 2 + }, + "ip": { + "config": { + "source-ip-address": "192.168.0.16/32" + } + } + }, + "3": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 3 + }, + "transport": { + "config": { + "source-port": "4661" + } + } + }, + "4": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 4 + }, + "ip": { + "config": { + "protocol": 126 + } + } + }, + "5": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 5 + }, + "transport": { + "config": { + "tcp-flags": ["TCP_ACK", "TCP_SYN"] + } + } + }, + "6": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 6 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.3/32" + } + } + }, + "7": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 7 + }, + "ip": { + "config": { + "source-ip-address": "10.0.0.3/32" + } + } + }, + "8": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 8 + }, + "transport": { + "config": { + "destination-port": "4661" + } + } + }, + "9": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 9 + }, + "l2": { + "config": { + "ethertype": "4660" + } + } + }, + "10": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 10 + }, + "transport": { + "config": { + "source-port": "4656..4671" + } + } + }, + "11": { + "actions": { + "config": { + "forwarding-action": "DROP" + } + }, + "config": { + "sequence-id": 11 + }, + "transport": { + "config": { + "destination-port": "4640..4687" + } + } + }, + "12": { + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + }, + "config": { + "sequence-id": 12 + }, + "l2": { + "config": { + "ethertype": "ETHERTYPE_IPV4" + } + } + } + } + } + } + } + } + } +} diff --git a/ansible/roles/test/tasks/acltb.yml b/ansible/roles/test/tasks/acltb.yml index bd10a48bb89..501f05bc932 100644 --- a/ansible/roles/test/tasks/acltb.yml +++ b/ansible/roles/test/tasks/acltb.yml @@ -1,20 +1,87 @@ -#----------------------------------------- -# Apply ACL configuration -#----------------------------------------- -- name: Acl test setup on testbed - include: acltb_configure.yml - tags: acltb_configure - -#----------------------------------------- -# Run ACL test -#----------------------------------------- -- name: Acl test run on testbed - include: acltb_test.yml - tags: acltb_test - -#----------------------------------------- -# Clean up ACL configuration -#----------------------------------------- -- name: Clean up ACL test configuration on the testbed - include: acltb_cleanup.yml - tags: acltb_cleanup +# Set facts for the loganalizer +- set_fact: + out_dir: /tmp/ + testname: acl + +# Gather minigraph facts +- name: Gathering minigraph facts about the device + minigraph_facts: host={{ inventory_hostname }} + become: no + connection: local + +- name: Read port reverse alias mapping + set_fact: + alias_reverse_map: "{{ minigraph_map_ngs_to_sonic }}" + podset_number: 200 + +# Copy ACL config to the switch +- name: Copy ACL config file to the DUT + copy: src="roles/test/tasks/acl/{{ item }}" dest="/tmp/" + with_items: + - "acltb_test_rules.json" + - "acltb_test_rules_allow_all.json" + - "acltb_test_rules-del.json" + - "acltb_test_rules_part_1.json" + - "acltb_test_rules_part_2.json" + +- block: + - name: Apply allow all rule + vars: + command_to_run: "acl-loader update full /tmp/acltb_test_rules_allow_all.json" + errors_expected: false + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Apply test rules + vars: + command_to_run: "acl-loader update full /tmp/acltb_test_rules.json" + errors_expected: false + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Run the test + include: ptf_runner.yml + vars: + ptf_test_name: ACL Test + ptf_test_dir: test + ptf_test_path: acltb_test.AclTest + ptf_platform: remote + ptf_test_params: + - verbose=True + - router_mac=\"{{ ansible_Ethernet0['macaddress'] }}\" + - switch_info=\"/tmp/acltb_switch_info.txt\" + + - name: Clean up ACL rules. + vars: + command_to_run: "acl-loader update full /tmp/acltb_test_rules-del.json" + errors_expected: false + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Apply part 1 of ACL rules. + vars: + command_to_run: "acl-loader update incremental /tmp/acltb_test_rules_part_1.json" + errors_expected: false + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Apply part 2 of ACL rules. + vars: + command_to_run: "acl-loader update incremental /tmp/acltb_test_rules_part_2.json" + errors_expected: false + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Run the test + include: ptf_runner.yml + vars: + ptf_test_name: ACL Test + ptf_test_dir: test + ptf_test_path: acltb_test.AclTest + ptf_platform: remote + ptf_test_params: + - verbose=True + - router_mac=\"{{ ansible_Ethernet0['macaddress'] }}\" + - switch_info=\"/tmp/acltb_switch_info.txt\" + + always: + - name: Clean up ACL rules. + vars: + command_to_run: "acl-loader update full /tmp/acltb_test_rules-del.json" + errors_expected: false + include: roles/test/tasks/run_command_with_log_analyzer.yml diff --git a/ansible/roles/test/tasks/acltb_cleanup.yml b/ansible/roles/test/tasks/acltb_cleanup.yml deleted file mode 100644 index 290229e4c70..00000000000 --- a/ansible/roles/test/tasks/acltb_cleanup.yml +++ /dev/null @@ -1,68 +0,0 @@ -# Set facts for ACL configuration -- set_fact: - acltb_configs: - - "{{ 'acltb_test_rules.json' }}" - - "{{ 'acltb_test_table.json' }}" - -# Set facts for the loganalizer -- set_fact: - testname: acl - run_dir: /tmp - out_dir: /tmp/ansible-loganalyzer-results - test_match_file: acltb_match_messages.txt - test_ignore_file: acltb_ignore_messages.txt - test_expect_file: acltb_expect_messages.txt - match_file: loganalyzer_common_match.txt - ignore_file: loganalyzer_common_ignore.txt - tests_location: "{{ 'roles/test/tasks' }}" - -# Separate set_fact is required to be able to use 'testname' fact. -- set_fact: - testname_unique: "{{ testname }}.{{ ansible_date_time.date}}.{{ ansible_date_time.hour}}-{{ ansible_date_time.minute}}-{{ ansible_date_time.second}}" - -# Separate set_fact is required to be able to use 'testname_unique' fact. -- set_fact: - test_out_dir: "{{ out_dir }}/{{testname_unique}}" - match_file_list: "{{ run_dir }}/{{test_match_file}},{{ run_dir }}/{{match_file}}" - ignore_file_list: "{{ run_dir }}/{{test_ignore_file}},{{ run_dir }}/{{ignore_file}}" - result_file: result.loganalysis.{{testname_unique}}.log - summary_file: summary.loganalysis.{{testname_unique}}.log - -# Gather minigraph facts -- name: Gathering minigraph facts about the device - minigraph_facts: host={{ inventory_hostname }} - become: no - connection: local - -- name: Read port reverse alias mapping - set_fact: - alias_reverse_map: "{{ minigraph_map_ngs_to_sonic }}" - -# Generate json files with ACL configuration for tests -- template: src=acltb_test_table.j2 dest=/tmp/acltb_test_table.json - connection: local - -- template: src=acltb_test_rules.j2 dest=/tmp/acltb_test_rules.json - connection: local - -# Copy ACL config to the swss container via the switch -- name: Copy ACL config file to the DUT - copy: src="/tmp/{{ item }}" dest="/tmp/{{ item }}" - with_items: - - "{{ acltb_configs }}" - -- name: Copy ACL config file to the swss container - command: docker cp "/tmp/{{ item }}" swss:/etc/swss/config.d/"{{ item }}" - with_items: - - "{{ acltb_configs }}" - -- name: Create ACL configuration to delete rules/tables - command: docker exec -t swss bash -c "sed -i 's/SET/DEL/g' /etc/swss/config.d/{{ item }}" - with_items: - - "{{ acltb_configs }}" - -- block: - - name: Apply ACL delete configuration - command: docker exec -t swss bash -c "swssconfig /etc/swss/config.d/{{ item }}" - with_items: - - "{{ acltb_configs }}" diff --git a/ansible/roles/test/tasks/acltb_configure.yml b/ansible/roles/test/tasks/acltb_configure.yml deleted file mode 100644 index 44915a0e789..00000000000 --- a/ansible/roles/test/tasks/acltb_configure.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Set facts for ACL configuration -- set_fact: - acltb_configs: - - "{{ 'acltb_test_table.json' }}" - - "{{ 'acltb_test_rules.json' }}" - -# Set facts for the loganalizer -- set_fact: - testname: acl - run_dir: /tmp - out_dir: /tmp/ansible-loganalyzer-results - test_match_file: acltb_match_messages.txt - test_ignore_file: acltb_ignore_messages.txt - test_expect_file: acltb_expect_messages.txt - match_file: loganalyzer_common_match.txt - ignore_file: loganalyzer_common_ignore.txt - tests_location: "{{ 'roles/test/tasks' }}" - -# Separate set_fact is required to be able to use 'testname' fact. -- set_fact: - testname_unique: "{{ testname }}.{{ ansible_date_time.date}}.{{ ansible_date_time.hour}}-{{ ansible_date_time.minute}}-{{ ansible_date_time.second}}" - -# Separate set_fact is required to be able to use 'testname_unique' fact. -- set_fact: - test_out_dir: "{{ out_dir }}/{{testname_unique}}" - match_file_list: "{{ run_dir }}/{{test_match_file}},{{ run_dir }}/{{match_file}}" - ignore_file_list: "{{ run_dir }}/{{test_ignore_file}},{{ run_dir }}/{{ignore_file}}" - result_file: result.loganalysis.{{testname_unique}}.log - summary_file: summary.loganalysis.{{testname_unique}}.log - -# Gather minigraph facts -- name: Gathering minigraph facts about the device - minigraph_facts: host={{ inventory_hostname }} - become: no - connection: local - -- name: Read port reverse alias mapping - set_fact: - alias_reverse_map: "{{ minigraph_map_ngs_to_sonic }}" - podset_number: 200 - -# Generate json files with ACL configuration for tests -- template: src=acltb_test_table.j2 dest=/tmp/acltb_test_table.json - connection: local - -- template: src=acltb_test_rules.j2 dest=/tmp/acltb_test_rules.json - connection: local - -# Copy ACL config to the swss container via the switch -- name: Copy ACL config file to the DUT - copy: src="/tmp/{{ item }}" dest="/tmp/{{ item }}" - with_items: - - "{{ acltb_configs }}" - -- name: Copy ACL config file to the swss container - command: docker cp "/tmp/{{ item }}" swss:/etc/swss/config.d/"{{ item }}" - with_items: - - "{{ acltb_configs }}" - -- block: - - name: Apply ACL configuration - command: docker exec -t swss bash -c "swssconfig /etc/swss/config.d/{{ item }}" - with_items: - - "{{ acltb_configs }}" diff --git a/ansible/roles/test/tasks/acltb_test.yml b/ansible/roles/test/tasks/acltb_test.yml deleted file mode 100644 index 30a6f74864e..00000000000 --- a/ansible/roles/test/tasks/acltb_test.yml +++ /dev/null @@ -1,76 +0,0 @@ -#----------------------------------------- -# Run ACL test and Perform log analysis. -#----------------------------------------- - -# Pre-check testbed_type value -- fail: msg="testbed_type is not defined." - when: testbed_type is not defined - -- fail: msg="testbed_type {{testbed_type}} is invalid." - when: testbed_type not in ['t1-lag', 't1'] - -- include_vars: "vars/topo_{{testbed_type}}.yml" - -# Gather minigraph facts -- name: Gathering minigraph facts about the device - minigraph_facts: host={{ inventory_hostname }} - become: no - connection: local - -- name: Read port reverse alias mapping - set_fact: - alias_reverse_map: "{{ minigraph_map_ngs_to_sonic }}" - -- name: Expand properties into props - set_fact: props="{{configuration_properties['spine']}}" - when: testbed_type in ['t1', 't1-lag'] - -# Generate file with switch information -- template: src=acltb.j2 dest=/tmp/acltb_switch_info.txt - connection: local - -- name: Copy switch info file to the PTF host - copy: src=/tmp/acltb_switch_info.txt dest=/tmp/acltb_switch_info.txt - delegate_to: "{{ ptf_host }}" - -- set_fact: - testname: acl - run_dir: /tmp - out_dir: /tmp/ansible-loganalyzer-results - test_match_file: acltb_match_messages.txt - test_ignore_file: acltb_ignore_messages.txt - test_expect_file: acltb_expect_messages.txt - match_file: loganalyzer_common_match.txt - ignore_file: loganalyzer_common_ignore.txt - tests_location: "{{ 'roles/test/tasks' }}" - -# Separate set_fact is required to be able to use 'testname' fact. -- set_fact: - testname_unique: "{{ testname }}.{{ ansible_date_time.date}}.{{ ansible_date_time.hour}}-{{ ansible_date_time.minute}}-{{ ansible_date_time.second}}" - -# Separate set_fact is required to be able to use 'testname_unique' fact. -- set_fact: - test_out_dir: "{{ out_dir }}/{{testname_unique}}" - match_file_list: "{{ run_dir }}/{{test_match_file}},{{ run_dir }}/{{match_file}}" - ignore_file_list: "{{ run_dir }}/{{test_ignore_file}},{{ run_dir }}/{{ignore_file}}" - result_file: result.loganalysis.{{testname_unique}}.log - summary_file: summary.loganalysis.{{testname_unique}}.log - -- name: Copy the ACL test to PTF container - become: true - copy: src=roles/test/files/acstests/acltb_test.py dest=/root/test/ - delegate_to: "{{ ptf_host }}" - -# Run the ACL PTF test -- block: - - name: Run the test - include: ptf_runner.yml - vars: - ptf_test_name: ACL Test - ptf_test_dir: test - ptf_test_path: acltb_test.AclTest - ptf_platform: remote - ptf_test_params: - - verbose=True - - router_mac=\"{{ ansible_Ethernet0['macaddress'] }}\" - - switch_info=\"/tmp/acltb_switch_info.txt\" diff --git a/ansible/roles/test/tasks/run_command_with_log_analyzer.yml b/ansible/roles/test/tasks/run_command_with_log_analyzer.yml new file mode 100644 index 00000000000..7a2876ba755 --- /dev/null +++ b/ansible/roles/test/tasks/run_command_with_log_analyzer.yml @@ -0,0 +1,50 @@ +#----------------------------------------- +# Test json-configuration: +# 1) Upload json-config through swssconfig. +# 2) Check log through the loganalyzer. +# 3) Run cleanup if needed. +#----------------------------------------- + +- include_vars: "vars/run_config_test_vars.yml" + +- block: + - name: Initialize loganalizer. Put start marker to log file. + include: roles/test/files/tools/loganalyzer/loganalyzer_init.yml + + - name: Run command {{ command_to_run }} + command: "{{ command_to_run }}" + + - name: Use loganalyzer to check for the error messages {{ testname }} / {{ command_to_run }}. + include: roles/test/files/tools/loganalyzer/loganalyzer_analyze.yml + + - name: Read loganalyzer summary file. + shell: cat "{{ test_out_dir }}/{{ summary_file }}" + register: log_summary + + - name: Print loganalyzer summary file. + debug: + var: log_summary.stdout_lines + + - name: Get the total number of expected messages. + shell: grep "TOTAL EXPECTED" "{{ test_out_dir }}/{{ summary_file }}" | sed -n "s/TOTAL EXPECTED MATCHES:[[:space:]]*//p" + register: expects_found + when: errors_expected == true + + - name: Check that expected error messages are found (negative tests only). + fail: msg="Expected error messages are not found while running {{ testname }} / {{ command_to_run }}" + when: errors_expected == true and expects_found.stdout == "0" + + - name: Get the total number of error messages. + shell: grep "TOTAL MATCHES" "{{ test_out_dir }}/{{ summary_file }}" | sed -n "s/TOTAL MATCHES:[[:space:]]*//p" + register: errors_found + + - name: Check the number of error messages (positive tests only). + fail: msg="{{ errors_found.stdout }} errors found while running {{ testname }} / {{ command_to_run }}." + when: errors_expected == false and errors_found.stdout != "0" + + - name: Copy test data to host. + fetch: src={{ test_out_dir }}/{{ item }} dest=failed-test-data/{{ testname_unique }}/{{ item }} + with_items: + - "{{ summary_file }}" + - "{{ result_file }}" + when: (errors_expected == true and expects_found.stdout == "0") or (errors_expected == false and errors_found.stdout != "0") diff --git a/ansible/roles/test/tasks/run_config_test.yml b/ansible/roles/test/tasks/run_config_test.yml index d3754bf2992..2c4834b4416 100644 --- a/ansible/roles/test/tasks/run_config_test.yml +++ b/ansible/roles/test/tasks/run_config_test.yml @@ -5,50 +5,18 @@ # 3) Run cleanup if needed. #----------------------------------------- -- include_vars: "vars/run_config_test_vars.yml" - block: - - name: Initialize loganalizer. Put start marker to log file. - include: roles/test/files/tools/loganalyzer/loganalyzer_init.yml - name: Load JSON config {{ config_file }} command: docker exec -i swss swssconfig {{ docker_testdir }}/{{ config_file }} - - name: Use loganalyzer to check for the error messages {{ testname }} / {{ config_file }}. - include: roles/test/files/tools/loganalyzer/loganalyzer_analyze.yml - - - name: Read loganalyzer summary file. - shell: cat "{{ test_out_dir }}/{{ summary_file }}" - register: log_summary - - - name: Print loganalyzer summary file. - debug: - var: log_summary.stdout_lines - - - name: Get the total number of expected messages. - shell: grep "TOTAL EXPECTED" "{{ test_out_dir }}/{{ summary_file }}" | sed -n "s/TOTAL EXPECTED MATCHES:[[:space:]]*//p" - register: expects_found - when: errors_expected == true - - - name: Check that expected error messages are found (negative tests only). - fail: msg="Expected error messages are not found while running {{ testname }} / {{ config_file }}" - when: errors_expected == true and expects_found.stdout == "0" - - - name: Get the total number of error messages. - shell: grep "TOTAL MATCHES" "{{ test_out_dir }}/{{ summary_file }}" | sed -n "s/TOTAL MATCHES:[[:space:]]*//p" - register: errors_found - - - name: Check the number of error messages (positive tests only). - fail: msg="{{ errors_found.stdout }} errors found while running {{ testname }} / {{ config_file }}." - when: errors_expected == false and errors_found.stdout != "0" - - - name: Copy test data to host. - fetch: src={{ test_out_dir }}/{{ item }} dest=failed-test-data/{{ testname_unique }}/{{ item }} - with_items: - - "{{ summary_file }}" - - "{{ result_file }}" - when: (errors_expected == true and expects_found.stdout == "0") or (errors_expected == false and errors_found.stdout != "0") + - name: Run command. + vars: + command_to_run: "docker exec -i swss swssconfig {{ docker_testdir }}/{{ config_file }}" + include: roles/test/tasks/run_command_with_log_analyzer.yml + always: - name: Do configuration cleanup after {{ testname }} / {{ config_file }} include: roles/test/tasks/run_config_cleanup.yml when: run_cleanup == true diff --git a/ansible/roles/test/templates/acltb_test_rules.j2 b/ansible/roles/test/templates/acltb_test_rules.j2 deleted file mode 100644 index cb842e3adba..00000000000 --- a/ansible/roles/test/templates/acltb_test_rules.j2 +++ /dev/null @@ -1,109 +0,0 @@ -{% set break = 0 %} -{% set acltb_dst_ip_block = "" %} -{% set acltb_dst_ip_priority = "" %} -{% for podset in range(0, podset_number) if break == 0 %} -{% for tor in range(0, 15) if break == 0 %} -{% if loop.index == 2 %} -[ - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule01_SRC_IP_test": { - "priority" : "50", - "src_ip" : "10.0.0.2", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule02_DST_IP_test": { - "priority" : "50", - "dst_ip" : "192.168.{{ podset }}.{{ tor * 16 }}", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule03_SRC_port_test": { - "priority" : "50", - "l4_src_port" : "0x1235", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule04_DST_port_test": { - "priority" : "50", - "l4_dst_port" : "0x1235", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule05_Ethertype_test": { - "priority" : "50", - "ether_type" : "0x1234", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule06_IP_protocol_test": { - "priority" : "50", - "ip_protocol" : "0x7E", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule07_tcp_flags_test": { - "priority" : "50", - "tcp_flags" : "0x12/0x12", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule08_IP_type_test": { - "priority" : "50", - "ip_type" : "IPv6ANY", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule091_SRC_port_range_test": { - "priority" : "50", - "l4_src_port_range" : "4656-4671", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:Rule0A1_DST_port_range_test": { - "priority" : "50", - "l4_dst_port_range" : "4640-4687", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:RuleB1_Priority_test_drop": { - "priority" : "50", - "src_ip" : "10.0.0.3", - "packet_action" : "drop" - }, - "OP": "SET" - }, - { - "ACL_RULE_TABLE:ACL_Testbed_Test_Table:RuleB2_Priority_test_permit": { - "priority" : "51", - "src_ip" : "10.0.0.3", - "packet_action" : "forward" - }, - "OP": "SET" - } -] -{% set break = 1 %} -{% endif %} -{% endfor %} -{% set break = 1 %} -{% endfor %} diff --git a/ansible/roles/test/templates/acltb_test_table.j2 b/ansible/roles/test/templates/acltb_test_table.j2 deleted file mode 100644 index ad171fccbc8..00000000000 --- a/ansible/roles/test/templates/acltb_test_table.j2 +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "ACL_TABLE:ACL_Testbed_Test_Table": { - "policy_desc" : "This_table_contains_rules_needed_for_the_testbed_regression_tests", - "type" : "L3", - "ports" : "{% for ifname, v in minigraph_neighbors.iteritems() %}{{"%s" % alias_reverse_map[ifname]}},{% endfor %}" - }, - "OP": "SET" - } -]