(t *testing.T, id int)
| 108 | } |
| 109 | |
| 110 | func createNamespaceFixture(t *testing.T, id int) *namespaceFixture { |
| 111 | t.Helper() |
| 112 | |
| 113 | ns := fmt.Sprintf("wg-e2e-%d", id) |
| 114 | hostVeth := fmt.Sprintf("vethh%d", id) |
| 115 | nsVeth := fmt.Sprintf("vethn%d", id) |
| 116 | hostTransitIP := fmt.Sprintf("172.30.%d.1", id) |
| 117 | nsTransitIP := fmt.Sprintf("172.30.%d.2", id) |
| 118 | transitCIDRHost := hostTransitIP + "/30" |
| 119 | transitCIDRNS := nsTransitIP + "/30" |
| 120 | |
| 121 | // Best-effort cleanup in case a previous run left stale resources. |
| 122 | runCommandNoFail("ip", "netns", "del", ns) |
| 123 | runCommandNoFail("ip", "link", "del", hostVeth) |
| 124 | |
| 125 | runCommand(t, "ip", "netns", "add", ns) |
| 126 | runCommand(t, "ip", "link", "add", hostVeth, "type", "veth", "peer", "name", nsVeth) |
| 127 | runCommand(t, "ip", "link", "set", nsVeth, "netns", ns) |
| 128 | runCommand(t, "ip", "addr", "add", transitCIDRHost, "dev", hostVeth) |
| 129 | runCommand(t, "ip", "link", "set", hostVeth, "up") |
| 130 | runCommand(t, "ip", "netns", "exec", ns, "ip", "link", "set", "lo", "up") |
| 131 | runCommand(t, "ip", "netns", "exec", ns, "ip", "addr", "add", transitCIDRNS, "dev", nsVeth) |
| 132 | runCommand(t, "ip", "netns", "exec", ns, "ip", "link", "set", nsVeth, "up") |
| 133 | |
| 134 | t.Cleanup(func() { |
| 135 | runCommandNoFail("ip", "link", "del", hostVeth) |
| 136 | runCommandNoFail("ip", "netns", "del", ns) |
| 137 | }) |
| 138 | |
| 139 | return &namespaceFixture{ |
| 140 | name: ns, |
| 141 | hostVeth: hostVeth, |
| 142 | nsVeth: nsVeth, |
| 143 | hostTransitIP: hostTransitIP, |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | func wireGuardServerIPByFamily(t *testing.T, wg *WireGuard, wantIPv6 bool) string { |
| 148 | t.Helper() |
no test coverage detected