|
|
@ -53,22 +53,22 @@ func newNatTest(tb testing.TB) *natTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
modRoot := filepath.Join(root, "../../..")
|
|
|
|
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: filepath.Join(modRoot, "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 {
|
|
|
|
tb.Skipf("skipping test; base image %q not found", nt.base)
|
|
|
|
tb.Skipf("skipping test; base image %q not found", nt.base)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nt.kernel, err = findKernelPath(filepath.Join(modRoot, "gokrazy/tsapp/builddir/github.com/tailscale/gokrazy-kernel/go.mod"))
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
tb.Skipf("skipping test; kernel not found: %v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tb.Logf("found kernel: %v", nt.kernel)
|
|
|
|
|
|
|
|
|
|
|
|
return nt
|
|
|
|
return nt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -388,67 +388,54 @@ func up(ctx context.Context, c *vnet.NodeAgentClient) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyEasy(t *testing.T) {
|
|
|
|
type nodeType struct {
|
|
|
|
nt := newNatTest(t)
|
|
|
|
name string
|
|
|
|
nt.runTest(easy, easy)
|
|
|
|
fn addNodeFunc
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyHard(t *testing.T) {
|
|
|
|
|
|
|
|
nt := newNatTest(t)
|
|
|
|
|
|
|
|
nt.runTest(easy, hard)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyAFHard(t *testing.T) {
|
|
|
|
var types = []nodeType{
|
|
|
|
nt := newNatTest(t)
|
|
|
|
{"easy", easy},
|
|
|
|
nt.runTest(easyAF, hard)
|
|
|
|
{"easyAF", easyAF},
|
|
|
|
}
|
|
|
|
{"hard", hard},
|
|
|
|
|
|
|
|
{"easyPMP", easyPMP},
|
|
|
|
func TestEasyHardPMP(t *testing.T) {
|
|
|
|
{"hardPMP", hardPMP},
|
|
|
|
nt := newNatTest(t)
|
|
|
|
{"one2one", one2one},
|
|
|
|
nt.runTest(easy, hardPMP)
|
|
|
|
{"sameLAN", sameLAN},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyPMPHard(t *testing.T) {
|
|
|
|
func TestEasyEasy(t *testing.T) {
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt.runTest(easyPMP, hard)
|
|
|
|
nt.runTest(easy, easy)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestHardHardPMP(t *testing.T) {
|
|
|
|
var pair = flag.String("pair", "", "comma-separated pair of types to test (easy, easyAF, hard, easyPMP, hardPMP, one2one, sameLAN)")
|
|
|
|
nt := newNatTest(t)
|
|
|
|
|
|
|
|
nt.runTest(hard, hardPMP)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestHardHard(t *testing.T) {
|
|
|
|
func TestPair(t *testing.T) {
|
|
|
|
nt := newNatTest(t)
|
|
|
|
t1, t2, ok := strings.Cut(*pair, ",")
|
|
|
|
nt.runTest(hard, hard)
|
|
|
|
if !ok {
|
|
|
|
}
|
|
|
|
t.Skipf("skipping test without --pair=type1,type2 set")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
find := func(name string) addNodeFunc {
|
|
|
|
|
|
|
|
for _, nt := range types {
|
|
|
|
|
|
|
|
if nt.name == name {
|
|
|
|
|
|
|
|
return nt.fn
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Fatalf("unknown type %q", name)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyOne2One(t *testing.T) {
|
|
|
|
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt.runTest(easy, one2one)
|
|
|
|
nt.runTest(find(t1), find(t2))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestHardOne2One(t *testing.T) {
|
|
|
|
var runGrid = flag.Bool("run-grid", false, "run grid test")
|
|
|
|
nt := newNatTest(t)
|
|
|
|
|
|
|
|
nt.runTest(hard, one2one)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestGrid(t *testing.T) {
|
|
|
|
func TestGrid(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
if !*runGrid {
|
|
|
|
|
|
|
|
t.Skip("skipping grid test; set --run-grid to run")
|
|
|
|
type nodeType struct {
|
|
|
|
|
|
|
|
name string
|
|
|
|
|
|
|
|
fn addNodeFunc
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
types := []nodeType{
|
|
|
|
|
|
|
|
{"easy", easy},
|
|
|
|
|
|
|
|
{"easyAF", easyAF},
|
|
|
|
|
|
|
|
{"hard", hard},
|
|
|
|
|
|
|
|
{"easyPMP", easyPMP},
|
|
|
|
|
|
|
|
{"hardPMP", hardPMP},
|
|
|
|
|
|
|
|
{"one2one", one2one},
|
|
|
|
|
|
|
|
{"sameLAN", sameLAN},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
|
|
|
|
sem := syncs.NewSemaphore(2)
|
|
|
|
sem := syncs.NewSemaphore(2)
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|