mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Decouple Scope lifecycle from Weave lifecycle
- Run the Weave integrations regardless of if weave is detected. - Make everything backoff and not spam the logs. - Add miekg dns to vendor. - Have the app periodically register with weaveDNS, and the probe do lookups there. - Decide what the local networks are at runtime, not once at startup. - Correctly resolve app ids, fixes #825
This commit is contained in:
@@ -60,6 +60,14 @@ func (c *mockCmd) Kill() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *mockCmd) Output() ([]byte, error) {
|
||||
return ioutil.ReadAll(c.ReadCloser)
|
||||
}
|
||||
|
||||
func (c *mockCmd) Run() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *blockingReader) Read(p []byte) (n int, err error) {
|
||||
<-b.quit
|
||||
return 0, nil
|
||||
|
||||
71
test/weave/mock.go
Normal file
71
test/weave/mock.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package weave
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/weaveworks/scope/common/weave"
|
||||
)
|
||||
|
||||
// Constants used for testing
|
||||
const (
|
||||
MockWeavePeerName = "winnebago"
|
||||
MockWeavePeerNickName = "winny"
|
||||
MockContainerID = "83183a667c01"
|
||||
MockContainerMAC = "d6:f2:5a:12:36:a8"
|
||||
MockContainerIP = "10.0.0.123"
|
||||
MockHostname = "hostname.weave.local"
|
||||
)
|
||||
|
||||
// MockClient is a mock version of weave.Client
|
||||
type MockClient struct{}
|
||||
|
||||
// Status implements weave.Client
|
||||
func (MockClient) Status() (weave.Status, error) {
|
||||
return weave.Status{
|
||||
Router: weave.Router{
|
||||
Peers: []struct {
|
||||
Name string
|
||||
NickName string
|
||||
}{
|
||||
{
|
||||
Name: MockWeavePeerName,
|
||||
NickName: MockWeavePeerNickName,
|
||||
},
|
||||
},
|
||||
},
|
||||
DNS: weave.DNS{
|
||||
Entries: []struct {
|
||||
Hostname string
|
||||
ContainerID string
|
||||
Tombstone int64
|
||||
}{
|
||||
{
|
||||
Hostname: MockHostname + ".",
|
||||
ContainerID: MockContainerID,
|
||||
Tombstone: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AddDNSEntry implements weave.Client
|
||||
func (MockClient) AddDNSEntry(fqdn, containerid string, ip net.IP) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PS implements weave.Client
|
||||
func (MockClient) PS() (map[string]weave.PSEntry, error) {
|
||||
return map[string]weave.PSEntry{
|
||||
MockContainerID: {
|
||||
ContainerIDPrefix: MockContainerID,
|
||||
MACAddress: MockContainerMAC,
|
||||
IPs: []string{MockContainerIP},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Expose implements weave.Client
|
||||
func (MockClient) Expose() error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user