From 1e075227e0c846e5c3597558101cf56532edc00a Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Mon, 19 Feb 2018 19:47:45 +0200 Subject: [PATCH 1/3] [crm]: Implement test for CRM Signed-off-by: Volodymyr Samotiy --- ansible/README.test.md | 4 + ansible/roles/test/tasks/crm.yml | 45 +++++++++++ ansible/roles/test/tasks/crm/acl.json | 30 ++++++++ .../test/tasks/crm/crm_test_acl_counter.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_acl_entry.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_fdb_entry.yml | 66 ++++++++++++++++ .../test/tasks/crm/crm_test_ipv4_neighbor.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_ipv4_nexthop.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_ipv4_route.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_ipv6_neighbor.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_ipv6_nexthop.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_ipv6_route.yml | 63 +++++++++++++++ .../test/tasks/crm/crm_test_nexthop_group.yml | 62 +++++++++++++++ .../crm/crm_test_nexthop_group_member.yml | 62 +++++++++++++++ .../test/tasks/crm/crm_test_threshold.yml | 76 +++++++++++++++++++ .../roles/test/tasks/crm/expect_crm_th_clear | 1 + .../test/tasks/crm/expect_crm_th_exceeded | 1 + ansible/roles/test/tasks/crm/fdb.json | 9 +++ .../roles/test/tasks/test_sonic_by_tag.yml | 4 + ansible/roles/test/vars/testcases.yml | 4 + 20 files changed, 861 insertions(+) create mode 100644 ansible/roles/test/tasks/crm.yml create mode 100644 ansible/roles/test/tasks/crm/acl.json create mode 100644 ansible/roles/test/tasks/crm/crm_test_acl_counter.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_acl_entry.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml create mode 100644 ansible/roles/test/tasks/crm/crm_test_threshold.yml create mode 100644 ansible/roles/test/tasks/crm/expect_crm_th_clear create mode 100644 ansible/roles/test/tasks/crm/expect_crm_th_exceeded create mode 100644 ansible/roles/test/tasks/crm/fdb.json diff --git a/ansible/README.test.md b/ansible/README.test.md index 017d1d82a36..61b3a69dfa4 100644 --- a/ansible/README.test.md +++ b/ansible/README.test.md @@ -165,3 +165,7 @@ ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} -e "testbed_name ``` - Requires switch connected to a t0 testbed - Requires switch connected to fanout switch and fanout switch need support [QinQ](https://en.wikipedia.org/wiki/IEEE_802.1ad). + +### CRM test +``` +ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags crm diff --git a/ansible/roles/test/tasks/crm.yml b/ansible/roles/test/tasks/crm.yml new file mode 100644 index 00000000000..5009ae14f2b --- /dev/null +++ b/ansible/roles/test/tasks/crm.yml @@ -0,0 +1,45 @@ +- block: + + - name: Set polling interval + command: crm config polling interval 1 + + - name: Make sure CRM counters updated + pause: seconds=300 + + - name: Run test case "CRM IPv4 route resource" + include: roles/test/tasks/crm/crm_test_ipv4_route.yml + + - name: Run test case "CRM IPv6 route resource" + include: roles/test/tasks/crm/crm_test_ipv6_route.yml + + - name: Run test case "CRM IPv4 nexthop resource" + include: roles/test/tasks/crm/crm_test_ipv4_nexthop.yml + + - name: Run test case "CRM IPv6 nexthop resource" + include: roles/test/tasks/crm/crm_test_ipv6_nexthop.yml + + - name: Run test case "CRM IPv4 neighbor resource" + include: roles/test/tasks/crm/crm_test_ipv4_neighbor.yml + + - name: Run test case "CRM IPv6 neighbor resource" + include: roles/test/tasks/crm/crm_test_ipv6_neighbor.yml + + - name: Run test case "CRM nexthop group resource" + include: roles/test/tasks/crm/crm_test_nexthop_group.yml + + - name: Run test case "CRM nexthop group member resource" + include: roles/test/tasks/crm/crm_test_nexthop_group_member.yml + + - name: Run test case "CRM ACL entry resources" + include: roles/test/tasks/crm/crm_test_acl_entry.yml + + - name: Run test case "CRM ACL counter resources" + include: roles/test/tasks/crm/crm_test_acl_counter.yml + + - name: Run test case "CRM FDB entry resource" + include: roles/test/tasks/crm/crm_test_fdb_entry.yml + + always: + + - name: Restore polling interval + command: crm config polling interval 300 diff --git a/ansible/roles/test/tasks/crm/acl.json b/ansible/roles/test/tasks/crm/acl.json new file mode 100644 index 00000000000..ba2a385128f --- /dev/null +++ b/ansible/roles/test/tasks/crm/acl.json @@ -0,0 +1,30 @@ +{ + "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/crm/crm_test_acl_counter.yml b/ansible/roles/test/tasks/crm/crm_test_acl_counter.yml new file mode 100644 index 00000000000..2e6b52f0901 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_acl_counter.yml @@ -0,0 +1,62 @@ +- block: + + - set_fact: crm_stats_acl_counter_used=0 + - set_fact: crm_stats_acl_counter_available=0 + + - name: Copy ACL JSON config to switch. + copy: src=roles/test/tasks/crm/acl.json dest=/tmp + + - name: Add ACL + command: acl-loader update full /tmp/acl.json + + - name: Get ACL table key + command: bash -c "docker exec -i database redis-cli --raw -n 2 KEYS *CRM:ACL_TABLE_STATS* | head -1" + register: out + - set_fact: acl_tbl_key={{out.stdout}} + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_acl_counter_used" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_counter_used + register: out + - set_fact: new_crm_stats_acl_counter_used={{out.stdout}} + + - name: Get new "crm_stats_acl_counter_available" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_counter_available + register: out + - set_fact: new_crm_stats_acl_counter_available={{out.stdout}} + + - name: Verify "crm_stats_acl_counter_used" counter was incremented + assert: {that: "{{new_crm_stats_acl_counter_used|int - crm_stats_acl_counter_used|int == 2}}"} + + - set_fact: crm_stats_acl_counter_available="{{new_crm_stats_acl_counter_available|int + new_crm_stats_acl_counter_used|int}}" + + - name: Verify thresholds for "ACL entry" CRM resource + vars: + crm_cli_res: "acl group entry" + crm_used: "{{new_crm_stats_acl_counter_used}}" + crm_avail: "{{new_crm_stats_acl_counter_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml + + - name: Remove ACL + command: acl-loader delete + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_acl_counter_used" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_counter_used + register: out + - set_fact: new_crm_stats_acl_counter_used={{out.stdout}} + + - name: Get new "crm_stats_acl_counter_available" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_counter_available + register: out + - set_fact: new_crm_stats_acl_counter_available={{out.stdout}} + + - name: Verify "crm_stats_acl_counter_used" counter was decremented + assert: {that: "{{new_crm_stats_acl_counter_used|int - crm_stats_acl_counter_used|int == 0}}"} + + - name: Verify "crm_stats_acl_counter_available" counter was incremented + assert: {that: "{{new_crm_stats_acl_counter_available|int - crm_stats_acl_counter_available|int == 0}}"} diff --git a/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml b/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml new file mode 100644 index 00000000000..87a9238fc71 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml @@ -0,0 +1,62 @@ +- block: + + - set_fact: crm_stats_acl_entry_used=0 + - set_fact: crm_stats_acl_entry_available=0 + + - name: Copy ACL JSON config to switch. + copy: src=roles/test/tasks/crm/acl.json dest=/tmp + + - name: Add ACL + command: acl-loader update full /tmp/acl.json + + - name: Get ACL table key + command: bash -c "docker exec -i database redis-cli --raw -n 2 KEYS *CRM:ACL_TABLE_STATS* | head -1" + register: out + - set_fact: acl_tbl_key={{out.stdout}} + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_acl_entry_used" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_entry_used + register: out + - set_fact: new_crm_stats_acl_entry_used={{out.stdout}} + + - name: Get new "crm_stats_acl_entry_available" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_entry_available + register: out + - set_fact: new_crm_stats_acl_entry_available={{out.stdout}} + + - name: Verify "crm_stats_acl_entry_used" counter was incremented + assert: {that: "{{new_crm_stats_acl_entry_used|int - crm_stats_acl_entry_used|int == 2}}"} + + - set_fact: crm_stats_acl_entry_available="{{new_crm_stats_acl_entry_available|int + new_crm_stats_acl_entry_used|int}}" + + - name: Verify thresholds for "ACL entry" CRM resource + vars: + crm_cli_res: "acl group entry" + crm_used: "{{new_crm_stats_acl_entry_used}}" + crm_avail: "{{new_crm_stats_acl_entry_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml + + - name: Remove ACL + command: acl-loader delete + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_acl_entry_used" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_entry_used + register: out + - set_fact: new_crm_stats_acl_entry_used={{out.stdout}} + + - name: Get new "crm_stats_acl_entry_available" counter value + command: docker exec -i database redis-cli -n 2 HGET {{acl_tbl_key}} crm_stats_acl_entry_available + register: out + - set_fact: new_crm_stats_acl_entry_available={{out.stdout}} + + - name: Verify "crm_stats_acl_entry_used" counter was decremented + assert: {that: "{{new_crm_stats_acl_entry_used|int - crm_stats_acl_entry_used|int == 0}}"} + + - name: Verify "crm_stats_acl_entry_available" counter was incremented + assert: {that: "{{new_crm_stats_acl_entry_available|int - crm_stats_acl_entry_available|int == 0}}"} diff --git a/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml b/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml new file mode 100644 index 00000000000..4f58e35f848 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml @@ -0,0 +1,66 @@ +- block: + + - name: Get "crm_stats_fdb_entry_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_fdb_entry_used + register: out + - set_fact: crm_stats_fdb_entry_used={{out.stdout}} + + - name: Get "crm_stats_fdb_entry_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_fdb_entry_available + register: out + - set_fact: crm_stats_fdb_entry_available={{out.stdout}} + + - name: Copy FDB JSON config to switch. + copy: src=roles/test/tasks/crm/fdb.json dest=/tmp + + - name: Copy FDB JSON config to SWSS container + command: docker cp /tmp/fdb.json swss:/ + + - name: Add FDB entry + command: docker exec -i swss swssconfig /fdb.json + + - name: Add VLAN required for FDB entry + command: config vlan add 2 + + - name: Add VLAN member required for FDB entry + command: config vlan member add 2 Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_fdb_entry_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_fdb_entry_used + register: out + - set_fact: new_crm_stats_fdb_entry_used={{out.stdout}} + + - name: Get new "crm_stats_fdb_entry_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_fdb_entry_available + register: out + - set_fact: new_crm_stats_fdb_entry_available={{out.stdout}} + + - name: Verify "crm_stats_fdb_entry_used" counter was incremented + assert: {that: "{{new_crm_stats_fdb_entry_used|int - crm_stats_fdb_entry_used|int == 1}}"} + + - name: Verify "crm_stats_fdb_entry_available" counter was decremented + assert: {that: "{{crm_stats_fdb_entry_available|int - new_crm_stats_fdb_entry_available|int == 1}}"} + + - name: Verify thresholds for "FDB entry" CRM resource + vars: + crm_cli_res: "fdb" + crm_used: "{{new_crm_stats_fdb_entry_used}}" + crm_avail: "{{new_crm_stats_fdb_entry_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml + + always: + + - name: Remove VLAN member required for FDB entry + command: config vlan member del 2 Ethernet0 + + - name: Remove VLAN required for FDB entry + command: config vlan del 2 + + - name: Remove FDB JSON config from switch. + command: rm /tmp/fdb.json + + - name: Remove FDB JSON config from SWSS container + command: docker exec -i swss rm /fdb.json diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml b/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml new file mode 100644 index 00000000000..cf9b1379401 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_ipv4_neighbor_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_neighbor_used + register: out + - set_fact: crm_stats_ipv4_neighbor_used={{out.stdout}} + + - name: Get "crm_stats_ipv4_neighbor_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_neighbor_available + register: out + - set_fact: crm_stats_ipv4_neighbor_available={{out.stdout}} + + - name: Add IPv4 neighbor + command: ip neigh replace 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv4_neighbor_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_neighbor_used + register: out + - set_fact: new_crm_stats_ipv4_neighbor_used={{out.stdout}} + + - name: Get new "crm_stats_ipv4_neighbor_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_neighbor_available + register: out + - set_fact: new_crm_stats_ipv4_neighbor_available={{out.stdout}} + + - name: Verify "crm_stats_ipv4_neighbor_used" counter was incremented + assert: {that: "{{new_crm_stats_ipv4_neighbor_used|int - crm_stats_ipv4_neighbor_used|int >= 1}}"} + + - name: Verify "crm_stats_ipv4_neighbor_available" counter was decremented + assert: {that: "{{crm_stats_ipv4_neighbor_available|int - new_crm_stats_ipv4_neighbor_available|int == 1}}"} + + - name: Remove IPv4 neighbor + command: ip neigh del 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv4_neighbor_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_neighbor_used + register: out + - set_fact: new_crm_stats_ipv4_neighbor_used={{out.stdout}} + + - name: Get new "crm_stats_ipv4_neighbor_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_neighbor_available + register: out + - set_fact: new_crm_stats_ipv4_neighbor_available={{out.stdout}} + + - name: Verify "crm_stats_ipv4_neighbor_used" counter was decremented + assert: {that: "{{new_crm_stats_ipv4_neighbor_used|int - crm_stats_ipv4_neighbor_used|int >= 0}}"} + + - name: Verify "crm_stats_ipv4_neighbor_available" counter was incremented + assert: {that: "{{new_crm_stats_ipv4_neighbor_available|int - crm_stats_ipv4_neighbor_available|int == 0}}"} + + - name: Verify thresholds for "IPv4 neighbor" CRM resource + vars: + crm_cli_res: "ipv4 neighbor" + crm_used: "{{new_crm_stats_ipv4_neighbor_used}}" + crm_avail: "{{new_crm_stats_ipv4_neighbor_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml b/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml new file mode 100644 index 00000000000..cdf705843ab --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_ipv4_nexthop_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_nexthop_used + register: out + - set_fact: crm_stats_ipv4_nexthop_used={{out.stdout}} + + - name: Get "crm_stats_ipv4_nexthop_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_nexthop_available + register: out + - set_fact: crm_stats_ipv4_nexthop_available={{out.stdout}} + + - name: Add IPv4 nexthop + command: ip neigh replace 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv4_nexthop_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_nexthop_used + register: out + - set_fact: new_crm_stats_ipv4_nexthop_used={{out.stdout}} + + - name: Get new "crm_stats_ipv4_nexthop_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_nexthop_available + register: out + - set_fact: new_crm_stats_ipv4_nexthop_available={{out.stdout}} + + - name: Verify "crm_stats_ipv4_nexthop_used" counter was incremented + assert: {that: "{{new_crm_stats_ipv4_nexthop_used|int - crm_stats_ipv4_nexthop_used|int == 1}}"} + + - name: Verify "crm_stats_ipv4_nexthop_available" counter was decremented + assert: {that: "{{crm_stats_ipv4_nexthop_available|int - new_crm_stats_ipv4_nexthop_available|int == 1}}"} + + - name: Remove IPv4 nexthop + command: ip neigh del 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv4_nexthop_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_nexthop_used + register: out + - set_fact: new_crm_stats_ipv4_nexthop_used={{out.stdout}} + + - name: Get new "crm_stats_ipv4_nexthop_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_nexthop_available + register: out + - set_fact: new_crm_stats_ipv4_nexthop_available={{out.stdout}} + + - name: Verify "crm_stats_ipv4_nexthop_used" counter was decremented + assert: {that: "{{new_crm_stats_ipv4_nexthop_used|int - crm_stats_ipv4_nexthop_used|int == 0}}"} + + - name: Verify "crm_stats_ipv4_nexthop_available" counter was incremented + assert: {that: "{{new_crm_stats_ipv4_nexthop_available|int - crm_stats_ipv4_nexthop_available|int == 0}}"} + + - name: Verify thresholds for "IPv4 nexthop" CRM resource + vars: + crm_cli_res: "ipv4 nexthop" + crm_used: "{{new_crm_stats_ipv4_nexthop_used}}" + crm_avail: "{{new_crm_stats_ipv4_nexthop_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml b/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml new file mode 100644 index 00000000000..b8b510aee95 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_ipv4_route_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_route_used + register: out + - set_fact: crm_stats_ipv4_route_used={{out.stdout}} + + - name: Get "crm_stats_ipv4_route_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_route_available + register: out + - set_fact: crm_stats_ipv4_route_available={{out.stdout}} + + - name: Add IPv4 route + command: ip route add 2.2.2.0/24 via 10.0.0.1 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv4_route_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_route_used + register: out + - set_fact: new_crm_stats_ipv4_route_used={{out.stdout}} + + - name: Get new "crm_stats_ipv4_route_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_route_available + register: out + - set_fact: new_crm_stats_ipv4_route_available={{out.stdout}} + + - name: Verify "crm_stats_ipv4_route_used" counter was incremented + assert: {that: "{{new_crm_stats_ipv4_route_used|int - crm_stats_ipv4_route_used|int == 1}}"} + + - name: Verify "crm_stats_ipv4_route_available" counter was decremented + assert: {that: "{{crm_stats_ipv4_route_available|int - new_crm_stats_ipv4_route_available|int == 1}}"} + + - name: Remove IPv4 route + command: ip route del 2.2.2.0/24 via 10.0.0.1 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv4_route_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_route_used + register: out + - set_fact: new_crm_stats_ipv4_route_used={{out.stdout}} + + - name: Get new "crm_stats_ipv4_route_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv4_route_available + register: out + - set_fact: new_crm_stats_ipv4_route_available={{out.stdout}} + + - name: Verify "crm_stats_ipv4_route_used" counter was decremented + assert: {that: "{{new_crm_stats_ipv4_route_used|int - crm_stats_ipv4_route_used|int == 0}}"} + + - name: Verify "crm_stats_ipv4_route_available" counter was incremented + assert: {that: "{{new_crm_stats_ipv4_route_available|int - crm_stats_ipv4_route_available|int == 0}}"} + + - name: Verify thresholds for "IPv4 route" CRM resource + vars: + crm_cli_res: "ipv4 route" + crm_used: "{{new_crm_stats_ipv4_route_used}}" + crm_avail: "{{new_crm_stats_ipv4_route_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml b/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml new file mode 100644 index 00000000000..b087965afa6 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_ipv6_neighbor_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_neighbor_used + register: out + - set_fact: crm_stats_ipv6_neighbor_used={{out.stdout}} + + - name: Get "crm_stats_ipv6_neighbor_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_neighbor_available + register: out + - set_fact: crm_stats_ipv6_neighbor_available={{out.stdout}} + + - name: Add IPv6 neighbor + command: ip neigh replace 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv6_neighbor_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_neighbor_used + register: out + - set_fact: new_crm_stats_ipv6_neighbor_used={{out.stdout}} + + - name: Get new "crm_stats_ipv6_neighbor_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_neighbor_available + register: out + - set_fact: new_crm_stats_ipv6_neighbor_available={{out.stdout}} + + - name: Verify "crm_stats_ipv6_neighbor_used" counter was incremented + assert: {that: "{{new_crm_stats_ipv6_neighbor_used|int - crm_stats_ipv6_neighbor_used|int >= 1}}"} + + - name: Verify "crm_stats_ipv6_neighbor_available" counter was decremented + assert: {that: "{{crm_stats_ipv6_neighbor_available|int - new_crm_stats_ipv6_neighbor_available|int == 1}}"} + + - name: Remove IPv6 neighbor + command: ip neigh del 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv6_neighbor_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_neighbor_used + register: out + - set_fact: new_crm_stats_ipv6_neighbor_used={{out.stdout}} + + - name: Get new "crm_stats_ipv6_neighbor_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_neighbor_available + register: out + - set_fact: new_crm_stats_ipv6_neighbor_available={{out.stdout}} + + - name: Verify "crm_stats_ipv6_neighbor_used" counter was decremented + assert: {that: "{{new_crm_stats_ipv6_neighbor_used|int - crm_stats_ipv6_neighbor_used|int >= 0}}"} + + - name: Verify "crm_stats_ipv6_neighbor_available" counter was incremented + assert: {that: "{{new_crm_stats_ipv6_neighbor_available|int - crm_stats_ipv6_neighbor_available|int == 0}}"} + + - name: Verify thresholds for "IPv6 neighbor" CRM resource + vars: + crm_cli_res: "ipv6 neighbor" + crm_used: "{{new_crm_stats_ipv6_neighbor_used}}" + crm_avail: "{{new_crm_stats_ipv6_neighbor_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml b/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml new file mode 100644 index 00000000000..66bc3f52b2c --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_ipv6_nexthop_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_nexthop_used + register: out + - set_fact: crm_stats_ipv6_nexthop_used={{out.stdout}} + + - name: Get "crm_stats_ipv6_nexthop_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_nexthop_available + register: out + - set_fact: crm_stats_ipv6_nexthop_available={{out.stdout}} + + - name: Add IPv6 nexthop + command: ip neigh replace 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv6_nexthop_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_nexthop_used + register: out + - set_fact: new_crm_stats_ipv6_nexthop_used={{out.stdout}} + + - name: Get new "crm_stats_ipv6_nexthop_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_nexthop_available + register: out + - set_fact: new_crm_stats_ipv6_nexthop_available={{out.stdout}} + + - name: Verify "crm_stats_ipv6_nexthop_used" counter was incremented + assert: {that: "{{new_crm_stats_ipv6_nexthop_used|int - crm_stats_ipv6_nexthop_used|int == 1}}"} + + - name: Verify "crm_stats_ipv6_nexthop_available" counter was decremented + assert: {that: "{{crm_stats_ipv6_nexthop_available|int - new_crm_stats_ipv6_nexthop_available|int == 1}}"} + + - name: Remove IPv6 nexthop + command: ip neigh del 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv6_nexthop_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_nexthop_used + register: out + - set_fact: new_crm_stats_ipv6_nexthop_used={{out.stdout}} + + - name: Get new "crm_stats_ipv6_nexthop_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_nexthop_available + register: out + - set_fact: new_crm_stats_ipv6_nexthop_available={{out.stdout}} + + - name: Verify "crm_stats_ipv6_nexthop_used" counter was decremented + assert: {that: "{{new_crm_stats_ipv6_nexthop_used|int - crm_stats_ipv6_nexthop_used|int == 0}}"} + + - name: Verify "crm_stats_ipv6_nexthop_available" counter was incremented + assert: {that: "{{new_crm_stats_ipv6_nexthop_available|int - crm_stats_ipv6_nexthop_available|int == 0}}"} + + - name: Verify thresholds for "IPv6 nexthop" CRM resource + vars: + crm_cli_res: "ipv6 nexthop" + crm_used: "{{new_crm_stats_ipv6_nexthop_used}}" + crm_avail: "{{new_crm_stats_ipv6_nexthop_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml b/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml new file mode 100644 index 00000000000..e2d3c995ee5 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml @@ -0,0 +1,63 @@ +- block: + + - name: Get "crm_stats_ipv6_route_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_route_used + register: out + - set_fact: crm_stats_ipv6_route_used={{out.stdout}} + + - name: Get "crm_stats_ipv6_route_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_route_available + register: out + - set_fact: crm_stats_ipv6_route_available={{out.stdout}} + + - name: Add IPv6 route + command: ip -6 route add 2001::/126 via fc00::2 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv6_route_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_route_used + register: out + - set_fact: new_crm_stats_ipv6_route_used={{out.stdout}} + + - name: Get new "crm_stats_ipv6_route_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_route_available + register: out + - set_fact: new_crm_stats_ipv6_route_available={{out.stdout}} + + - name: Verify "crm_stats_ipv6_route_used" counter was incremented + assert: {that: "{{new_crm_stats_ipv6_route_used|int - crm_stats_ipv6_route_used|int == 1}}"} + + - name: Verify "crm_stats_ipv6_route_available" counter was decremented + assert: {that: "{{crm_stats_ipv6_route_available|int - new_crm_stats_ipv6_route_available|int == 1}}"} + + - name: Remove IPv6 route + command: ip -6 route del 2001::/126 via fc00::2 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_ipv6_route_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_route_used + register: out + - set_fact: new_crm_stats_ipv6_route_used={{out.stdout}} + + - name: Get new "crm_stats_ipv6_route_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_ipv6_route_available + register: out + - set_fact: new_crm_stats_ipv6_route_available={{out.stdout}} + + - name: Verify "crm_stats_ipv6_route_used" counter was decremented + assert: {that: "{{new_crm_stats_ipv6_route_used|int - crm_stats_ipv6_route_used|int == 0}}"} + + - name: Verify "crm_stats_ipv6_route_available" counter was incremented + assert: {that: "{{new_crm_stats_ipv6_route_available|int - crm_stats_ipv6_route_available|int == 0}}"} + + - name: Verify thresholds for "IPv6 route" CRM resource + vars: + crm_cli_res: "ipv6 route" + crm_used: "{{new_crm_stats_ipv6_route_used}}" + crm_avail: "{{new_crm_stats_ipv6_route_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml + diff --git a/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml b/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml new file mode 100644 index 00000000000..11d575faed0 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_nexthop_group_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_used + register: out + - set_fact: crm_stats_nexthop_group_used={{out.stdout}} + + - name: Get "crm_stats_nexthop_group_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_available + register: out + - set_fact: crm_stats_nexthop_group_available={{out.stdout}} + + - name: Add nexthop group + command: ip route add 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_nexthop_group_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_used + register: out + - set_fact: new_crm_stats_nexthop_group_used={{out.stdout}} + + - name: Get new "crm_stats_nexthop_group_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_available + register: out + - set_fact: new_crm_stats_nexthop_group_available={{out.stdout}} + + - name: Verify "crm_stats_nexthop_group_used" counter was incremented + assert: {that: "{{new_crm_stats_nexthop_group_used|int - crm_stats_nexthop_group_used|int == 1}}"} + + - name: Verify "crm_stats_nexthop_group_available" counter was decremented + assert: {that: "{{crm_stats_nexthop_group_available|int - new_crm_stats_nexthop_group_available|int >= 1}}"} + + - name: Remove nexthop group + command: ip route del 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_nexthop_group_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_used + register: out + - set_fact: new_crm_stats_nexthop_group_used={{out.stdout}} + + - name: Get new "crm_stats_nexthop_group_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_available + register: out + - set_fact: new_crm_stats_nexthop_group_available={{out.stdout}} + + - name: Verify "crm_stats_nexthop_group_used" counter was decremented + assert: {that: "{{new_crm_stats_nexthop_group_used|int - crm_stats_nexthop_group_used|int == 0}}"} + + - name: Verify "crm_stats_nexthop_group_available" counter was incremented + assert: {that: "{{new_crm_stats_nexthop_group_available|int - crm_stats_nexthop_group_available|int == 0}}"} + + - name: Verify thresholds for "nexthop group" CRM resource + vars: + crm_cli_res: "nexthop group object" + crm_used: "{{new_crm_stats_nexthop_group_used}}" + crm_avail: "{{new_crm_stats_nexthop_group_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml b/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml new file mode 100644 index 00000000000..9cf3e4af713 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml @@ -0,0 +1,62 @@ +- block: + + - name: Get "crm_stats_nexthop_group_member_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_member_used + register: out + - set_fact: crm_stats_nexthop_group_member_used={{out.stdout}} + + - name: Get "crm_stats_nexthop_group_member_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_member_available + register: out + - set_fact: crm_stats_nexthop_group_member_available={{out.stdout}} + + - name: Add nexthop group members + command: ip route add 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_nexthop_group_member_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_member_used + register: out + - set_fact: new_crm_stats_nexthop_group_member_used={{out.stdout}} + + - name: Get new "crm_stats_nexthop_group_member_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_member_available + register: out + - set_fact: new_crm_stats_nexthop_group_member_available={{out.stdout}} + + - name: Verify "crm_stats_nexthop_group_member_used" counter was incremented + assert: {that: "{{new_crm_stats_nexthop_group_member_used|int - crm_stats_nexthop_group_member_used|int == 2}}"} + + - name: Verify "crm_stats_nexthop_group_member_available" counter was decremented + assert: {that: "{{crm_stats_nexthop_group_member_available|int - new_crm_stats_nexthop_group_member_available|int == 2}}"} + + - name: Remove nexthop group members + command: ip route del 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_nexthop_group_member_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_member_used + register: out + - set_fact: new_crm_stats_nexthop_group_member_used={{out.stdout}} + + - name: Get new "crm_stats_nexthop_group_member_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_nexthop_group_member_available + register: out + - set_fact: new_crm_stats_nexthop_group_member_available={{out.stdout}} + + - name: Verify "crm_stats_nexthop_group_member_used" counter was decremented + assert: {that: "{{new_crm_stats_nexthop_group_member_used|int - crm_stats_nexthop_group_member_used|int == 0}}"} + + - name: Verify "crm_stats_nexthop_group_member_available" counter was incremented + assert: {that: "{{new_crm_stats_nexthop_group_member_available|int - crm_stats_nexthop_group_member_available|int == 0}}"} + + - name: Verify thresholds for "nexthop group member" CRM resource + vars: + crm_cli_res: "nexthop group member" + crm_used: "{{new_crm_stats_nexthop_group_member_used}}" + crm_avail: "{{new_crm_stats_nexthop_group_member_available}}" + include: roles/test/tasks/crm/crm_test_threshold.yml diff --git a/ansible/roles/test/tasks/crm/crm_test_threshold.yml b/ansible/roles/test/tasks/crm/crm_test_threshold.yml new file mode 100644 index 00000000000..3384f21e455 --- /dev/null +++ b/ansible/roles/test/tasks/crm/crm_test_threshold.yml @@ -0,0 +1,76 @@ +- block: + + - name: Verify "CRM_EXCEEDED" log message for "used" threshold + vars: + command_to_run: bash -c "crm config thresholds {{crm_cli_res}} type used; crm config thresholds {{crm_cli_res}} low {{crm_used|int - 1}}; crm config thresholds {{crm_cli_res}} high {{crm_used|int}}" + tests_location: roles/test/tasks + testname: crm + test_expect_file: expect_crm_th_exceeded + out_dir: /tmp + run_dir: /tmp + errors_expected: true + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Verify "CRM_CLEAR" log message for "used" threshold + vars: + command_to_run: bash -c "crm config thresholds {{crm_cli_res}} type used && crm config thresholds {{crm_cli_res}} low {{crm_used|int}} && crm config thresholds {{crm_cli_res}} high {{crm_used|int + 1}}" + tests_location: roles/test/tasks + testname: crm + test_expect_file: expect_crm_th_clear + out_dir: /tmp + run_dir: /tmp + errors_expected: true + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Verify "CRM_EXCEEDED" log message for "free" threshold + vars: + command_to_run: bash -c "crm config thresholds {{crm_cli_res}} type free && crm config thresholds {{crm_cli_res}} low {{crm_avail|int - 1}} && crm config thresholds {{crm_cli_res}} high {{crm_avail|int}}" + tests_location: roles/test/tasks + testname: crm + test_expect_file: expect_crm_th_exceeded + out_dir: /tmp + run_dir: /tmp + errors_expected: true + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Verify "CRM_CLEAR" log message for "free" threshold + vars: + command_to_run: bash -c "crm config thresholds {{crm_cli_res}} type free && crm config thresholds {{crm_cli_res}} low {{crm_avail|int}} && crm config thresholds {{crm_cli_res}} high {{crm_avail|int + 1}}" + tests_location: roles/test/tasks + testname: crm + test_expect_file: expect_crm_th_clear + out_dir: /tmp + run_dir: /tmp + errors_expected: true + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Verify "CRM_EXCEEDED" log message for "percentage" threshold + vars: + th_lo: "{{(crm_used|int * 100 / (crm_used|int + crm_avail|int)) - 1}}" + th_hi: "{{crm_used|int * 100 / (crm_used|int + crm_avail|int)}}" + command_to_run: bash -c "crm config thresholds {{crm_cli_res}} type percentage && crm config thresholds {{crm_cli_res}} low {{th_lo|int}} && crm config thresholds {{crm_cli_res}} high {{th_hi|int}}" + tests_location: roles/test/tasks + testname: crm + test_expect_file: expect_crm_th_exceeded + out_dir: /tmp + run_dir: /tmp + errors_expected: true + include: roles/test/tasks/run_command_with_log_analyzer.yml + + - name: Verify "CRM_CLEAR" log message for "percentage" threshold + vars: + th_lo: "{{crm_used|int * 100 / (crm_used|int + crm_avail|int)}}" + th_hi: "{{(crm_used|int * 100 / (crm_used|int + crm_avail|int)) + 1}}" + command_to_run: bash -c "crm config thresholds {{crm_cli_res}} type percentage && crm config thresholds {{crm_cli_res}} low {{th_lo|int}} && crm config thresholds {{crm_cli_res}} high {{th_hi|int}}" + tests_location: roles/test/tasks + testname: crm + test_expect_file: expect_crm_th_clear + out_dir: /tmp + run_dir: /tmp + errors_expected: true + include: roles/test/tasks/run_command_with_log_analyzer.yml + + always: + + - name: Restore CRM threshods + command: bash -c "crm config thresholds {{crm_cli_res}} type percentage && crm config thresholds {{crm_cli_res}} low 70 && crm config thresholds {{crm_cli_res}} high 85" diff --git a/ansible/roles/test/tasks/crm/expect_crm_th_clear b/ansible/roles/test/tasks/crm/expect_crm_th_clear new file mode 100644 index 00000000000..fab01e5131c --- /dev/null +++ b/ansible/roles/test/tasks/crm/expect_crm_th_clear @@ -0,0 +1 @@ +r, ".* THRESHOLD_CLEAR .*" diff --git a/ansible/roles/test/tasks/crm/expect_crm_th_exceeded b/ansible/roles/test/tasks/crm/expect_crm_th_exceeded new file mode 100644 index 00000000000..dd42f4412f1 --- /dev/null +++ b/ansible/roles/test/tasks/crm/expect_crm_th_exceeded @@ -0,0 +1 @@ +r, ".* THRESHOLD_EXCEEDED .*" diff --git a/ansible/roles/test/tasks/crm/fdb.json b/ansible/roles/test/tasks/crm/fdb.json new file mode 100644 index 00000000000..e280e3d68fe --- /dev/null +++ b/ansible/roles/test/tasks/crm/fdb.json @@ -0,0 +1,9 @@ +[ + { + "FDB_TABLE:Vlan2:52-54-00-25-07-E9": { + "port": "Ethernet0", + "type": "dynamic" + }, + "OP": "SET" + } +] diff --git a/ansible/roles/test/tasks/test_sonic_by_tag.yml b/ansible/roles/test/tasks/test_sonic_by_tag.yml index 426ec840fe5..c4286da552d 100644 --- a/ansible/roles/test/tasks/test_sonic_by_tag.yml +++ b/ansible/roles/test/tasks/test_sonic_by_tag.yml @@ -175,3 +175,7 @@ - name: neighbor mac change test without using ptf include: neighbour-mac-noptf.yml tags: neighbour_mac_noptf + +- name: CRM test + include: crm.yml + tags: crm diff --git a/ansible/roles/test/vars/testcases.yml b/ansible/roles/test/vars/testcases.yml index d629f50da4c..af9500060e8 100644 --- a/ansible/roles/test/vars/testcases.yml +++ b/ansible/roles/test/vars/testcases.yml @@ -176,3 +176,7 @@ testcases: required_vars: ptf_host: testbed_type: + + crm: + filename: crm.yml + topologies: [t1] From 545631ec7e3bb2b9915ba7f231fe6f42aa4f0acb Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Mon, 5 Mar 2018 17:33:34 +0200 Subject: [PATCH 2/3] [crm]: Implement test for CRM * Add support of t0 and t1-lag topologies * Add option to run commands with sudo privileges * Fix problem with fetching ACL table ID Signed-off-by: Volodymyr Samotiy --- ansible/roles/test/tasks/crm.yml | 12 ++++++++++ .../test/tasks/crm/crm_test_acl_counter.yml | 23 +++++++++++++++--- .../test/tasks/crm/crm_test_acl_entry.yml | 24 +++++++++++++++++-- .../test/tasks/crm/crm_test_fdb_entry.yml | 4 ++++ .../test/tasks/crm/crm_test_ipv4_neighbor.yml | 6 +++-- .../test/tasks/crm/crm_test_ipv4_nexthop.yml | 6 +++-- .../test/tasks/crm/crm_test_ipv4_route.yml | 8 ++++--- .../test/tasks/crm/crm_test_ipv6_neighbor.yml | 6 +++-- .../test/tasks/crm/crm_test_ipv6_nexthop.yml | 6 +++-- .../test/tasks/crm/crm_test_ipv6_route.yml | 6 +++-- .../test/tasks/crm/crm_test_nexthop_group.yml | 6 +++-- .../crm/crm_test_nexthop_group_member.yml | 6 +++-- ansible/roles/test/vars/testcases.yml | 2 +- 13 files changed, 92 insertions(+), 23 deletions(-) diff --git a/ansible/roles/test/tasks/crm.yml b/ansible/roles/test/tasks/crm.yml index 5009ae14f2b..0173d361737 100644 --- a/ansible/roles/test/tasks/crm.yml +++ b/ansible/roles/test/tasks/crm.yml @@ -1,5 +1,17 @@ - block: + - fail: msg="Information about tested missing" + when: (testbed_type is not defined) + + - fail: msg="Invalid testbed_type value '{{testbed_type}}'" + when: testbed_type not in ['t1', 't1-lag', 't0'] + + - set_fact: crm_intf="{{minigraph_interfaces[0].attachto}}" + when: testbed_type == "t1" + + - set_fact: crm_intf="{{minigraph_portchannel_interfaces[0].attachto}}" + when: (testbed_type == "t0") or (testbed_type == "t1-lag") + - name: Set polling interval command: crm config polling interval 1 diff --git a/ansible/roles/test/tasks/crm/crm_test_acl_counter.yml b/ansible/roles/test/tasks/crm/crm_test_acl_counter.yml index 2e6b52f0901..faa404eb8da 100644 --- a/ansible/roles/test/tasks/crm/crm_test_acl_counter.yml +++ b/ansible/roles/test/tasks/crm/crm_test_acl_counter.yml @@ -8,11 +8,27 @@ - name: Add ACL command: acl-loader update full /tmp/acl.json + become: yes + + - name: Get ACL entry keys + command: bash -c "docker exec -i database redis-cli --raw -n 1 KEYS *SAI_OBJECT_TYPE_ACL_ENTRY*" + register: out + - set_fact: acl_tbl_keys={{out.stdout.split()}} + + - name: Get ethertype for ACL entry in order to match ACL which was configured + command: bash -c "docker exec -i database redis-cli -n 1 HGET {{item}} SAI_ACL_ENTRY_ATTR_FIELD_ETHER_TYPE" + with_items: "{{acl_tbl_keys}}" + register: out + + - name: Match ethertype value for ACL entry + set_fact: key={{item.item}} + with_items: "{{out.results}}" + when: item.stdout|search("2048") - name: Get ACL table key - command: bash -c "docker exec -i database redis-cli --raw -n 2 KEYS *CRM:ACL_TABLE_STATS* | head -1" + command: bash -c "docker exec -i database redis-cli -n 1 HGET {{key}} SAI_ACL_ENTRY_ATTR_TABLE_ID" register: out - - set_fact: acl_tbl_key={{out.stdout}} + - set_fact: acl_tbl_key={{"CRM:ACL_TABLE_STATS:{0}".format(out.stdout|replace("oid:", ""))}} - name: Make sure CRM counters updated pause: seconds=1 @@ -34,13 +50,14 @@ - name: Verify thresholds for "ACL entry" CRM resource vars: - crm_cli_res: "acl group entry" + crm_cli_res: "acl group counter" crm_used: "{{new_crm_stats_acl_counter_used}}" crm_avail: "{{new_crm_stats_acl_counter_available}}" include: roles/test/tasks/crm/crm_test_threshold.yml - name: Remove ACL command: acl-loader delete + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml b/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml index 87a9238fc71..424526d61c6 100644 --- a/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml +++ b/ansible/roles/test/tasks/crm/crm_test_acl_entry.yml @@ -8,11 +8,30 @@ - name: Add ACL command: acl-loader update full /tmp/acl.json + become: yes + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get ACL entry keys + command: bash -c "docker exec -i database redis-cli --raw -n 1 KEYS *SAI_OBJECT_TYPE_ACL_ENTRY*" + register: out + - set_fact: acl_tbl_keys={{out.stdout.split()}} + + - name: Get ethertype for ACL entry in order to match ACL which was configured + command: bash -c "docker exec -i database redis-cli -n 1 HGET {{item}} SAI_ACL_ENTRY_ATTR_FIELD_ETHER_TYPE" + with_items: "{{acl_tbl_keys}}" + register: out + + - name: Match ethertype value for ACL entry + set_fact: key={{item.item}} + with_items: "{{out.results}}" + when: item.stdout|search("2048") - name: Get ACL table key - command: bash -c "docker exec -i database redis-cli --raw -n 2 KEYS *CRM:ACL_TABLE_STATS* | head -1" + command: bash -c "docker exec -i database redis-cli -n 1 HGET {{key}} SAI_ACL_ENTRY_ATTR_TABLE_ID" register: out - - set_fact: acl_tbl_key={{out.stdout}} + - set_fact: acl_tbl_key={{"CRM:ACL_TABLE_STATS:{0}".format(out.stdout|replace("oid:", ""))}} - name: Make sure CRM counters updated pause: seconds=1 @@ -41,6 +60,7 @@ - name: Remove ACL command: acl-loader delete + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml b/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml index 4f58e35f848..ff065b7bbb3 100644 --- a/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml +++ b/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml @@ -21,9 +21,11 @@ - name: Add VLAN required for FDB entry command: config vlan add 2 + become: yes - name: Add VLAN member required for FDB entry command: config vlan member add 2 Ethernet0 + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -55,9 +57,11 @@ - name: Remove VLAN member required for FDB entry command: config vlan member del 2 Ethernet0 + become: yes - name: Remove VLAN required for FDB entry command: config vlan del 2 + become: yes - name: Remove FDB JSON config from switch. command: rm /tmp/fdb.json diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml b/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml index cf9b1379401..5e553a173bb 100644 --- a/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml +++ b/ansible/roles/test/tasks/crm/crm_test_ipv4_neighbor.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_ipv4_neighbor_available={{out.stdout}} - name: Add IPv4 neighbor - command: ip neigh replace 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh replace 2.2.2.2 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_ipv4_neighbor_available|int - new_crm_stats_ipv4_neighbor_available|int == 1}}"} - name: Remove IPv4 neighbor - command: ip neigh del 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh del 2.2.2.2 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml b/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml index cdf705843ab..689cd5bd964 100644 --- a/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml +++ b/ansible/roles/test/tasks/crm/crm_test_ipv4_nexthop.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_ipv4_nexthop_available={{out.stdout}} - name: Add IPv4 nexthop - command: ip neigh replace 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh replace 2.2.2.2 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_ipv4_nexthop_available|int - new_crm_stats_ipv4_nexthop_available|int == 1}}"} - name: Remove IPv4 nexthop - command: ip neigh del 2.2.2.2 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh del 2.2.2.2 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml b/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml index b8b510aee95..4e5b00cc73e 100644 --- a/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml +++ b/ansible/roles/test/tasks/crm/crm_test_ipv4_route.yml @@ -10,8 +10,9 @@ register: out - set_fact: crm_stats_ipv4_route_available={{out.stdout}} - - name: Add IPv4 route - command: ip route add 2.2.2.0/24 via 10.0.0.1 + - name: Add IPv4 route + command: ip route add 2.2.2.0/24 via 10.0.0.57 + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_ipv4_route_available|int - new_crm_stats_ipv4_route_available|int == 1}}"} - name: Remove IPv4 route - command: ip route del 2.2.2.0/24 via 10.0.0.1 + command: ip route del 2.2.2.0/24 via 10.0.0.57 + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml b/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml index b087965afa6..40fcbd53cdb 100644 --- a/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml +++ b/ansible/roles/test/tasks/crm/crm_test_ipv6_neighbor.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_ipv6_neighbor_available={{out.stdout}} - name: Add IPv6 neighbor - command: ip neigh replace 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh replace 2001::1 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_ipv6_neighbor_available|int - new_crm_stats_ipv6_neighbor_available|int == 1}}"} - name: Remove IPv6 neighbor - command: ip neigh del 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh del 2001::1 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml b/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml index 66bc3f52b2c..754e32c4f33 100644 --- a/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml +++ b/ansible/roles/test/tasks/crm/crm_test_ipv6_nexthop.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_ipv6_nexthop_available={{out.stdout}} - name: Add IPv6 nexthop - command: ip neigh replace 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh replace 2001::1 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_ipv6_nexthop_available|int - new_crm_stats_ipv6_nexthop_available|int == 1}}"} - name: Remove IPv6 nexthop - command: ip neigh del 2001::1 lladdr 11:22:33:44:55:66 dev Ethernet0 + command: ip neigh del 2001::1 lladdr 11:22:33:44:55:66 dev {{crm_intf}} + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml b/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml index e2d3c995ee5..a6a5c10a5d8 100644 --- a/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml +++ b/ansible/roles/test/tasks/crm/crm_test_ipv6_route.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_ipv6_route_available={{out.stdout}} - name: Add IPv6 route - command: ip -6 route add 2001::/126 via fc00::2 + command: ip -6 route add 2001::/126 via fc00::72 + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_ipv6_route_available|int - new_crm_stats_ipv6_route_available|int == 1}}"} - name: Remove IPv6 route - command: ip -6 route del 2001::/126 via fc00::2 + command: ip -6 route del 2001::/126 via fc00::72 + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml b/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml index 11d575faed0..7b593fe904b 100644 --- a/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml +++ b/ansible/roles/test/tasks/crm/crm_test_nexthop_group.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_nexthop_group_available={{out.stdout}} - name: Add nexthop group - command: ip route add 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + command: ip route add 2.2.2.0/24 nexthop via 10.0.0.57 nexthop via 10.0.0.59 + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_nexthop_group_available|int - new_crm_stats_nexthop_group_available|int >= 1}}"} - name: Remove nexthop group - command: ip route del 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + command: ip route del 2.2.2.0/24 nexthop via 10.0.0.57 nexthop via 10.0.0.59 + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml b/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml index 9cf3e4af713..5960a085743 100644 --- a/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml +++ b/ansible/roles/test/tasks/crm/crm_test_nexthop_group_member.yml @@ -11,7 +11,8 @@ - set_fact: crm_stats_nexthop_group_member_available={{out.stdout}} - name: Add nexthop group members - command: ip route add 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + command: ip route add 2.2.2.0/24 nexthop via 10.0.0.57 nexthop via 10.0.0.59 + become: yes - name: Make sure CRM counters updated pause: seconds=1 @@ -33,7 +34,8 @@ assert: {that: "{{crm_stats_nexthop_group_member_available|int - new_crm_stats_nexthop_group_member_available|int == 2}}"} - name: Remove nexthop group members - command: ip route del 2.2.2.0/24 nexthop via 10.0.0.1 dev Ethernet0 nexthop via 10.0.0.5 dev Ethernet8 + command: ip route del 2.2.2.0/24 nexthop via 10.0.0.57 nexthop via 10.0.0.59 + become: yes - name: Make sure CRM counters updated pause: seconds=1 diff --git a/ansible/roles/test/vars/testcases.yml b/ansible/roles/test/vars/testcases.yml index af9500060e8..2d43d784ff9 100644 --- a/ansible/roles/test/vars/testcases.yml +++ b/ansible/roles/test/vars/testcases.yml @@ -179,4 +179,4 @@ testcases: crm: filename: crm.yml - topologies: [t1] + topologies: [t1, t1-lag, t0] From 51f940adfc1c2af2479c6e73bb58a577daf57000 Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Tue, 6 Mar 2018 14:37:04 +0200 Subject: [PATCH 3/3] [crm]: Implement test for CRM * Update FDB entry test case Signed-off-by: Volodymyr Samotiy --- .../test/tasks/crm/crm_test_fdb_entry.yml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml b/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml index ff065b7bbb3..165270cb845 100644 --- a/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml +++ b/ansible/roles/test/tasks/crm/crm_test_fdb_entry.yml @@ -53,6 +53,28 @@ crm_avail: "{{new_crm_stats_fdb_entry_available}}" include: roles/test/tasks/crm/crm_test_threshold.yml + - name: Remove FDB entry + command: fdbclear + + - name: Make sure CRM counters updated + pause: seconds=1 + + - name: Get new "crm_stats_fdb_entry_used" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_fdb_entry_used + register: out + - set_fact: new_crm_stats_fdb_entry_used={{out.stdout}} + + - name: Get new "crm_stats_fdb_entry_available" counter value + command: docker exec -i database redis-cli -n 2 HGET CRM:STATS crm_stats_fdb_entry_available + register: out + - set_fact: new_crm_stats_fdb_entry_available={{out.stdout}} + + - name: Verify "crm_stats_fdb_entry_used" counter was decremented + assert: {that: "{{new_crm_stats_fdb_entry_used|int - crm_stats_fdb_entry_used|int == 0}}"} + + - name: Verify "crm_stats_fdb_entry_available" counter was incremented + assert: {that: "{{new_crm_stats_fdb_entry_available|int - crm_stats_fdb_entry_available|int == 0}}"} + always: - name: Remove VLAN member required for FDB entry @@ -63,6 +85,9 @@ command: config vlan del 2 become: yes + - name: Remove FDB entry + command: fdbclear + - name: Remove FDB JSON config from switch. command: rm /tmp/fdb.json