mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-26 21:01:14 +08:00
Refactor connectivity tests for integration tests
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
88
test/e2e/network_connectivity_test.go
Normal file
88
test/e2e/network_connectivity_test.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// SPDX-FileCopyrightText: 2023 Steffen Vogel <post@steffenvogel.de>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
opt "github.com/stv0g/cunicu/test/e2e/nodes/options"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func (n *Network) ConnectivityTests() {
|
||||
It("", func() {
|
||||
By("Waiting until all peers are connected")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), options.timeout)
|
||||
defer cancel()
|
||||
|
||||
err := n.AgentNodes.WaitConnectionsReady(ctx)
|
||||
Expect(err).To(Succeed(), "Failed to wait for peers to connect: %s", err)
|
||||
|
||||
By("Ping between all peers started")
|
||||
|
||||
err = n.AgentNodes.PingPeers(ctx)
|
||||
Expect(err).To(Succeed(), "Failed to ping peers: %s", err)
|
||||
|
||||
By("Ping between all peers succeeded")
|
||||
})
|
||||
}
|
||||
|
||||
func (n *Network) ConnectivityTestsWithExtraArgs(extraArgs ...any) {
|
||||
BeforeEach(func() {
|
||||
n.AgentOptions = append(n.AgentOptions,
|
||||
opt.ExtraArgs(extraArgs),
|
||||
)
|
||||
})
|
||||
|
||||
n.ConnectivityTests()
|
||||
}
|
||||
|
||||
func (n *Network) ConnectivityTestsForAllCandidateTypes() {
|
||||
Context("candidate-types", func() {
|
||||
Context("any: Allow any candidate type", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("host: Allow only host candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-candidate-type", "host", "--ice-network-type", "udp4") // , "--port-forwarding=false")
|
||||
})
|
||||
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-candidate-type", "host", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("srflx: Allow only server reflexive candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-candidate-type", "srflx", "--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-candidate-type", "srflx", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("relay: Allow only relay candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-candidate-type", "relay", "--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
// TODO: Check why IPv6 relay is not working
|
||||
// Blocked by: https://github.com/pion/ice/pull/462
|
||||
Context("ipv6", Pending, func() {
|
||||
n.ConnectivityTestsWithExtraArgs("--ice-candidate-type", "relay", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
@@ -4,7 +4,6 @@
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -182,25 +181,6 @@ func (n *Network) WriteSpecReport() {
|
||||
Expect(err).To(Succeed(), "Failed to write report: %s", err)
|
||||
}
|
||||
|
||||
func (n *Network) ConnectivityTests() {
|
||||
It("", func() {
|
||||
By("Waiting until all peers are connected")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), options.timeout)
|
||||
defer cancel()
|
||||
|
||||
err := n.AgentNodes.WaitConnectionsReady(ctx)
|
||||
Expect(err).To(Succeed(), "Failed to wait for peers to connect: %s", err)
|
||||
|
||||
By("Ping between all peers started")
|
||||
|
||||
err = n.AgentNodes.PingPeers(ctx)
|
||||
Expect(err).To(Succeed(), "Failed to ping peers: %s", err)
|
||||
|
||||
By("Ping between all peers succeeded")
|
||||
})
|
||||
}
|
||||
|
||||
func (n *Network) Init() {
|
||||
*n = Network{}
|
||||
|
||||
|
@@ -128,64 +128,8 @@ var _ = Context("simple: Simple local-area switched topology with variable numbe
|
||||
n.Start()
|
||||
})
|
||||
|
||||
ConnectivityTestsWithExtraArgs := func(extraArgs ...any) {
|
||||
BeforeEach(func() {
|
||||
n.AgentOptions = append(n.AgentOptions,
|
||||
opt.ExtraArgs(extraArgs),
|
||||
)
|
||||
})
|
||||
|
||||
n.ConnectivityTests()
|
||||
}
|
||||
|
||||
ConnectivityTestsForAllCandidateTypes := func() {
|
||||
Context("candidate-types", func() {
|
||||
Context("any: Allow any candidate type", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("host: Allow only host candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "host", "--ice-network-type", "udp4") // , "--port-forwarding=false")
|
||||
})
|
||||
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "host", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("srflx: Allow only server reflexive candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "srflx", "--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "srflx", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("relay: Allow only relay candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "relay", "--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
// TODO: Check why IPv6 relay is not working
|
||||
// Blocked by: https://github.com/pion/ice/pull/462
|
||||
Context("ipv6", Pending, func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "relay", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Context("kernel: Use kernel WireGuard interface", func() {
|
||||
ConnectivityTestsForAllCandidateTypes()
|
||||
n.ConnectivityTestsForAllCandidateTypes()
|
||||
})
|
||||
|
||||
Context("userspace: Use wireguard-go userspace interfaces", Pending, func() {
|
||||
@@ -200,7 +144,7 @@ var _ = Context("simple: Simple local-area switched topology with variable numbe
|
||||
)
|
||||
})
|
||||
|
||||
ConnectivityTestsForAllCandidateTypes()
|
||||
n.ConnectivityTestsForAllCandidateTypes()
|
||||
})
|
||||
|
||||
Context("no-nat: Disable NAT for kernel device", Pending, func() {
|
||||
|
Reference in New Issue
Block a user