|
|
@ -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) {
|
|
|
|
var types = []nodeType{
|
|
|
|
nt := newNatTest(t)
|
|
|
|
{"easy", easy},
|
|
|
|
nt.runTest(easy, hard)
|
|
|
|
{"easyAF", easyAF},
|
|
|
|
|
|
|
|
{"hard", hard},
|
|
|
|
|
|
|
|
{"easyPMP", easyPMP},
|
|
|
|
|
|
|
|
{"hardPMP", hardPMP},
|
|
|
|
|
|
|
|
{"one2one", one2one},
|
|
|
|
|
|
|
|
{"sameLAN", sameLAN},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyAFHard(t *testing.T) {
|
|
|
|
func TestEasyEasy(t *testing.T) {
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt.runTest(easyAF, hard)
|
|
|
|
nt.runTest(easy, easy)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyHardPMP(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(easy, hardPMP)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestEasyPMPHard(t *testing.T) {
|
|
|
|
func TestPair(t *testing.T) {
|
|
|
|
nt := newNatTest(t)
|
|
|
|
t1, t2, ok := strings.Cut(*pair, ",")
|
|
|
|
nt.runTest(easyPMP, hard)
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
t.Skipf("skipping test without --pair=type1,type2 set")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
find := func(name string) addNodeFunc {
|
|
|
|
func TestHardHardPMP(t *testing.T) {
|
|
|
|
for _, nt := range types {
|
|
|
|
nt := newNatTest(t)
|
|
|
|
if nt.name == name {
|
|
|
|
nt.runTest(hard, hardPMP)
|
|
|
|
return nt.fn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestHardHard(t *testing.T) {
|
|
|
|
|
|
|
|
nt := newNatTest(t)
|
|
|
|
|
|
|
|
nt.runTest(hard, hard)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Fatalf("unknown type %q", name)
|
|
|
|
func TestEasyOne2One(t *testing.T) {
|
|
|
|
return nil
|
|
|
|
nt := newNatTest(t)
|
|
|
|
|
|
|
|
nt.runTest(easy, one2one)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestHardOne2One(t *testing.T) {
|
|
|
|
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt := newNatTest(t)
|
|
|
|
nt.runTest(hard, one2one)
|
|
|
|
nt.runTest(find(t1), find(t2))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestGrid(t *testing.T) {
|
|
|
|
var runGrid = flag.Bool("run-grid", false, "run grid test")
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type nodeType struct {
|
|
|
|
func TestGrid(t *testing.T) {
|
|
|
|
name string
|
|
|
|
if !*runGrid {
|
|
|
|
fn addNodeFunc
|
|
|
|
t.Skip("skipping grid test; set --run-grid to run")
|
|
|
|
}
|
|
|
|
|
|
|
|
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 (
|
|
|
|