Skip to content

Remove most of the iputils from tests #4342

Open
@Michal-Leszczynski

Description

@Michal-Leszczynski

So basically, SM handles IPV6 poorly, as in most places it stores IP addresses in string format and compares them as strings as well.
Since IPV6 does not have a unique string representation, it creates issues.

And what are we doing when a test fails beacuse of mismatch in IPV6 string representation?
We alter the test to use required representation instead of fixing SM implementation...

Functions like:

// ToCanonicalIP replaces ":0:0" in IPv6 addresses with "::"
// ToCanonicalIP("192.168.0.1") -> "192.168.0.1"
// ToCanonicalIP("100:200:0:0:0:0:0:1") -> "100:200::1".
func ToCanonicalIP(host string) string {
	val := net.ParseIP(host)
	if val == nil {
		return host
	}
	return val.String()
}

// ExpandIP expands IPv6 addresses "::" to ":0:0..."
// ToCanonicalIP("192.168.0.1") -> "192.168.0.1"
// ToCanonicalIP("100:200:0:0:0:0:0:1") -> "100:200::1".
func ExpandIP(host string) string {
	if !strings.Contains(host, "::") {
		return host
	}
	expected := 7
	existing := strings.Count(host, ":") - 1
	return strings.Replace(host, "::", strings.Repeat(":0", expected-existing)+":", 1)
}

Needs to be removed from our tests so that we are not hiding problems with IPV6 handling.
Obviously, SM implementation needs to be updated to handle those cases correctly.

Metadata

Metadata

Labels

bugSomething isn't workingtesting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions