mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-02 06:25:37 +00:00
don't hard-code bradfitz or maisem in paths
Change-Id: Ie8c7591fac3800bb3b7f8c35356cce309fd3c164 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
24aedc2077
commit
2e90e9e9ef
@ -2,4 +2,4 @@ module gokrazy/build/tsapp
|
|||||||
|
|
||||||
go 1.22.2
|
go 1.22.2
|
||||||
|
|
||||||
require github.com/tailscale/gokrazy-kernel v0.0.0-20240530042707-3f95c886bcf2 // indirect
|
require github.com/tailscale/gokrazy-kernel v0.0.0-20240728225134-3d23beabda2e // indirect
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
github.com/tailscale/gokrazy-kernel v0.0.0-20240530042707-3f95c886bcf2 h1:xzf+cMvBJBcA/Av7OTWBa0Tjrbfcy00TeatJeJt6zrY=
|
github.com/tailscale/gokrazy-kernel v0.0.0-20240530042707-3f95c886bcf2 h1:xzf+cMvBJBcA/Av7OTWBa0Tjrbfcy00TeatJeJt6zrY=
|
||||||
github.com/tailscale/gokrazy-kernel v0.0.0-20240530042707-3f95c886bcf2/go.mod h1:7Mth+m9bq2IHusSsexMNyupHWPL8RxwOuSvBlSGtgDY=
|
github.com/tailscale/gokrazy-kernel v0.0.0-20240530042707-3f95c886bcf2/go.mod h1:7Mth+m9bq2IHusSsexMNyupHWPL8RxwOuSvBlSGtgDY=
|
||||||
|
github.com/tailscale/gokrazy-kernel v0.0.0-20240728225134-3d23beabda2e h1:tyUUgeRPGHjCZWycRnhdx8Lx9DRkjl3WsVUxYMrVBOw=
|
||||||
|
github.com/tailscale/gokrazy-kernel v0.0.0-20240728225134-3d23beabda2e/go.mod h1:7Mth+m9bq2IHusSsexMNyupHWPL8RxwOuSvBlSGtgDY=
|
||||||
|
@ -11,15 +11,18 @@
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/mod/modfile"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"tailscale.com/client/tailscale"
|
"tailscale.com/client/tailscale"
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/tstest/natlab/vnet"
|
"tailscale.com/tstest/natlab/vnet"
|
||||||
|
"tailscale.com/types/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type natTest struct {
|
type natTest struct {
|
||||||
@ -27,13 +30,27 @@ type natTest struct {
|
|||||||
base string // base image
|
base string // base image
|
||||||
tempDir string // for qcow2 images
|
tempDir string // for qcow2 images
|
||||||
vnet *vnet.Server
|
vnet *vnet.Server
|
||||||
|
kernel string // linux kernel path
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNatTest(tb testing.TB) *natTest {
|
func newNatTest(tb testing.TB) *natTest {
|
||||||
|
root, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
tb.Fatal(err)
|
||||||
|
}
|
||||||
|
modRoot := filepath.Join(root, "../../..")
|
||||||
|
|
||||||
|
linuxKernel, err := findKernelPath(filepath.Join(modRoot, "gokrazy/tsapp/builddir/github.com/tailscale/gokrazy-kernel/go.mod"))
|
||||||
|
if err != nil {
|
||||||
|
tb.Fatalf("findKernelPath: %v", err)
|
||||||
|
}
|
||||||
|
tb.Logf("found kernel: %v", linuxKernel)
|
||||||
|
|
||||||
nt := &natTest{
|
nt := &natTest{
|
||||||
tb: tb,
|
tb: tb,
|
||||||
tempDir: tb.TempDir(),
|
tempDir: tb.TempDir(),
|
||||||
base: "/Users/maisem/dev/tailscale.com/gokrazy/tsapp.qcow2",
|
base: filepath.Join(modRoot, "gokrazy/tsapp.qcow2"),
|
||||||
|
kernel: linuxKernel,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(nt.base); err != nil {
|
if _, err := os.Stat(nt.base); err != nil {
|
||||||
@ -42,6 +59,27 @@ func newNatTest(tb testing.TB) *natTest {
|
|||||||
return nt
|
return nt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findKernelPath(goMod string) (string, error) {
|
||||||
|
b, err := os.ReadFile(goMod)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
mf, err := modfile.Parse("go.mod", b, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
goModB, err := exec.Command("go", "env", "GOMODCACHE").CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
for _, r := range mf.Require {
|
||||||
|
if r.Mod.Path == "github.com/tailscale/gokrazy-kernel" {
|
||||||
|
return strings.TrimSpace(string(goModB)) + "/" + r.Mod.String() + "/vmlinuz", nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("failed to find kernel in %v", goMod)
|
||||||
|
}
|
||||||
|
|
||||||
type addNodeFunc func(c *vnet.Config) *vnet.Node
|
type addNodeFunc func(c *vnet.Config) *vnet.Node
|
||||||
|
|
||||||
func easy(c *vnet.Config) *vnet.Node {
|
func easy(c *vnet.Config) *vnet.Node {
|
||||||
@ -120,7 +158,7 @@ func (nt *natTest) runTest(node1, node2 addNodeFunc) {
|
|||||||
"-M", "microvm,isa-serial=off",
|
"-M", "microvm,isa-serial=off",
|
||||||
"-m", "1G",
|
"-m", "1G",
|
||||||
"-nodefaults", "-no-user-config", "-nographic",
|
"-nodefaults", "-no-user-config", "-nographic",
|
||||||
"-kernel", "/Users/maisem/dev/github.com/tailscale/gokrazy-kernel/vmlinuz",
|
"-kernel", nt.kernel,
|
||||||
"-append", "console=hvc0 root=PARTUUID=60c24cc1-f3f9-427a-8199-dd02023b0001/PARTNROFF=1 ro init=/gokrazy/init panic=10 oops=panic pci=off nousb tsc=unstable clocksource=hpet tailscale-tta=1",
|
"-append", "console=hvc0 root=PARTUUID=60c24cc1-f3f9-427a-8199-dd02023b0001/PARTNROFF=1 ro init=/gokrazy/init panic=10 oops=panic pci=off nousb tsc=unstable clocksource=hpet tailscale-tta=1",
|
||||||
"-drive", "id=blk0,file="+disk+",format=qcow2",
|
"-drive", "id=blk0,file="+disk+",format=qcow2",
|
||||||
"-device", "virtio-blk-device,drive=blk0",
|
"-device", "virtio-blk-device,drive=blk0",
|
||||||
@ -182,7 +220,7 @@ func (nt *natTest) runTest(node1, node2 addNodeFunc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
route, err := ping(ctx, lc1, sts[1].Self.TailscaleIPs[0])
|
route, err := ping(ctx, lc1, sts[1].Self.TailscaleIPs[0])
|
||||||
t.Logf("ping route: %v, %v", route, err)
|
t.Logf("ping route: %v, %v", logger.AsJSON(route), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ping(ctx context.Context, c *vnet.NodeAgentClient, target netip.Addr) (*ipnstate.PingResult, error) {
|
func ping(ctx context.Context, c *vnet.NodeAgentClient, target netip.Addr) (*ipnstate.PingResult, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user