1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

Dotf fixes 3 (#820)

* [beta] IX-F importer: [showstopper]: Seeing 'Update' hint instead of 'Add' hint #816

* [beta] IX-F importer: list of hints should be case-independently sorted alphabetically #817

* [beta] IX-F importer: IX "Last Updated" timestamp is based on IX-F import time - not sure that is intended #812

* Improve soft delete error handling re: protectedactions

* Fix template bug

* Modify template again

* add a test to confirm ipaddr suggestions end up in template

* rebase #817 into this and adapt to changes in #817

* [beta] IX-F importer: notice about dismissed hints remains after no longer relevant #809

* Server Error 500 when deleting organisations #798

* black formatting

Co-authored-by: Stefan Pratter <stefan@20c.com>
Co-authored-by: egfrank <elliot@20c.com>
This commit is contained in:
Matt Griswold
2020-08-18 09:30:40 -05:00
committed by GitHub
parent ac047fa0bc
commit 31a0f886a7
9 changed files with 462 additions and 48 deletions

View File

@@ -90,6 +90,7 @@ def test_update_data_attributes(entities, use_ip, save):
data = setup_test_data("ixf.member.0")
network = entities["net"]["UPDATE_ENABLED"]
ixlan = entities["ixlan"][0]
ix_updated = ixlan.ix.updated
with reversion.create_revision():
entities["netixlan"].append(
@@ -114,10 +115,12 @@ def test_update_data_attributes(entities, use_ip, save):
importer.update(ixlan, data=data)
importer.notify_proposals()
assert IXFMemberData.objects.count() == 0
# assert that the exchange's `updated` field was not
# altered by the import (#812)
ixlan.ix.refresh_from_db()
assert ixlan.ix.updated == ix_updated
print(importer.log)
print(use_ip(4), use_ip(6))
assert IXFMemberData.objects.count() == 0
if (network.ipv4_support and not use_ip(4)) or (
network.ipv6_support and not use_ip(6)
@@ -474,6 +477,8 @@ def test_add_netixlan(entities, use_ip, save):
network = entities["net"]["UPDATE_ENABLED"]
ixlan = entities["ixlan"][0]
ix_updated = ixlan.ix.updated
importer = ixf.Importer()
if not save:
@@ -482,6 +487,11 @@ def test_add_netixlan(entities, use_ip, save):
importer.update(ixlan, data=data)
importer.notify_proposals()
# assert that the exchange's `updated` field was not
# altered by the import (#812)
ixlan.ix.refresh_from_db()
assert ixlan.ix.updated == ix_updated
log = importer.log["data"][0]
assert log["action"] == "add"
assert NetworkIXLan.objects.count() == 1
@@ -709,6 +719,7 @@ def test_suggest_add_local_ixf(entities, use_ip, save):
data = setup_test_data("ixf.member.3")
network = entities["net"]["UPDATE_DISABLED"]
ixlan = entities["ixlan"][0]
ix_updated = ixlan.ix.updated
# This appears in the remote-ixf data so should not
# create a IXFMemberData instance
@@ -751,6 +762,12 @@ def test_suggest_add_local_ixf(entities, use_ip, save):
importer.update(ixlan, data=data)
importer.notify_proposals()
# assert that the exchange's `updated` field was not
# altered by the import (#812)
ixlan.ix.refresh_from_db()
assert ixlan.ix.updated == ix_updated
if (not network.ipv4_support and use_ip(4) and not use_ip(6)) or (
not network.ipv6_support and use_ip(6) and not use_ip(4)
):
@@ -1213,6 +1230,48 @@ def test_single_ipaddr_matches_no_auto_update(entities, use_ip, save):
# Test idempotent
assert_idempotent(importer, ixlan, data)
@pytest.mark.django_db
def test_816_edge_case(entities, use_ip, save):
"""
Test that #770 protocol only triggers when the
depending deletion is towards the same asn AND
not already handled (dependency == noop)
"""
data = setup_test_data("ixf.member.1")
network = entities["net"]["UPDATE_DISABLED_2"]
ixlan = entities["ixlan"][0]
entities["netixlan"].append(
NetworkIXLan.objects.create(
network=network,
ixlan=ixlan,
asn=network.asn,
speed=10000,
ipaddr4=use_ip(4, "195.69.147.250"),
ipaddr6=use_ip(6, "2001:7f8:1::a500:2906:1"),
status="ok",
is_rs_peer=True,
operational=True,
)
)
importer = ixf.Importer()
if not save:
return assert_idempotent(importer, ixlan, data, save=False)
importer.update(ixlan, data=data)
importer.notify_proposals()
assert IXFMemberData.objects.count() == 2
assert IXFMemberData.objects.get(asn=1001).action == "add"
assert IXFImportEmail.objects.filter(net__asn=1001, message__contains='CREATE').exists()
assert not IXFImportEmail.objects.filter(net__asn=1001, message__contains='MODIFY').exists()
# Test idempotent
assert_idempotent(importer, ixlan, data)
@pytest.mark.django_db
def test_two_missing_ipaddrs_no_auto_update(entities, save):
@@ -1341,6 +1400,7 @@ def test_delete(entities, save):
data = setup_test_data("ixf.member.0")
network = entities["net"]["UPDATE_ENABLED"]
ixlan = entities["ixlan"][0]
ix_updated = ixlan.ix.updated
with reversion.create_revision():
entities["netixlan"].append(
@@ -1379,6 +1439,11 @@ def test_delete(entities, save):
importer.update(ixlan, data=data)
importer.notify_proposals()
# assert that the exchange's `updated` field was not
# altered by the import (#812)
ixlan.ix.refresh_from_db()
assert ixlan.ix.updated == ix_updated
assert len(importer.log["data"]) == 1
log = importer.log["data"][0]
@@ -2335,6 +2400,20 @@ def entities_base():
info_unicast=True,
info_ipv6=True,
),
"UPDATE_DISABLED_2": Network.objects.create(
name="Network w allow ixp update disabled (2)",
org=entities["org"][0],
asn=1101,
allow_ixp_update=False,
status="ok",
info_prefixes4=42,
info_prefixes6=42,
website="http://netflix.com/",
policy_general="Open",
policy_url="https://www.netflix.com/openconnect/",
info_unicast=True,
info_ipv6=True,
),
}
entities["netcontact"] = [