Closed pugnacity closed 3 months ago
It looks like something broke in the circuit integration tests. I would recommend running invoke integration -vvv -t circuit
to narrow down the issue. From the CI it looks like something is not idempotent.
I can't understand why this happens
integration-1 | TASK [latest : PYNAUTOBOT_CIRCUIT 2: Duplicate] ********************************
integration-1 | task path: /usr/share/ansible/collections/ansible_collections/networktocode/nautobot/tests/output/.tmp/integration/latest-pnro1qkk-ÅÑŚÌβŁÈ/tests/integration/targets/latest/tasks/circuit.yml:35
integration-1 | Using module file /usr/share/ansible/collections/ansible_collections/networktocode/nautobot/plugins/modules/circuit.py
integration-1 | Pipelining is enabled.
integration-1 | <testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
integration-1 | <testhost> EXEC /bin/sh -c '/usr/local/bin/python3.9 && sleep 0'
integration-1 | changed: [testhost] => {
integration-1 | "changed": true,
integration-1 | "circuit": {
integration-1 | "cid": "Test Circuit One",
integration-1 | "circuit_termination_a": null,
integration-1 | "circuit_termination_z": null,
integration-1 | "circuit_type": "6022cdb9-2b49-4f03-af10-0bf9e5d54131",
integration-1 | "comments": "",
integration-1 | "commit_rate": null,
integration-1 | "created": "2024-04-04T06:35:28.345846Z",
integration-1 | "custom_fields": {
integration-1 | "my_selection_custom_field": null
integration-1 | },
integration-1 | "description": "",
integration-1 | "display": "Test Circuit One",
integration-1 | "id": "e029fb08-1647-4772-b3ea-bb2290a8f845",
integration-1 | "install_date": null,
integration-1 | "last_updated": "2024-04-04T06:35:28.345865Z",
integration-1 | "natural_slug": "test-provider_test-circuit-one_e029",
integration-1 | "notes_url": "http://nautobot:8000/api/circuits/circuits/e029fb08-1647-4772-b3ea-bb2290a8f845/notes/",
integration-1 | "object_type": "circuits.circuit",
integration-1 | "provider": "bf385bae-9714-47f8-82e2-e621e0ecfdbe",
integration-1 | "status": "70d34f1f-dc8b-4d46-9a22-9dc3caf10ca1",
integration-1 | "tags": [],
integration-1 | "tenant": null,
integration-1 | "url": "http://nautobot:8000/api/circuits/circuits/e029fb08-1647-4772-b3ea-bb2290a8f845/"
integration-1 | },
integration-1 | "diff": {
integration-1 | "after": {},
integration-1 | "before": {}
integration-1 | },
integration-1 | "invocation": {
integration-1 | "module_args": {
integration-1 | "api_version": null,
integration-1 | "cid": "Test Circuit One",
integration-1 | "circuit_type": "Test Circuit Type",
integration-1 | "comments": null,
integration-1 | "commit_rate": null,
integration-1 | "custom_fields": null,
integration-1 | "description": null,
integration-1 | "install_date": null,
integration-1 | "provider": "Test Provider",
integration-1 | "query_params": null,
integration-1 | "state": "present",
integration-1 | "status": "Active",
integration-1 | "tags": null,
integration-1 | "tenant": null,
integration-1 | "token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
integration-1 | "url": "http://nautobot:8000",
integration-1 | "validate_certs": true
integration-1 | }
integration-1 | },
integration-1 | "msg": "circuit Test Circuit One updated"
integration-1 | }
where is no diff, but the entry was changed.
The last thing I would like to see is actually integration testing that this is true. Can you add an additional custom fields in the nautobot-populate.py file and then add it to the circuit integration tests?
Edit: It looks like we don't have an edit idempotent test in that file, so we should probably duplicate "PYNAUTOBOT_CIRCUIT 3: Update provider with other fields"
and then assert it doesn't change like we do in "PYNAUTOBOT_CIRCUIT 2: ASSERT - Create duplicate"
.
This should ensure that the custom_field is idempotent, even when only a subset of fields is written
backport of https://github.com/netbox-community/ansible_modules/pull/839