summaryrefslogtreecommitdiff
path: root/test/integration/targets/exos_l2_interfaces/tests/httpapi/deleted.yaml
blob: 23921ee9a2340fcc8f8bbbaab0bb30baa70e79b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
- debug:
    msg: "Start exos_l2_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"

- include_tasks: _reset_config.yaml
  ignore_errors: yes

- include_tasks: _populate_config.yaml

- set_fact:
    config:
      - access:
          vlan: 1
        name: '2'
        trunk: null
      - access:
          vlan: 1
        name: '3'
        trunk: null
    config_all:
      - access:
          vlan: 1
        name: '1'
        trunk: null

- exos_facts:
    gather_network_resources: l2_interfaces

- block:
  - name: Delete L2 interface configuration
    exos_l2_interfaces: &deleted
      config:
        - name: '2'
        - name: '3'
      state: deleted
    register: result

  - name: Assert that correct set of results were generated
    assert:
      that:
        - "deleted['requests_1']|symmetric_difference(result['requests']) == []"
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []"

  - exos_facts:
      gather_network_resources: l2_interfaces

  - name: Assert that after dicts were correctly generated
    assert:
      that:
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []"
        - "config|difference(ansible_facts.network_resources.l2_interfaces) == []"

  - name: Delete L2 interface configuration
    exos_l2_interfaces:
      config:
      state: deleted
    register: result

  - name: Assert that correct set of results were generated
    assert:
      that:
        - "deleted['requests_2']|symmetric_difference(result['requests']) == []"
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []"

  - exos_facts:
      gather_network_resources: l2_interfaces

  - name: Assert that after dicts were correctly generated
    assert:
      that:
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []"
        - "config_all|difference(ansible_facts.network_resources.l2_interfaces) == []"

  - name: Delete attributes of all configured interfaces (IDEMPOTENT)
    exos_l2_interfaces: *deleted
    register: result

  - name: Assert that the previous task was idempotent
    assert:
      that:
        - "result.changed == false"

  - exos_facts:
      gather_network_resources: l2_interfaces

  - name: Assert that the before dicts were correctly generated
    assert:
      that:
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []"

  - set_fact:
      expected_config: "{{ config }} + {{ config_all }}"

  - assert:
      that:
        - "expected_config|difference(ansible_facts.network_resources.l2_interfaces) == []"