Get integration test netmap from watch-ipn command (#1729)
This commit is contained in:
parent
3f162c212c
commit
5dbd59ca55
6 changed files with 244 additions and 34 deletions
|
@ -212,15 +212,9 @@ func (h *Headscale) handlePoll(
|
|||
return
|
||||
}
|
||||
|
||||
// TODO(kradalby): Figure out why patch changes does
|
||||
// not show up in output from `tailscale debug netmap`.
|
||||
// stateUpdate := types.StateUpdate{
|
||||
// Type: types.StatePeerChangedPatch,
|
||||
// ChangePatches: []*tailcfg.PeerChange{&change},
|
||||
// }
|
||||
stateUpdate := types.StateUpdate{
|
||||
Type: types.StatePeerChanged,
|
||||
ChangeNodes: types.Nodes{node},
|
||||
Type: types.StatePeerChangedPatch,
|
||||
ChangePatches: []*tailcfg.PeerChange{&change},
|
||||
}
|
||||
if stateUpdate.Valid() {
|
||||
ctx := types.NotifyCtx(context.Background(), "poll-nodeupdate-peers-patch", node.Hostname)
|
||||
|
|
13
hscontrol/util/util.go
Normal file
13
hscontrol/util/util.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package util
|
||||
|
||||
import "tailscale.com/util/cmpver"
|
||||
|
||||
func TailscaleVersionNewerOrEqual(minimum, toCheck string) bool {
|
||||
if cmpver.Compare(minimum, toCheck) <= 0 ||
|
||||
toCheck == "unstable" ||
|
||||
toCheck == "head" {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
95
hscontrol/util/util_test.go
Normal file
95
hscontrol/util/util_test.go
Normal file
|
@ -0,0 +1,95 @@
|
|||
package util
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTailscaleVersionNewerOrEqual(t *testing.T) {
|
||||
type args struct {
|
||||
minimum string
|
||||
toCheck string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "is-equal",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "1.56",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "is-newer-head",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "head",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "is-newer-unstable",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "unstable",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "is-newer-patch",
|
||||
args: args{
|
||||
minimum: "1.56.1",
|
||||
toCheck: "1.56.1",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "is-older-patch-same-minor",
|
||||
args: args{
|
||||
minimum: "1.56.1",
|
||||
toCheck: "1.56.0",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "is-older-unstable",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "1.55",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "is-older-one-stable",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "1.54",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "is-older-five-stable",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "1.46",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "is-older-patch",
|
||||
args: args{
|
||||
minimum: "1.56",
|
||||
toCheck: "1.48.1",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := TailscaleVersionNewerOrEqual(tt.args.minimum, tt.args.toCheck); got != tt.want {
|
||||
t.Errorf("TailscaleVersionNewerThan() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue