Remove obsolete methods
This commit is contained in:
1 parent
66de361fd6
commit
30447ada52
4 files changed
+20
-52
No files matched your search
@@ -87,12 +87,7 @@ func (mz *mockedZoneWithRecords) DeleteRecords(ident string, name string, ip net
|
||||
notImplWarn()
|
||||
return 0
|
||||
}
|
||||
func (mz *mockedZoneWithRecords) DeleteRecord(ident string, ip net.IP) error {
|
||||
notImplWarn()
|
||||
return nil
|
||||
}
|
||||
func (mz *mockedZoneWithRecords) DeleteRecordsFor(ident string) error { notImplWarn(); return nil }
|
||||
func (mz *mockedZoneWithRecords) Status() string { notImplWarn(); return "nothing" }
|
||||
func (mz *mockedZoneWithRecords) Status() string { notImplWarn(); return "nothing" }
|
||||
func (mz *mockedZoneWithRecords) ObserveName(name string, observer ZoneRecordObserver) error {
|
||||
notImplWarn()
|
||||
return nil
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestServerDbCacheInvalidation(t *testing.T) {
|
||||
q, _ = assertExchange(t, testName1, dns.TypeA, testPort, 3, 4, 0)
|
||||
assertInCache(t, cache, q, "after asking about the name")
|
||||
Debug.Printf("... and removing one of the IP addresses")
|
||||
zone.DeleteRecord(containerID, net.ParseIP("10.2.2.2"))
|
||||
zone.DeleteRecords(containerID, "", net.ParseIP("10.2.2.2"))
|
||||
assertNotInCache(t, cache, q, "after deleting IP for 10.2.2.2")
|
||||
|
||||
// Zone database at this point:
|
||||
@@ -125,7 +125,7 @@ func TestServerDbCacheInvalidation(t *testing.T) {
|
||||
|
||||
// now we will check if a removal affects all the responses
|
||||
Debug.Printf("... and removing an IP should invalidate both the cached responses for name and raddr")
|
||||
zone.DeleteRecord(containerID, net.ParseIP("10.2.2.1"))
|
||||
zone.DeleteRecords(containerID, "", net.ParseIP("10.2.2.1"))
|
||||
assertNotInCache(t, cache, qptr, "after deleting record")
|
||||
assertNotInCache(t, cache, qname, "after deleting record")
|
||||
assertInCache(t, cache, qotherName, "after deleting record")
|
||||
@@ -161,7 +161,7 @@ func TestServerDbCacheInvalidation(t *testing.T) {
|
||||
// first.weave.local = 10.2.2.3 10.2.2.7
|
||||
// second.weave.local = 10.9.9.1
|
||||
|
||||
zone.DeleteRecordsFor(containerID)
|
||||
zone.DeleteRecords(containerID, "", net.IP{})
|
||||
assertNotInCache(t, cache, qotherName, "after removing container")
|
||||
assertNotInCache(t, cache, qotherPtr, "after removing container")
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func TestServerCacheExpiration(t *testing.T) {
|
||||
|
||||
// We delete the IP in the second peer right after
|
||||
Debug.Printf("Removing the IPs from %s in database #2", testName1)
|
||||
dbs[1].Zone.DeleteRecord(containerID, net.ParseIP("10.2.2.1"))
|
||||
dbs[1].Zone.DeleteRecords(containerID, "", net.ParseIP("10.2.2.1"))
|
||||
|
||||
// Check that we return to the initial state: a neg-local entry in the cache
|
||||
qName1, _ = assertExchange(t, testName1, dns.TypeA, testPort, 0, 0, dns.RcodeNameError)
|
||||
@@ -329,8 +329,8 @@ func TestServerCacheRefresh(t *testing.T) {
|
||||
assertNotLocalInCache(t, cache, qName2, "after asking for a unknown name")
|
||||
|
||||
// delete the IPs, and some time passes by so the cache should be purged...
|
||||
dbs[1].Zone.DeleteRecord(containerID, net.ParseIP("10.2.2.1"))
|
||||
dbs[1].Zone.DeleteRecord(containerID, net.ParseIP("10.2.2.2"))
|
||||
dbs[1].Zone.DeleteRecords(containerID, "", net.ParseIP("10.2.2.1"))
|
||||
dbs[1].Zone.DeleteRecords(containerID, "", net.ParseIP("10.2.2.2"))
|
||||
clk.Forward(refreshInterval + 1)
|
||||
|
||||
qName1, _ = assertExchange(t, testName1, dns.TypeA, testPort, 0, 0, dns.RcodeNameError)
|
||||
|
||||
+2
-31
@@ -51,10 +51,6 @@ type Zone interface {
|
||||
AddRecord(ident string, name string, ip net.IP) error
|
||||
// Delete matching records (uninitialised values act as wildcards)
|
||||
DeleteRecords(ident string, name string, ip net.IP) (count int)
|
||||
// Delete a record in the local database
|
||||
DeleteRecord(ident string, ip net.IP) error
|
||||
// Delete all records for an ident in the local database
|
||||
DeleteRecordsFor(ident string) error
|
||||
// Lookup for a name in the whole domain
|
||||
DomainLookupName(name string) ([]ZoneRecord, error)
|
||||
// Lookup for an address in the whole domain
|
||||
@@ -635,32 +631,6 @@ func (zone *ZoneDb) DeleteRecords(ident string, name string, ip net.IP) int {
|
||||
return count
|
||||
}
|
||||
|
||||
// Delete all records for an ident
|
||||
func (zone *ZoneDb) DeleteRecordsFor(ident string) (err error) {
|
||||
zone.mx.Lock()
|
||||
defer zone.mx.Unlock()
|
||||
Debug.Printf("[zonedb] Deleting records for ident '%s'", ident)
|
||||
zone.deleteIdent(ident)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete an IP in a ident
|
||||
func (zone *ZoneDb) DeleteRecord(ident string, ip net.IP) (err error) {
|
||||
zone.mx.Lock()
|
||||
defer zone.mx.Unlock()
|
||||
|
||||
Debug.Printf("[zonedb] Deleting record '%s'/[%s]", ident, ip)
|
||||
if _, found := zone.idents[ident]; found {
|
||||
err = zone.idents[ident].deleteIP(ipToIPv4(ip))
|
||||
if zone.idents[ident].empty() {
|
||||
zone.deleteIdent(ident)
|
||||
}
|
||||
} else {
|
||||
err = LookupError(ident)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Observe a name.
|
||||
// The name must have at least one valid IP address.
|
||||
// Name observers are notified when
|
||||
@@ -727,7 +697,8 @@ func (zone *ZoneDb) String() string {
|
||||
// Notify that a container has died
|
||||
func (zone *ZoneDb) ContainerDied(ident string) error {
|
||||
Info.Printf("[zonedb] Container %s down. Removing records", ident)
|
||||
return zone.DeleteRecordsFor(ident)
|
||||
zone.DeleteRecords(ident, "", net.IP{})
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return true if a remote name is still relevant
|
||||
|
||||
+11
-9
@@ -98,8 +98,8 @@ func TestZone(t *testing.T) {
|
||||
|
||||
t.Logf("Zone database:\n%s", zone)
|
||||
t.Logf("Deleting the %s in %s", ip1, container1)
|
||||
err = zone.DeleteRecord(container1, ip1)
|
||||
wt.AssertNoErr(t, err)
|
||||
count := zone.DeleteRecords(container1, "", ip1)
|
||||
wt.AssertEqualInt(t, count, 1, "delete failed")
|
||||
t.Logf("Zone database:\n%s", zone)
|
||||
|
||||
t.Logf("Checking %s's observers have been notified on removal", name1)
|
||||
@@ -114,19 +114,20 @@ func TestZone(t *testing.T) {
|
||||
|
||||
t.Logf("Checking %s is not found after removing %s it in %s and %s in %s",
|
||||
name1, ip1, container2, ip2, container1)
|
||||
err = zone.DeleteRecord(container1, ip2)
|
||||
err = zone.DeleteRecord(container2, ip1)
|
||||
wt.AssertNoErr(t, err)
|
||||
count = zone.DeleteRecords(container1, "", ip2)
|
||||
wt.AssertEqualInt(t, count, 1, "delete failed")
|
||||
count = zone.DeleteRecords(container2, "", ip1)
|
||||
wt.AssertEqualInt(t, count, 1, "delete failed")
|
||||
t.Logf("Zone database:\n%s", zone)
|
||||
_, err = zone.LookupName(name1)
|
||||
wt.AssertErrorType(t, err, (*LookupError)(nil), "after deleting record")
|
||||
|
||||
t.Logf("Checking if removing an unknown record results in an error")
|
||||
err = zone.DeleteRecord(container1, net.ParseIP("0.0.0.0"))
|
||||
wt.AssertErrorType(t, err, (*LookupError)(nil), "when deleting record that doesn't exist")
|
||||
count = zone.DeleteRecords(container1, "", net.ParseIP("0.0.0.0"))
|
||||
wt.AssertEqualInt(t, count, 0, "delete failed")
|
||||
}
|
||||
|
||||
func TestDeleteFor(t *testing.T) {
|
||||
func TestDeleteRecords(t *testing.T) {
|
||||
var (
|
||||
id = "foobar"
|
||||
name = "foo.weave."
|
||||
@@ -151,7 +152,8 @@ func TestDeleteFor(t *testing.T) {
|
||||
_, err = zone.LookupName(name)
|
||||
wt.AssertNoErr(t, err)
|
||||
|
||||
err = zone.DeleteRecordsFor(id)
|
||||
count := zone.DeleteRecords(id, "", net.IP{})
|
||||
wt.AssertEqualInt(t, count, 2, "wildcard delete failed")
|
||||
_, err = zone.LookupName(name)
|
||||
wt.AssertErrorType(t, err, (*LookupError)(nil), "after deleting records for ident")
|
||||
}
|
||||
Reference in new issue
Block a user