kubernetes-sigs / ip-masq-agent

Manage IP masquerade on nodes
Apache License 2.0
217 stars 70 forks source link

make test is broken at head #107

Closed MrHohn closed 1 year ago

MrHohn commented 1 year ago

Thanks to @ramkumar-k for noticing this - we found out ip-masq-agent unit test is broken with the below error:

$ make test
Running tests:
# k8s.io/ip-masq-agent/cmd/ip-masq-agent [k8s.io/ip-masq-agent/cmd/ip-masq-agent.test]
cmd/ip-masq-agent/ip-masq-agent_test.go:322:19: fipt.Lines undefined (type *"k8s.io/kubernetes/pkg/util/iptables/testing".FakeIPTables has no field or method Lines)
cmd/ip-masq-agent/ip-masq-agent_test.go:323:61: fipt.Lines undefined (type *"k8s.io/kubernetes/pkg/util/iptables/testing".FakeIPTables has no field or method Lines)
cmd/ip-masq-agent/ip-masq-agent_test.go:384:20: fipt6.Lines undefined (type *"k8s.io/kubernetes/pkg/util/iptables/testing".FakeIPTables has no field or method Lines)
cmd/ip-masq-agent/ip-masq-agent_test.go:385:66: fipt6.Lines undefined (type *"k8s.io/kubernetes/pkg/util/iptables/testing".FakeIPTables has no field or method Lines)
?       k8s.io/ip-masq-agent/cmd/ip-masq-agent/testing/fakefs   [no test files]
?       k8s.io/ip-masq-agent/pkg/version        [no test files]
FAIL    k8s.io/ip-masq-agent/cmd/ip-masq-agent [build failed]
FAIL
make: *** [Makefile:349: test] Error 1

This seems to be introduced because of an upstream change in Kubernetes, where iptables/testing/fake.go got revamped: https://github.com/kubernetes/kubernetes/pull/109844

cc @jingyuanliang

Ramkumar-K commented 1 year ago

The fix seems to involve the following:

  1. Convert fipt.Lines to fipt.Dump.String() in ip-masq-agent_test.go
  2. In FakeIPTables, add this line "f.Dump = dump" to end of the RestoreAll function
Ramkumar-K commented 1 year ago

PR https://github.com/kubernetes-sigs/ip-masq-agent/pull/108 addresses this