Remove unused code
This commit is contained in:
1 parent
00623be8a7
commit
df52117bfa
12 files changed
-100
No files matched your search
@@ -207,21 +207,6 @@ func (alloc *Allocator) doOperation(op operation, ops *[]operation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given an operation, remove it from the pending queue
|
|
||||||
// Note the op may not be on the queue; it may have
|
|
||||||
// already succeeded. If it is on the queue, we call
|
|
||||||
// cancel on it, allowing callers waiting for the resultChans
|
|
||||||
// to unblock.
|
|
||||||
func (alloc *Allocator) cancelOp(opToCancel operation, ops *[]operation) {
|
|
||||||
for i, op := range *ops {
|
|
||||||
if op == opToCancel {
|
|
||||||
*ops = append((*ops)[:i], (*ops)[i+1:]...)
|
|
||||||
op.Cancel()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel all operations in a queue
|
// Cancel all operations in a queue
|
||||||
func (alloc *Allocator) cancelOps(ops *[]operation) {
|
func (alloc *Allocator) cancelOps(ops *[]operation) {
|
||||||
for _, op := range *ops {
|
for _, op := range *ops {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
testStart1 = "10.0.1.0"
|
testStart1 = "10.0.1.0"
|
||||||
testStart2 = "10.0.2.0"
|
|
||||||
testStart3 = "10.0.3.0"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func returnFalse() bool { return false }
|
func returnFalse() bool { return false }
|
||||||
|
|||||||
@@ -56,16 +56,6 @@ func (m *Model) addLink(a, b *TestNode) {
|
|||||||
m.readyLinks = append(m.readyLinks, &ab, &ba)
|
m.readyLinks = append(m.readyLinks, &ab, &ba)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) linkExists(a, b *TestNode) bool {
|
|
||||||
for _, l := range a.links {
|
|
||||||
if l.to == b {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
type TestParams struct {
|
type TestParams struct {
|
||||||
// Number of nodes
|
// Number of nodes
|
||||||
nodeCount uint
|
nodeCount uint
|
||||||
|
|||||||
@@ -24,14 +24,6 @@ func (m *mockMessage) String() string {
|
|||||||
return fmt.Sprintf("-> %s [%x]", m.dst, m.buf)
|
return fmt.Sprintf("-> %s [%x]", m.dst, m.buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toStringArray(messages []mockMessage) []string {
|
|
||||||
out := make([]string, len(messages))
|
|
||||||
for i := range out {
|
|
||||||
out[i] = messages[i].String()
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
type mockGossipComms struct {
|
type mockGossipComms struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
*testing.T
|
*testing.T
|
||||||
@@ -100,14 +92,6 @@ func (m *mockGossipComms) GossipUnicast(dstPeerName mesh.PeerName, buf []byte) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExpectMessage(alloc *Allocator, dst string, msgType byte, buf []byte) {
|
|
||||||
m := alloc.gossip.(*mockGossipComms)
|
|
||||||
dstPeerName, _ := mesh.PeerNameFromString(dst)
|
|
||||||
m.Lock()
|
|
||||||
m.messages = append(m.messages, mockMessage{dstPeerName, msgType, buf})
|
|
||||||
m.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExpectBroadcastMessage(alloc *Allocator, buf []byte) {
|
func ExpectBroadcastMessage(alloc *Allocator, buf []byte) {
|
||||||
m := alloc.gossip.(*mockGossipComms)
|
m := alloc.gossip.(*mockGossipComms)
|
||||||
m.Lock()
|
m.Lock()
|
||||||
@@ -208,15 +192,6 @@ func AssertNothingSent(t *testing.T, ch <-chan bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AssertNothingSentErr(t *testing.T, ch <-chan error) {
|
|
||||||
select {
|
|
||||||
case val := <-ch:
|
|
||||||
require.FailNow(t, fmt.Sprintf("Unexpected value on channel: %v", val))
|
|
||||||
default:
|
|
||||||
// no message received
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeNetworkOfAllocators(size int, cidr string, preClaims ...[]PreClaim) ([]*Allocator, *gossip.TestRouter, address.CIDR) {
|
func makeNetworkOfAllocators(size int, cidr string, preClaims ...[]PreClaim) ([]*Allocator, *gossip.TestRouter, address.CIDR) {
|
||||||
gossipRouter := gossip.NewTestRouter(0.0)
|
gossipRouter := gossip.NewTestRouter(0.0)
|
||||||
allocs := make([]*Allocator, size)
|
allocs := make([]*Allocator, size)
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ func TestTruncation(t *testing.T) {
|
|||||||
defer dnsserver.Stop()
|
defer dnsserver.Stop()
|
||||||
|
|
||||||
// Add 100 mappings to nameserver
|
// Add 100 mappings to nameserver
|
||||||
addrs := []address.Address{}
|
|
||||||
for i := address.Address(0); i < 100; i++ {
|
for i := address.Address(0); i < 100; i++ {
|
||||||
addrs = append(addrs, i)
|
|
||||||
nameserver.AddEntry("foo.weave.local.", "", mesh.UnknownPeerName, i)
|
nameserver.AddEntry("foo.weave.local.", "", mesh.UnknownPeerName, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -430,14 +430,6 @@ func (ipsec *IPSec) removeDropNonEncrypted(srcIP, dstIP net.IP, udpPort int, inS
|
|||||||
return ipsec.resetRules(rules, true)
|
return ipsec.resetRules(rules, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ipsec *IPSec) removeDropNonEncryptedInbound(srcIP, dstIP net.IP, inSPI SPI) error {
|
|
||||||
r := ruleMarkInboundESP(srcIP, dstIP, inSPI)
|
|
||||||
if err := ipsec.ipt.Delete(r.table, r.chain, r.rulespec...); err != nil {
|
|
||||||
return errors.Wrap(err, fmt.Sprintf("iptables delete unique (%s, %s, %s)", r.table, r.chain, r.rulespec))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// xfrm
|
// xfrm
|
||||||
|
|
||||||
func xfrmAllocSpiState(srcIP, dstIP net.IP) *netlink.XfrmState {
|
func xfrmAllocSpiState(srcIP, dstIP net.IP) *netlink.XfrmState {
|
||||||
|
|||||||
@@ -158,13 +158,6 @@ func (ns *ns) addToDefaultAllowIfNoMatching(pod *coreapi.Pod, policyType policyT
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ns *ns) checkLocalPod(obj *coreapi.Pod) bool {
|
|
||||||
if obj.Spec.NodeName != ns.nodeName {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ns *ns) addPod(obj *coreapi.Pod) error {
|
func (ns *ns) addPod(obj *coreapi.Pod) error {
|
||||||
ns.pods[uid(obj)] = obj
|
ns.pods[uid(obj)] = obj
|
||||||
|
|
||||||
|
|||||||
@@ -201,24 +201,6 @@ func (listener *listener) leaveEndpoint(w http.ResponseWriter, r *http.Request)
|
|||||||
emptyOrErrorResponse(w, listener.d.LeaveEndpoint(&l))
|
emptyOrErrorResponse(w, listener.d.LeaveEndpoint(&l))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (listener *listener) discoverNew(w http.ResponseWriter, r *http.Request) {
|
|
||||||
var disco api.DiscoveryNotification
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&disco); err != nil {
|
|
||||||
sendError(w, "Could not decode JSON encoded payload", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
emptyOrErrorResponse(w, listener.d.DiscoverNew(&disco))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (listener *listener) discoverDelete(w http.ResponseWriter, r *http.Request) {
|
|
||||||
var disco api.DiscoveryNotification
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&disco); err != nil {
|
|
||||||
sendError(w, "Could not decode JSON encoded payload", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
emptyOrErrorResponse(w, listener.d.DiscoverDelete(&disco))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===
|
// ===
|
||||||
|
|
||||||
func (listener *listener) getIpamCapabilities(w http.ResponseWriter, r *http.Request) {
|
func (listener *listener) getIpamCapabilities(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ const (
|
|||||||
peerName3 = "03:00:00:00:00:00"
|
peerName3 = "03:00:00:00:00:00"
|
||||||
nodeName1 = "fake-node-1"
|
nodeName1 = "fake-node-1"
|
||||||
nodeName2 = "fake-node-2"
|
nodeName2 = "fake-node-2"
|
||||||
|
|
||||||
testIters = 1000
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPeerListBasic(t *testing.T) {
|
func TestPeerListBasic(t *testing.T) {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*")
|
containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*")
|
||||||
weaveWaitEntrypoint = []string{"/w/w"}
|
weaveWaitEntrypoint = []string{"/w/w"}
|
||||||
weaveEntrypoint = "/home/weave/weaver"
|
|
||||||
weaveContainerName = "/weave"
|
|
||||||
|
|
||||||
Log = common.Log
|
Log = common.Log
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ const (
|
|||||||
caCertPath = "ca.pem"
|
caCertPath = "ca.pem"
|
||||||
clientKeyPath = "key.pem"
|
clientKeyPath = "key.pem"
|
||||||
clientCertPath = "cert.pem"
|
clientCertPath = "cert.pem"
|
||||||
serverKeyPath = "server-key.pem"
|
|
||||||
serverCertPath = "server.pem"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -29,12 +28,6 @@ func AssertErrorType(t *testing.T, expected interface{}, actual error, desc stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func stackTrace(all bool) string {
|
|
||||||
buf := make([]byte, 1<<20)
|
|
||||||
stacklen := runtime.Stack(buf, all)
|
|
||||||
return string(buf[:stacklen])
|
|
||||||
}
|
|
||||||
|
|
||||||
// TrimTestArgs finds the first -- in os.Args and trim all args before
|
// TrimTestArgs finds the first -- in os.Args and trim all args before
|
||||||
// that, returning true when a -- was in fact found.
|
// that, returning true when a -- was in fact found.
|
||||||
func TrimTestArgs() bool {
|
func TrimTestArgs() bool {
|
||||||
|
|||||||
Reference in new issue
Block a user