Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ansible/roles/test/tasks/acl.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#-----------------------------------------
# Run all the acl tests.
#-----------------------------------------
Expand All @@ -18,21 +17,27 @@
- block:
- name: Test file input.
include: "{{ tests_location }}/acl_input_test/acl_input_test.yml"
when: tests_location is defined

- name: Test port bind configuration.
include: "{{ tests_location }}/acl_port_bind_test/acl_port_bind_test.yml"
when: tests_location is defined

- name: Test orchagent logic.
include: "{{ tests_location }}/acl_orchagent_logic_test/acl_orchagent_logic_test.yml"
when: tests_location is defined

- name: Test traffic.
include: "{{ tests_location }}/acl_traffic_test/acl_traffic_test.yml"
when: tests_location is defined

- name: Test counters traffic.
include: "{{ tests_location }}/acl_counter_traffic_test/acl_counter_traffic_test.yml"
when: tests_location is defined

- name: Test L4 ports.
- name: Test L4 port range.
include: "{{ tests_location }}/acl_port_range_test/acl_port_range_test.yml"
when: tests_location is defined

always:
- name: General cleanup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
- include_vars: "{{ vars_files_location }}/acl_counter_traffic_test_vars.yml"

- name: Copy JSON configs onto switch.
copy: src="{{ tests_location }}/{{ testname }}/{{ item }}" dest="{{ run_dir }}/{{ item }}"
copy: src={{ tests_location }}/{{ testname }}/{{ item }} dest={{ run_dir }}/{{ item }}
with_items:
- "{{ config_files }}"

- name: Copy JSON configs from switch into docker filesystem.
shell: docker cp "{{ run_dir }}/{{ item }}" orchagent:{{ docker_testdir }}/{{ item }}
shell: docker cp {{ run_dir }}/{{ item }} {{ orchagent }}:{{ docker_testdir }}/{{ item }}
with_items:
- "{{ config_files }}"

Expand All @@ -31,10 +31,10 @@
delegate_to: "{{ ptf_host }}"

- name: Create an ACL L3 table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}

- name: Create a rule within L3 table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_rule }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_rule }}

- name: Check if {{ rule_name}} data is written into DBs.
vars:
Expand Down Expand Up @@ -87,7 +87,7 @@

# Delete rule and check if config is deleted as well
- name: Delete L3-rule.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_rule_delete }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_rule_delete }}

- name: Check if {{ rule_name}} data is removed from DBs.
vars:
Expand All @@ -101,10 +101,10 @@
#--------------------

- name: Create a mirror session.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_mirror_session }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_mirror_session }}

- name: Create a mirror table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_mirror }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_mirror }}

- name: Add neighbor.
shell: ip neigh add {{ switch_if1_ip }} lladdr 0e:9c:37:42:43:67 dev Ethernet0
Expand All @@ -113,7 +113,7 @@
shell: ip route add {{ dst_mirror_subnet }} via {{ switch_if1_ip }}

- name: Create a rule within mirror table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_rule_mirror }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_rule_mirror }}

- name: Check that {{ mirror_rule_name }} data is written into DBs.
vars:
Expand Down Expand Up @@ -145,7 +145,7 @@
when: (counters_value_result.stdout|int - counters_value_initial.stdout|int) != packets_sent|int

- name: Delete mirror-rule.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_rule_mirror_delete }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_rule_mirror_delete }}

- name: Check that {{ mirror_rule_name }} data is removed from DBs.
vars:
Expand All @@ -154,7 +154,6 @@
expect_data: false
include: "{{ acl_check_db }}"


# CLEANUP.
- name: Run config cleanup after {{ testname}}
include: "{{ run_config_cleanup }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
- include_vars: "{{ vars_files_location }}/acl_input_test_vars.yml"

- name: Copy JSON configs onto switch
copy: src="{{ tests_location }}/{{ testname }}/{{ item }}" dest="{{ run_dir }}/{{ item }}"
copy: src={{ tests_location }}/{{ testname }}/{{ item }} dest={{ run_dir }}/{{ item }}
with_items:
- "{{ acl_config_valid }}"
- "{{ acl_config_invalid }}"

- name: Copy JSON configs from switch into docker filesystem
command: docker cp "{{ run_dir }}/{{ item }}" orchagent:"{{ docker_testdir }}/{{ item }}"
command: docker cp {{ run_dir }}/{{ item }} {{ orchagent }}:{{ docker_testdir }}/{{ item }}
with_items:
- "{{ acl_config_valid }}"
- "{{ acl_config_invalid }}"

- block:
- name: Load valid JSON config.
command: docker exec -i orchagent swssconfig "{{ docker_testdir }}/{{ acl_config_valid }}"
command: docker exec -i {{ orchagent }} swssconfig "{{ docker_testdir }}/{{ acl_config_valid }}"
register: valid_config_upload
failed_when: valid_config_upload.rc != 0

- name: Load invalid JSON config and check that errors returned.
command: docker exec -i orchagent swssconfig "{{ docker_testdir }}/{{ acl_config_invalid }}"
command: docker exec -i {{ orchagent }} swssconfig "{{ docker_testdir }}/{{ acl_config_invalid }}"
register: invalid_config_upload
failed_when: invalid_config_upload.rc == 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
- include_vars: "{{ vars_files_location }}/acl_orchagent_logic_test_vars.yml"

- name: Copy JSON configs onto switch.
copy: src="{{ tests_location }}/{{ testname }}/{{ item }}" dest="{{ run_dir }}/{{ item }}"
copy: src={{ tests_location }}/{{ testname }}/{{ item }} dest={{ run_dir }}/{{ item }}
with_items:
- "{{ config_files }}"

- name: Copy JSON configs from switch into docker filesystem.
command: docker cp "{{ run_dir }}/{{ item }}" orchagent:{{ docker_testdir }}/{{ item }}
command: docker cp {{ run_dir }}/{{ item }} {{ orchagent }}:{{ docker_testdir }}/{{ item }}
with_items:
- "{{ config_files }}"

Expand Down Expand Up @@ -67,17 +67,18 @@

# Check return code from swssconfig
- name: Table test - invalid operation applied for table ("OP" field).
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_operation_invalid_1 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_operation_invalid_1 }}
register: invalid_oper_1
failed_when: invalid_oper_1.rc == 0

- name: Table test - invalid operation applied for table ("OP" field).
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_operation_invalid_2 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_operation_invalid_2 }}
register: invalid_oper_2
failed_when: invalid_oper_2.rc == 0

- name: Run config cleanup after.
include: "{{ run_config_cleanup }}"

#-----------------------------------------
# test duplicate table creation
#-----------------------------------------
Expand Down Expand Up @@ -630,4 +631,3 @@
file: path="{{ run_dir }}/{{ item }}" state=absent
with_items:
- "{{ config_files }}"

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
- include_vars: "{{ vars_files_location }}/acl_port_bind_test_vars.yml"

- name: Copy JSON configs onto switch.
copy: src="{{ tests_location }}/{{ testname }}/{{ item }}" dest="{{ run_dir }}/{{ item }}"
copy: src={{ tests_location }}/{{ testname }}/{{ item }} dest={{ run_dir }}/{{ item }}
with_items:
- "{{ config_files }}"

- name: Copy JSON configs from switch into docker filesystem.
command: docker cp "{{ run_dir }}/{{ item }}" orchagent:{{ docker_testdir }}/{{ item }}
command: docker cp {{ run_dir }}/{{ item }} {{ orchagent }}:{{ docker_testdir }}/{{ item }}
with_items:
- "{{ config_files }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
- include_vars: "{{ vars_files_location }}/acl_port_range_test_vars.yml"

- name: Copy JSON configs onto switch.
copy: src="{{ tests_location }}/{{ testname }}/{{ item }}" dest="{{ run_dir }}/{{ item }}"
copy: src={{ tests_location }}/{{ testname }}/{{ item }} dest={{ run_dir }}/{{ item }}
with_items:
- "{{ config_files }}"

- name: Copy JSON configs from switch into docker filesystem.
command: docker cp "{{ run_dir }}/{{ item }}" orchagent:{{ docker_testdir }}/{{ item }}
command: docker cp {{ run_dir }}/{{ item }} {{ orchagent }}:{{ docker_testdir }}/{{ item }}
with_items:
- "{{ config_files }}"

Expand All @@ -42,7 +42,7 @@

# L3 table testing.
- name: Create an L3 table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}

- name: Rule test - valid port range on L3 table.
vars:
Expand Down Expand Up @@ -75,10 +75,10 @@

# Mirror table and rule testing.
- name: Create a mirror session.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_mirror_session }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_mirror_session }}

- name: Create a mirror table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_mirror }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_mirror }}

- name: Add neighbor.
shell: ip neigh add {{ switch_if_ip }} lladdr 0e:9c:37:42:43:67 dev {{ switch_if }}
Expand Down Expand Up @@ -111,7 +111,7 @@
# Invalid configuration testing (valid L3 table + invalid rules).
#--------------------------------
- name: Create an L3 table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}

- name: Rule test - negative numbers used in range.
vars:
Expand Down Expand Up @@ -191,10 +191,10 @@
# Test the configuration deleting.
#--------------------------------
- name: Create an L3 table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}

- name: Create the rule with limited port range permitted (1028 - 4096).
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_l4_limited_port_range }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_l4_limited_port_range }}

- name: Delete rule test - rule with port range.
vars:
Expand All @@ -217,7 +217,7 @@
# Try to delete the same rule, but use another port range in delete-json.
# This should not make any difference, so we dont expect any errors.
- name: Create the rule with limited port range permitted (1028 - 4096).
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_l4_limited_port_range }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_l4_limited_port_range }}

- name: Delete rule test - rule with port range.
vars:
Expand Down Expand Up @@ -265,10 +265,10 @@
delegate_to: "{{ ptf_host }}"

- name: Create an L3 table.
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_table_type_l3 }}

- name: Create the rule with limited port range permitted (1028 - 4096).
shell: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_l4_limited_port_range }}
shell: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_l4_limited_port_range }}

# Sending packets with L4 port permitted (counters value should be increased).
- name: Read initial counters value (before sending packets).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
- include_vars: "{{ vars_files_location }}/acl_traffic_test_vars.yml"

- name: Copy JSON configs onto switch.
copy: src="{{ tests_location }}/{{ testname }}/{{ item }}" dest="{{ run_dir }}/{{ item }}"
copy: src={{ tests_location }}/{{ testname }}/{{ item }} dest={{ run_dir }}/{{ item }}
with_items:
- "{{ config_files }}"

- name: Copy JSON configs from switch into docker filesystem.
command: docker cp "{{ run_dir }}/{{ item }}" orchagent:{{ docker_testdir }}/{{ item }}
command: docker cp {{ run_dir }}/{{ item }} {{ orchagent }}:{{ docker_testdir }}/{{ item }}
with_items:
- "{{ config_files }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
include: "{{ loganalyzer_init }}"

- name: Set ACL rules.
command: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_file }}
command: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_file }}

- debug: msg="=== test json = {{ config_file }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
include: "{{ loganalyzer_init }}"

- name: Set ACL rules.
command: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_file }}
command: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_file }}

- debug: msg="======================= PTF TEST =========================="

Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/acl/run_config_cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

- name: Do configuration cleanup.
shell: systemctl restart orchagent
shell: systemctl restart {{ orchagent }}
register: clean_up

- fail: msg="swssconfig - failed to cleanup the ACL configuration"
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/acl/run_config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
include: "{{ loganalyzer_init }}"

- name: Load JSON config {{ config_file }}
command: docker exec -i orchagent swssconfig {{ docker_testdir }}/{{ config_file }}
command: docker exec -i {{ orchagent }} swssconfig {{ docker_testdir }}/{{ config_file }}

- name: Use loganalyzer to check for the error messages {{ testname }} / {{ config_file }}.
include: "{{ loganalyzer_analyze }}"
Expand Down
2 changes: 2 additions & 0 deletions ansible/vars/acl/acl_vars.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---

orchagent: swss

run_dir: /home/admin/acl_tests
out_dir: /home/admin/acl_tests/results
docker_testdir: /tmp
Expand Down