Skip to content

Commit d8f2b23

Browse files
authored
Fix integration tests with v3.0 (#619)
* Uncomment v3.0 in matrix * Remove `display_name` from services and interfaces * Remove `display_name` from compose * Run ansible-test with --color * Change latitude & longitude to float instead of str * Fix incorrect vcpus assert * Remove `display_name` from nb_lookup tests * Add changelog fragment * Use Python 3.8 with NetBox v3.0 for integration tests
1 parent b600fb7 commit d8f2b23

File tree

11 files changed

+25
-51
lines changed

11 files changed

+25
-51
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ jobs:
5151
- python-version: 3.8
5252
VERSION: "v2.11"
5353
INTEGRATION_TESTS: "v2.11"
54-
#- python-version: 3.6
55-
# VERSION: "v3.0"
56-
# INTEGRATION_TESTS: "v3.0"
54+
- python-version: 3.8
55+
VERSION: "v3.0"
56+
INTEGRATION_TESTS: "v3.0"
5757
steps:
5858
- name: Checkout repo
5959
uses: actions/checkout@v2
@@ -156,8 +156,8 @@ jobs:
156156
# Run regression and integration tests
157157
# Run the inventory test first, in case any of the other tests modify the data.
158158
run: |
159-
ansible-test integration -v --coverage --python ${{ matrix.python-version }} inventory-${{ matrix.INTEGRATION_TESTS }}
160-
ansible-test integration -v --coverage --python ${{ matrix.python-version }} regression-${{ matrix.INTEGRATION_TESTS }}
161-
ansible-test integration -v --coverage --python ${{ matrix.python-version }} ${{ matrix.INTEGRATION_TESTS }}
159+
ansible-test integration -v --color --coverage --python ${{ matrix.python-version }} inventory-${{ matrix.INTEGRATION_TESTS }}
160+
ansible-test integration -v --color --coverage --python ${{ matrix.python-version }} regression-${{ matrix.INTEGRATION_TESTS }}
161+
ansible-test integration -v --color --coverage --python ${{ matrix.python-version }} ${{ matrix.INTEGRATION_TESTS }}
162162
ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
163163
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- netbox.netbox - Fixed integration tests with v3.0

tests/integration/targets/inventory-v3.0/files/test-inventory-legacy.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"description": "",
6464
"device": {
6565
"display": "Test Nexus One",
66-
"display_name": "Test Nexus One",
6766
"id": 4,
6867
"name": "Test Nexus One"
6968
},
@@ -200,7 +199,6 @@
200199
"description": "",
201200
"device": {
202201
"display": "test100",
203-
"display_name": "test100",
204202
"id": 1,
205203
"name": "test100"
206204
},
@@ -223,7 +221,6 @@
223221
"description": "",
224222
"device": {
225223
"display": "test100",
226-
"display_name": "test100",
227224
"id": 1,
228225
"name": "test100"
229226
},
@@ -398,4 +395,4 @@
398395
"test104-vm"
399396
]
400397
}
401-
}
398+
}

tests/integration/targets/inventory-v3.0/files/test-inventory-options-flatten.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"description": "",
6262
"device": {
6363
"display": "Test Nexus One",
64-
"display_name": "Test Nexus One",
6564
"id": 4,
6665
"name": "Test Nexus One"
6766
},
@@ -122,7 +121,6 @@
122121
"description": "",
123122
"device": {
124123
"display": "Test Nexus Child One",
125-
"display_name": "Test Nexus Child One",
126124
"id": 5,
127125
"name": "Test Nexus Child One"
128126
},
@@ -189,7 +187,6 @@
189187
"description": "",
190188
"device": {
191189
"display": "Test Nexus One",
192-
"display_name": "Test Nexus One",
193190
"id": 4,
194191
"name": "Test Nexus One"
195192
},
@@ -336,7 +333,6 @@
336333
"description": "",
337334
"device": {
338335
"display": "test100",
339-
"display_name": "test100",
340336
"id": 1,
341337
"name": "test100"
342338
},
@@ -397,7 +393,6 @@
397393
"description": "",
398394
"device": {
399395
"display": "test100",
400-
"display_name": "test100",
401396
"id": 1,
402397
"name": "test100"
403398
},
@@ -466,7 +461,6 @@
466461
"description": "",
467462
"device": {
468463
"display": "test100",
469-
"display_name": "test100",
470464
"id": 1,
471465
"name": "test100"
472466
},
@@ -489,7 +483,6 @@
489483
"description": "",
490484
"device": {
491485
"display": "test100",
492-
"display_name": "test100",
493486
"id": 1,
494487
"name": "test100"
495488
},
@@ -976,4 +969,4 @@
976969
"R1-Device"
977970
]
978971
}
979-
}
972+
}

tests/integration/targets/inventory-v3.0/files/test-inventory-options.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"R1-Device": {
2929
"custom_fields": {},
3030
"device_type": "cisco-test",
31-
"display": "R1-Device",
3231
"is_virtual": false,
3332
"locations": [],
3433
"manufacturer": "cisco",
@@ -60,7 +59,6 @@
6059
"TestDeviceR1": {
6160
"custom_fields": {},
6261
"device_type": "cisco-test",
63-
"display": "TestDeviceR1",
6462
"is_virtual": false,
6563
"locations": [
6664
"test-rack-group",
@@ -85,7 +83,6 @@
8583
"ansible_host": "nexus.example.com",
8684
"custom_fields": {},
8785
"device_type": "nexus-parent",
88-
"display": "Test Nexus One",
8986
"dns_name": "nexus.example.com",
9087
"is_virtual": false,
9188
"locations": [
@@ -109,7 +106,6 @@
109106
"test100": {
110107
"custom_fields": {},
111108
"device_type": "cisco-test",
112-
"display": "test100",
113109
"is_virtual": false,
114110
"local_context_data": {
115111
"ntp_servers": [
@@ -361,4 +357,4 @@
361357
"R1-Device"
362358
]
363359
}
364-
}
360+
}

tests/integration/targets/inventory-v3.0/files/test-inventory-options.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ vm_query_filters:
4949
# https://docs.ansible.com/ansible/latest/plugins/inventory/constructed.html
5050

5151
compose:
52-
display: display_name
5352
rack_id: rack.id
5453
ntp_servers: config_context.ntp_servers
5554

tests/integration/targets/inventory-v3.0/files/test-inventory-plurals.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"description": "",
6464
"device": {
6565
"display": "Test Nexus One",
66-
"display_name": "Test Nexus One",
6766
"id": 4,
6867
"name": "Test Nexus One"
6968
},
@@ -124,7 +123,6 @@
124123
"description": "",
125124
"device": {
126125
"display": "Test Nexus Child One",
127-
"display_name": "Test Nexus Child One",
128126
"id": 5,
129127
"name": "Test Nexus Child One"
130128
},
@@ -195,7 +193,6 @@
195193
"description": "",
196194
"device": {
197195
"display": "Test Nexus One",
198-
"display_name": "Test Nexus One",
199196
"id": 4,
200197
"name": "Test Nexus One"
201198
},
@@ -381,7 +378,6 @@
381378
"description": "",
382379
"device": {
383380
"display": "test100",
384-
"display_name": "test100",
385381
"id": 1,
386382
"name": "test100"
387383
},
@@ -442,7 +438,6 @@
442438
"description": "",
443439
"device": {
444440
"display": "test100",
445-
"display_name": "test100",
446441
"id": 1,
447442
"name": "test100"
448443
},
@@ -516,7 +511,6 @@
516511
"description": "",
517512
"device": {
518513
"display": "test100",
519-
"display_name": "test100",
520514
"id": 1,
521515
"name": "test100"
522516
},
@@ -539,7 +533,6 @@
539533
"description": "",
540534
"device": {
541535
"display": "test100",
542-
"display_name": "test100",
543536
"id": 1,
544537
"name": "test100"
545538
},
@@ -1095,4 +1088,4 @@
10951088
"test104-vm"
10961089
]
10971090
}
1098-
}
1091+
}

tests/integration/targets/inventory-v3.0/files/test-inventory.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"description": "",
4242
"device": {
4343
"display": "Test Nexus One",
44-
"display_name": "Test Nexus One",
4544
"id": 4,
4645
"name": "Test Nexus One"
4746
},
@@ -102,7 +101,6 @@
102101
"description": "",
103102
"device": {
104103
"display": "Test Nexus Child One",
105-
"display_name": "Test Nexus Child One",
106104
"id": 5,
107105
"name": "Test Nexus Child One"
108106
},
@@ -169,7 +167,6 @@
169167
"description": "",
170168
"device": {
171169
"display": "Test Nexus One",
172-
"display_name": "Test Nexus One",
173170
"id": 4,
174171
"name": "Test Nexus One"
175172
},
@@ -326,7 +323,6 @@
326323
"description": "",
327324
"device": {
328325
"display": "test100",
329-
"display_name": "test100",
330326
"id": 1,
331327
"name": "test100"
332328
},
@@ -387,7 +383,6 @@
387383
"description": "",
388384
"device": {
389385
"display": "test100",
390-
"display_name": "test100",
391386
"id": 1,
392387
"name": "test100"
393388
},
@@ -458,7 +453,6 @@
458453
"description": "",
459454
"device": {
460455
"display": "test100",
461-
"display_name": "test100",
462456
"id": 1,
463457
"name": "test100"
464458
},
@@ -481,7 +475,6 @@
481475
"description": "",
482476
"device": {
483477
"display": "test100",
484-
"display_name": "test100",
485478
"id": 1,
486479
"name": "test100"
487480
},
@@ -1021,4 +1014,4 @@
10211014
"test104-vm"
10221015
]
10231016
}
1024-
}
1017+
}

tests/integration/targets/v3.0/tasks/netbox_lookup.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
- name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)"
1414
assert:
15-
that: "{{ query_result|community.general.json_query('[?value.display_name==`Wibble`]')|count }} == 0"
15+
that: "{{ query_result|community.general.json_query('[?value.display==`Wibble`]')|count }} == 0"
1616
vars:
1717
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}"
1818

1919
- name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1"
2020
assert:
21-
that: "{{ query_result|community.general.json_query('[?value.display_name==`TestDeviceR1`]')|count }} == 1"
21+
that: "{{ query_result|community.general.json_query('[?value.display==`TestDeviceR1`]')|count }} == 1"
2222
vars:
2323
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}"
2424

@@ -58,21 +58,21 @@
5858

5959
- name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device"
6060
assert:
61-
that: "{{ query_result|community.general.json_query('[?value.display_name==`L2`]')|count }} == 1"
61+
that: "{{ query_result|community.general.json_query('[?value.display==`L2`]')|count }} == 1"
6262
vars:
6363
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}"
6464

6565
- name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict"
6666
assert:
67-
that: "{{ query_result|community.general.json_query('[?display_name==`L2`]')|count }} == 1"
67+
that: "{{ query_result|community.general.json_query('[?display==`L2`]')|count }} == 1"
6868
vars:
6969
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567', raw_data=True) }}"
7070

7171
- name: "NETBOX_LOOKUP 9: Device query specifying multiple sites, Make sure L1 and L2 are in the results"
7272
assert:
7373
that:
74-
- "'L1' in {{ query_result |community.general.json_query('[*].display_name') }}"
75-
- "'L2' in {{ query_result |community.general.json_query('[*].display_name') }}"
74+
- "'L1' in {{ query_result |community.general.json_query('[*].display') }}"
75+
- "'L2' in {{ query_result |community.general.json_query('[*].display') }}"
7676
vars:
7777
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch site=test-site site=test-site2', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567', raw_data=True) }}"
7878

tests/integration/targets/v3.0/tasks/netbox_site.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
- test_four['site']['description'] == "This is a test description"
108108
- test_four['site']['physical_address'] == "Hollywood, CA, 90210"
109109
- test_four['site']['shipping_address'] == "Hollywood, CA, 90210"
110-
- test_four['site']['latitude'] == "22.169141"
111-
- test_four['site']['longitude'] == "-100.994041"
110+
- test_four['site']['latitude'] == 22.169141
111+
- test_four['site']['longitude'] == -100.994041
112112
- test_four['site']['contact_name'] == "Jenny"
113113
- test_four['site']['contact_phone'] == "867-5309"
114114
- test_four['site']['contact_email'] == "jenny@changednumber.com"
@@ -157,8 +157,8 @@
157157
- test_results['site']['description'] == "This is a test description"
158158
- test_results['site']['physical_address'] == "Hollywood, CA, 90210"
159159
- test_results['site']['shipping_address'] == "Hollywood, CA, 90210"
160-
- test_results['site']['latitude'] == "22.169141"
161-
- test_results['site']['longitude'] == "-100.994041"
160+
- test_results['site']['latitude'] == 22.169141
161+
- test_results['site']['longitude'] == -100.994041
162162
- test_results['site']['contact_name'] == "Jenny"
163163
- test_results['site']['contact_phone'] == "867-5309"
164164
- test_results['site']['contact_email'] == "jenny@changednumber.com"

0 commit comments

Comments
 (0)