add worker version to network graph (#2672)
* add worker version to network graph
This commit is contained in:
1 parent
601be14c12
commit
5b162a4433
5 files changed
+42
-10
No files matched your search
@@ -71,8 +71,8 @@ type downstreamWorkersTicker interface {
|
||||
// Controller.downstreamWorkers field which is far better than allowing any (empty
|
||||
// interface)
|
||||
type downstreamers interface {
|
||||
// Root returns the root of the downstreamers' graph
|
||||
Root() string
|
||||
// RootId returns the root ID of the downstreamers' graph
|
||||
RootId() string
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -60,8 +60,8 @@ type downstreamRouter interface {
|
||||
// Worker.downstreamWorkers field which is far better than allowing any (empty
|
||||
// interface)
|
||||
type downstreamers interface {
|
||||
// Root returns the root of the downstreamers' graph
|
||||
Root() string
|
||||
// RootId returns the root ID of the downstreamers' graph
|
||||
RootId() string
|
||||
}
|
||||
|
||||
// downstreamRouterFactory provides a simple factory which a Worker can use to
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/version"
|
||||
"github.com/hashicorp/nodeenrollment/types"
|
||||
)
|
||||
|
||||
@@ -39,12 +40,13 @@ type options struct {
|
||||
withTestPkiWorkerAuthorized bool
|
||||
withTestPkiWorkerKeyId *string
|
||||
withWorkerType WorkerType
|
||||
withRoot string
|
||||
withRoot RootInfo
|
||||
withStopAfter uint
|
||||
WithCreateControllerLedActivationToken bool
|
||||
withReleaseVersion string
|
||||
withOperationalState string
|
||||
withActiveWorkers bool
|
||||
withFeature version.Feature
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
@@ -180,10 +182,10 @@ func WithWorkerType(with WorkerType) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithRoot provides an optional root worker id.
|
||||
func WithRoot(workerId string) Option {
|
||||
// WithRoot provides an optional root node
|
||||
func WithRoot(root RootInfo) Option {
|
||||
return func(o *options) {
|
||||
o.withRoot = workerId
|
||||
o.withRoot = root
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,3 +223,10 @@ func WithActiveWorkers(withActive bool) Option {
|
||||
o.withActiveWorkers = withActive
|
||||
}
|
||||
}
|
||||
|
||||
// WithFeature provides an option to specify a filter
|
||||
func WithFeature(feature version.Feature) Option {
|
||||
return func(o *options) {
|
||||
o.withFeature = feature
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/version"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -167,8 +168,14 @@ func Test_GetOpts(t *testing.T) {
|
||||
t.Run("WithRoot", func(t *testing.T) {
|
||||
opts := getDefaultOptions()
|
||||
assert.Empty(t, opts.withRoot)
|
||||
opts = GetOpts(WithRoot("a"))
|
||||
assert.Equal(t, "a", opts.withRoot)
|
||||
opts = GetOpts(WithRoot(RootInfo{
|
||||
RootId: "a",
|
||||
RootVer: "0.1.0",
|
||||
}))
|
||||
assert.Equal(t, RootInfo{
|
||||
RootId: "a",
|
||||
RootVer: "0.1.0",
|
||||
}, opts.withRoot)
|
||||
})
|
||||
t.Run("WithStopAfter", func(t *testing.T) {
|
||||
opts := getDefaultOptions()
|
||||
@@ -202,4 +209,12 @@ func Test_GetOpts(t *testing.T) {
|
||||
opts = GetOpts(WithActiveWorkers(true))
|
||||
assert.Equal(t, true, opts.withActiveWorkers)
|
||||
})
|
||||
t.Run("WithFeature", func(t *testing.T) {
|
||||
opts := GetOpts(WithFeature(version.MultiHopSessionFeature))
|
||||
testOpts := getDefaultOptions()
|
||||
testOpts.withFeature = version.MultiHopSessionFeature
|
||||
opts.withNewIdFunc = nil
|
||||
testOpts.withNewIdFunc = nil
|
||||
assert.Equal(t, opts, testOpts)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package server
|
||||
|
||||
type RootInfo struct {
|
||||
// the ID for this node. For workers, this is workerId
|
||||
RootId string
|
||||
// the version of boundary the root is running
|
||||
RootVer string
|
||||
}
|
||||
Reference in new issue
Block a user