mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-27 05:06:02 +08:00
test: restructure test packages
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
---
|
||||
ignore:
|
||||
# Auto-generated files
|
||||
- pkg/proto/**/*.pb.go
|
||||
- pkg/signaling/k8s/apis/**/*
|
||||
- pkg/signaling/k8s/client/**/*
|
||||
|
4
.github/workflows/build.yaml
vendored
4
.github/workflows/build.yaml
vendored
@@ -141,9 +141,9 @@ jobs:
|
||||
if: ${{ matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os == 'windows' }}
|
||||
run: make tests GINKGO_EXTRA_OPTS="--label-filter=!broken-on-windows"
|
||||
|
||||
- name: Run integration tests
|
||||
- name: Run end-to-end tests
|
||||
if: ${{ matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os == 'linux' }}
|
||||
run: sudo --preserve-env env "PATH=$PATH" make tests-integration
|
||||
run: sudo --preserve-env env "PATH=$PATH" make tests-e2e
|
||||
|
||||
- name: Upload logs an packet captures as artifacts
|
||||
if: ${{ always() && matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os == 'linux' }}
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,4 +7,4 @@ dist/
|
||||
*.test
|
||||
*.out.*
|
||||
lcov.info
|
||||
test/logs/
|
||||
test/e2e/logs/
|
||||
|
8
Makefile
8
Makefile
@@ -9,9 +9,9 @@ LDFLAGS = -X riasc.eu/wice/pkg/util/buildinfo.Version=$(shell git describe --tag
|
||||
-X riasc.eu/wice/pkg/util/buildinfo.Date=$(shell date -Iseconds) \
|
||||
-X riasc.eu/wice/pkg/util/buildinfo.BuiltBy=Makefile \
|
||||
|
||||
PKGS ?= ./cmd/... ./pkg/...
|
||||
PKGS ?= ./cmd/... ./pkg/... ./test
|
||||
ifeq ($(GOOS),linux)
|
||||
PKGS += ./test/...
|
||||
PKGS += ./test/e2e/...
|
||||
endif
|
||||
|
||||
GINKGO_OPTS = --compilers=2 \
|
||||
@@ -34,9 +34,9 @@ wice:
|
||||
tests:
|
||||
ginkgo run $(GINKGO_OPTS) --coverprofile=coverprofile.out ./pkg/...
|
||||
|
||||
tests-integration:
|
||||
tests-e2e:
|
||||
mkdir -p test/logs
|
||||
ginkgo run $(GINKGO_OPTS) --output-dir=./test/logs --coverprofile=coverprofile_integration.out ./test
|
||||
ginkgo run $(GINKGO_OPTS) --output-dir=./test/e2e/logs --coverprofile=coverprofile_integration.out ./test/e2e
|
||||
|
||||
coverprofile_merged.out: $(shell find . -name "*.out" -type f)
|
||||
gocov-merger -o $@ $^
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/pion/ice/v2"
|
||||
|
||||
"riasc.eu/wice/pkg/config"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
|
||||
icex "riasc.eu/wice/pkg/feat/epdisc/ice"
|
||||
)
|
||||
|
@@ -7,8 +7,8 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"net"
|
||||
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -25,6 +25,8 @@ func TestSuite(t *testing.T) {
|
||||
RunSpecs(t, "Logging Suite")
|
||||
}
|
||||
|
||||
// TODO: This test is currently broken on Windows dues:
|
||||
// https://github.com/uber-go/zap/issues/621
|
||||
var _ = Context("log", Label("broken-on-windows"), func() {
|
||||
var logger *zap.Logger
|
||||
var lvl zapcore.Level
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
|
||||
protoepdisc "riasc.eu/wice/pkg/proto/feat/epdisc"
|
||||
signalingproto "riasc.eu/wice/pkg/proto/signaling"
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/signaling/grpc"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
_ "riasc.eu/wice/pkg/signaling/inprocess"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/tools/clientcmd/api"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
)
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
13
pkg/util/json.go
Normal file
13
pkg/util/json.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package util
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func ReIndentJSON(j []byte, prefix, indent string) ([]byte, error) {
|
||||
u := map[string]any{}
|
||||
|
||||
if err := json.Unmarshal(j, &u); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.MarshalIndent(u, prefix, indent)
|
||||
}
|
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -14,10 +14,10 @@ import (
|
||||
"riasc.eu/wice/pkg/core"
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/pkg/device"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
"riasc.eu/wice/pkg/watcher"
|
||||
"riasc.eu/wice/pkg/wg"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
g "github.com/stv0g/gont/pkg"
|
||||
gopt "github.com/stv0g/gont/pkg/options"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
wopt "riasc.eu/wice/test/nodes/options/wg"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
wopt "riasc.eu/wice/test/e2e/nodes/options/wg"
|
||||
)
|
||||
|
||||
/* Carrier Grade NAT setup with two relays and a single signaling server
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
* │ n1 │ │ n2 │
|
||||
* └──────┘ └──────┘
|
||||
*/
|
||||
var _ = Context("nat double", func() {
|
||||
var _ = Context("nat double: Carrier Grade NAT setup with two relays and a single signaling server", func() {
|
||||
var (
|
||||
err error
|
||||
|
||||
@@ -221,7 +221,7 @@ var _ = Context("nat double", func() {
|
||||
n.SignalingNodes = nodes.SignalingList{s1}
|
||||
})
|
||||
|
||||
Context("2-nodes", func() {
|
||||
Context("2-nodes: Two agents connected to lan1 and lan2", func() {
|
||||
JustBeforeEach(func() {
|
||||
n.Start()
|
||||
})
|
||||
@@ -229,7 +229,7 @@ var _ = Context("nat double", func() {
|
||||
n.ConnectivityTests()
|
||||
})
|
||||
|
||||
Context("3-nodes", func() {
|
||||
Context("3-nodes: Additional agent connected to lan2", func() {
|
||||
JustBeforeEach(func() {
|
||||
AddAgent(3, lan2)
|
||||
|
||||
@@ -239,7 +239,7 @@ var _ = Context("nat double", func() {
|
||||
n.ConnectivityTests()
|
||||
})
|
||||
|
||||
Context("4-nodes", func() {
|
||||
Context("4-nodes: Additional agent connected to wan2", func() {
|
||||
JustBeforeEach(func() {
|
||||
AddAgent(3, lan2)
|
||||
AddAgent(4, wan2)
|
||||
@@ -250,7 +250,7 @@ var _ = Context("nat double", func() {
|
||||
n.ConnectivityTests()
|
||||
})
|
||||
|
||||
Context("5-nodes", func() {
|
||||
Context("5-nodes: Additional agent connected to wan1", func() {
|
||||
JustBeforeEach(func() {
|
||||
AddAgent(3, lan2)
|
||||
AddAgent(4, wan2)
|
@@ -1,4 +1,4 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
g "github.com/stv0g/gont/pkg"
|
||||
gopt "github.com/stv0g/gont/pkg/options"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
wopt "riasc.eu/wice/test/nodes/options/wg"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
wopt "riasc.eu/wice/test/e2e/nodes/options/wg"
|
||||
)
|
||||
|
||||
/* Typical wide-area NAT setup
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
* │ n1 │ │ n2 │ │ (n3) │
|
||||
* └──────┘ └──────┘ └──────┘
|
||||
*/
|
||||
var _ = Context("nat simple", func() {
|
||||
var _ = Context("nat simple: Simple home-router NAT setup", func() {
|
||||
var (
|
||||
err error
|
||||
|
||||
@@ -141,7 +141,7 @@ var _ = Context("nat simple", func() {
|
||||
n.SignalingNodes = nodes.SignalingList{s1}
|
||||
})
|
||||
|
||||
Context("2-nodes", func() {
|
||||
Context("2-nodes: Two agents connected to lan1 & lan2", func() {
|
||||
JustBeforeEach(func() {
|
||||
n.Start()
|
||||
})
|
||||
@@ -149,7 +149,7 @@ var _ = Context("nat simple", func() {
|
||||
n.ConnectivityTests()
|
||||
})
|
||||
|
||||
Context("3-nodes", func() {
|
||||
Context("3-nodes: Additional agent connected to lan2", func() {
|
||||
JustBeforeEach(func() {
|
||||
AddAgent(3, lan2)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//go:build !tracer
|
||||
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
type HandshakeTracer any
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
@@ -16,9 +15,9 @@ import (
|
||||
copt "github.com/stv0g/gont/pkg/options/capture"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
"riasc.eu/wice/test"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -157,10 +156,29 @@ func (n *Network) Close() {
|
||||
Expect(err).To(Succeed(), "Failed to close network; %s", err)
|
||||
|
||||
n.StopHandshakeTracer()
|
||||
n.WriteSpecReport()
|
||||
|
||||
GinkgoWriter.ClearTeeWriters()
|
||||
}
|
||||
|
||||
func (n *Network) WriteSpecReport() {
|
||||
report := CurrentSpecReport()
|
||||
report.CapturedGinkgoWriterOutput = ""
|
||||
|
||||
reportJSON, err := report.MarshalJSON()
|
||||
Expect(err).To(Succeed(), "Failed to marshal report: %s", err)
|
||||
|
||||
reportJSON, err = util.ReIndentJSON(reportJSON, "", " ")
|
||||
Expect(err).To(Succeed(), "Failed to indent report: %s", err)
|
||||
|
||||
reportFileName := filepath.Join(n.BasePath, "report.json")
|
||||
reportFile, err := os.OpenFile(reportFileName, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
|
||||
Expect(err).To(Succeed(), "Failed to open report file: %s", err)
|
||||
|
||||
_, err = reportFile.Write(reportJSON)
|
||||
Expect(err).To(Succeed(), "Failed to write report: %s", err)
|
||||
}
|
||||
|
||||
func (n *Network) ConnectivityTests() {
|
||||
It("", func() {
|
||||
By("Waiting until all peers are connected")
|
||||
@@ -182,9 +200,7 @@ func (n *Network) Init() {
|
||||
*n = Network{}
|
||||
|
||||
n.Name = fmt.Sprintf("wice-%d", rand.Uint32())
|
||||
|
||||
name := GinkgoT().Name()
|
||||
n.BasePath = filepath.Join(strings.Split(name, " ")...)
|
||||
n.BasePath = filepath.Join(SpecName()...)
|
||||
n.BasePath = filepath.Join("logs", n.BasePath)
|
||||
|
||||
logFilename := filepath.Join(n.BasePath, "test.log")
|
@@ -1,6 +1,6 @@
|
||||
//go:build tracer
|
||||
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"bytes"
|
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/gomega/gexec"
|
||||
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
@@ -49,7 +48,7 @@ func BuildTestBinary(name string) (string, []any, error) {
|
||||
// Build a test binary if profiling is requested
|
||||
if len(profileFlags) > 0 {
|
||||
// Generate coverage for all wice packages
|
||||
profileFlags["coverpkg"] = "../..."
|
||||
profileFlags["coverpkg"] = "../../..."
|
||||
|
||||
buildArgs = append(buildArgs, "-tags", "test")
|
||||
|
||||
@@ -60,9 +59,9 @@ func BuildTestBinary(name string) (string, []any, error) {
|
||||
|
||||
// We compile a dummy go test binary here which just
|
||||
// invokes main(), but is instrumented for profiling.
|
||||
testBinaryPath, err = gexec.CompileTest("../cmd/wice", buildArgs...)
|
||||
testBinaryPath, err = gexec.CompileTest("../../cmd/wice", buildArgs...)
|
||||
} else {
|
||||
testBinaryPath, err = gexec.Build("../cmd/wice", buildArgs...)
|
||||
testBinaryPath, err = gexec.Build("../../cmd/wice", buildArgs...)
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"riasc.eu/wice/test/nodes"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
)
|
||||
|
||||
type ExtraArgs []any
|
@@ -7,7 +7,7 @@ import (
|
||||
g "github.com/stv0g/gont/pkg"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
)
|
||||
|
||||
type PrivateKey crypto.Key
|
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
)
|
||||
|
||||
// PublicKey specifies the public key of this peer. PublicKey is a
|
@@ -1,4 +1,4 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -6,10 +6,11 @@ import (
|
||||
"time"
|
||||
|
||||
"riasc.eu/wice/pkg/crypto"
|
||||
"riasc.eu/wice/pkg/proto"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
"riasc.eu/wice/pkg/wg"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
wopt "riasc.eu/wice/test/nodes/options/wg"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
wopt "riasc.eu/wice/test/e2e/nodes/options/wg"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -37,7 +38,7 @@ import (
|
||||
* └────┘ └────┘
|
||||
* wice Agents
|
||||
*/
|
||||
var _ = Context("restart", func() {
|
||||
var _ = Context("restart: Restart ICE agents", func() {
|
||||
var (
|
||||
err error
|
||||
n Network
|
||||
@@ -123,9 +124,7 @@ var _ = Context("restart", func() {
|
||||
ConnectivityTestCycle := func() {
|
||||
n.ConnectivityTests()
|
||||
|
||||
It("", func() {
|
||||
By("Triggering restart")
|
||||
|
||||
It("Triggering restart", func() {
|
||||
restart(gap)
|
||||
|
||||
time.Sleep(gap)
|
||||
@@ -134,7 +133,7 @@ var _ = Context("restart", func() {
|
||||
n.ConnectivityTests()
|
||||
}
|
||||
|
||||
Context("quick", Ordered, func() {
|
||||
Context("quick: Waiting 3 seconds", Ordered, func() {
|
||||
BeforeEach(func() {
|
||||
gap = 3 * time.Second
|
||||
})
|
||||
@@ -142,7 +141,7 @@ var _ = Context("restart", func() {
|
||||
ConnectivityTestCycle()
|
||||
})
|
||||
|
||||
Context("slow", Ordered, func() {
|
||||
Context("slow: Waiting 10 seconds to trigger an ICE disconnect", Ordered, func() {
|
||||
BeforeEach(func() {
|
||||
gap = 10 * time.Second // > ICE failed/disconnected timeout (5s)
|
||||
})
|
||||
@@ -151,7 +150,7 @@ var _ = Context("restart", func() {
|
||||
})
|
||||
}
|
||||
|
||||
Context("agent", func() {
|
||||
Context("agent: Restart agent", func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
By("Stopping first agent")
|
||||
|
||||
@@ -169,7 +168,7 @@ var _ = Context("restart", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("addresses", Pending, func() {
|
||||
Context("addresses: Change uplink IP address", Pending, func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
i := n1.Interface("eth0")
|
||||
Expect(i).NotTo(BeNil(), "Failed to find agent interface")
|
||||
@@ -206,7 +205,7 @@ var _ = Context("restart", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("link", Pending, func() {
|
||||
Context("link: Bring uplink down and up", Pending, func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
i := n1.Interface("eth0")
|
||||
Expect(i).NotTo(BeNil(), "Failed to find agent interface")
|
||||
@@ -227,36 +226,62 @@ var _ = Context("restart", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("rpc", func() {
|
||||
Context("peer-rpc: Restart peer via RPC", func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
ctx := context.Background()
|
||||
|
||||
i := n1.WireGuardInterfaces[0]
|
||||
p := i.Peers[0]
|
||||
pk := (*crypto.Key)(&p.PublicKey)
|
||||
|
||||
By("Initiating restart via RPC")
|
||||
|
||||
i := n1.WireGuardInterfaces[0]
|
||||
pk := (*crypto.Key)(&i.Peers[0].PublicKey)
|
||||
err = n1.Client.RestartPeer(ctx, i.Name, pk)
|
||||
Expect(err).To(Succeed(), "Failed to restart peer: %s", err)
|
||||
})
|
||||
})
|
||||
|
||||
Context("signaling", Pending, func() {
|
||||
Context("agent-rpc: Restart agent via RPC", Pending, func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
ctx := context.Background()
|
||||
|
||||
By("Initiating agent restart via RPC")
|
||||
|
||||
_, err = n1.Client.Restart(ctx, &proto.Empty{})
|
||||
Expect(err).To(Succeed(), "Failed to restart peer: %s", err)
|
||||
})
|
||||
})
|
||||
|
||||
Context("signaling: Restart signaling server", Pending, func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
ctx := context.Background()
|
||||
|
||||
By("Stopping signaling server")
|
||||
|
||||
err = s1.Stop()
|
||||
Expect(err).To(Succeed(), "Failed to stop signaling server")
|
||||
|
||||
By("Restarting peer")
|
||||
|
||||
i := n1.WireGuardInterfaces[0]
|
||||
pk := (*crypto.Key)(&i.Peers[0].PublicKey)
|
||||
err = n1.Client.RestartPeer(ctx, i.Name, pk)
|
||||
Expect(err).To(Succeed(), "Failed to restart peer: %s", err)
|
||||
|
||||
By("Waiting some time")
|
||||
|
||||
time.Sleep(gap)
|
||||
|
||||
By("Re-starting signaling server again")
|
||||
By("Starting signaling server again")
|
||||
|
||||
err = s1.Start("", n.BasePath)
|
||||
Expect(err).To(Succeed(), "Failed to restart signaling server: %s", err)
|
||||
})
|
||||
})
|
||||
|
||||
Context("private-key: Trigger recreation of peer by changing private-key of interface", func() {
|
||||
RestartTest(func(gap time.Duration) {
|
||||
By("Changing private-key")
|
||||
|
||||
// i.Configuring
|
||||
})
|
||||
})
|
||||
})
|
@@ -1,13 +1,13 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"riasc.eu/wice/pkg/wg"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
opt "riasc.eu/wice/test/nodes/options"
|
||||
wopt "riasc.eu/wice/test/nodes/options/wg"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
opt "riasc.eu/wice/test/e2e/nodes/options"
|
||||
wopt "riasc.eu/wice/test/e2e/nodes/options/wg"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -37,7 +37,7 @@ import (
|
||||
* └────┘ └────┘ └────┘
|
||||
* wice Agents
|
||||
*/
|
||||
var _ = Context("simple", Serial, func() {
|
||||
var _ = Context("simple: Simple local-area switched topology with variable number of agents", Serial, func() {
|
||||
var (
|
||||
err error
|
||||
n Network
|
||||
@@ -142,38 +142,38 @@ var _ = Context("simple", Serial, func() {
|
||||
|
||||
ConnectivityTestsForAllCandidateTypes := func() {
|
||||
Context("candidate-types", func() {
|
||||
Context("any", func() {
|
||||
Context("ipv4", func() {
|
||||
Context("any: Allow any candidate type", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
Context("ipv6", func() {
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("host", func() {
|
||||
Context("ipv4", func() {
|
||||
Context("host: Allow only host candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "host", "--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
Context("ipv6", func() {
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "host", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("srflx", func() {
|
||||
Context("ipv4", func() {
|
||||
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", func() {
|
||||
Context("ipv6: Allow IPv6 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "srflx", "--ice-network-type", "udp6")
|
||||
})
|
||||
})
|
||||
|
||||
Context("relay", func() {
|
||||
Context("ipv4", func() {
|
||||
Context("relay: Allow only relay candidates", func() {
|
||||
Context("ipv4: Allow IPv4 network only", func() {
|
||||
ConnectivityTestsWithExtraArgs("--ice-candidate-type", "relay", "--ice-network-type", "udp4")
|
||||
})
|
||||
|
||||
@@ -185,11 +185,11 @@ var _ = Context("simple", Serial, func() {
|
||||
})
|
||||
}
|
||||
|
||||
Context("kernel", func() {
|
||||
Context("kernel: Use kernel WireGuard interface", func() {
|
||||
ConnectivityTestsForAllCandidateTypes()
|
||||
})
|
||||
|
||||
Context("userspace", func() {
|
||||
Context("userspace: Use wireguard-go userspace interfaces", func() {
|
||||
BeforeEach(func() {
|
||||
n.WireGuardInterfaceOptions = append(n.WireGuardInterfaceOptions,
|
||||
wopt.WriteConfigFile(true),
|
||||
@@ -204,8 +204,8 @@ var _ = Context("simple", Serial, func() {
|
||||
ConnectivityTestsForAllCandidateTypes()
|
||||
})
|
||||
|
||||
Context("filtered", func() {
|
||||
Context("p2p", func() {
|
||||
Context("filtered: Block WireGuard UDP traffic", func() {
|
||||
Context("p2p: Between agents only", func() {
|
||||
BeforeEach(func() {
|
||||
// We are dropped packets between the ɯice nodes to force ICE using the relay
|
||||
n.AgentOptions = append(n.AgentOptions,
|
||||
@@ -225,7 +225,7 @@ var _ = Context("simple", Serial, func() {
|
||||
n.ConnectivityTests()
|
||||
})
|
||||
|
||||
Context("all-udp", func() {
|
||||
Context("all-udp: All UDP entirely", func() {
|
||||
BeforeEach(func() {
|
||||
n.AgentOptions = append(n.AgentOptions,
|
||||
gopt.Filter(g.FilterInput,
|
||||
@@ -239,4 +239,32 @@ var _ = Context("simple", Serial, func() {
|
||||
n.ConnectivityTests()
|
||||
})
|
||||
})
|
||||
|
||||
Context("pdisc: Peer Discovery", Pending, Ordered, func() {
|
||||
BeforeEach(OncePerOrdered, func() {
|
||||
n.AgentOptions = append(n.AgentOptions,
|
||||
opt.ExtraArgs{"--community", "hallo"},
|
||||
)
|
||||
|
||||
n.WireGuardInterfaceOptions = append(n.WireGuardInterfaceOptions,
|
||||
wopt.NoPeers,
|
||||
)
|
||||
|
||||
NumAgents = 3
|
||||
})
|
||||
|
||||
n.ConnectivityTests()
|
||||
|
||||
It("", func() {
|
||||
By("Check existing peers 2")
|
||||
|
||||
n.AgentNodes.ForEachAgent(func(a *nodes.Agent) error {
|
||||
out, _, err := a.Run("wg")
|
||||
Expect(err).To(Succeed())
|
||||
|
||||
GinkgoWriter.Write(out)
|
||||
return nil
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
@@ -1,8 +1,8 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"riasc.eu/wice/pkg/wg"
|
||||
"riasc.eu/wice/test/nodes"
|
||||
"riasc.eu/wice/test/e2e/nodes"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
gopt "github.com/stv0g/gont/pkg/options"
|
||||
)
|
||||
|
||||
var _ = Context("single", Pending, func() {
|
||||
var _ = Context("single: A single node to test RPC and watcher", Pending, func() {
|
||||
var n Network
|
||||
|
||||
BeforeEach(func() {
|
||||
@@ -43,17 +43,17 @@ var _ = Context("single", Pending, func() {
|
||||
n.AgentNodes = nodes.AgentList{n1}
|
||||
})
|
||||
|
||||
Context("create", func() {
|
||||
Context("kernel", func() {
|
||||
Context("create: Create a new interface", func() {
|
||||
Context("kernel: Kernel-space", func() {
|
||||
|
||||
})
|
||||
|
||||
Context("userspace", func() {
|
||||
Context("userspace: User-space", func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Context("watcher", Ordered, func() {
|
||||
Context("watcher: Watch for changes of WireGuard interfaces and peers", Ordered, func() {
|
||||
It("detects a new interface", func() {
|
||||
|
||||
})
|
||||
@@ -79,15 +79,19 @@ var _ = Context("single", Pending, func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("host-sync", func() {
|
||||
Context("hsync: /etc/hosts synchronization", func() {
|
||||
|
||||
})
|
||||
|
||||
Context("route-sync", func() {
|
||||
Context("rtsync: Route synchronization", func() {
|
||||
|
||||
})
|
||||
|
||||
Context("config-sync", func() {
|
||||
Context("cfgsync: Config file synchronization", func() {
|
||||
|
||||
})
|
||||
|
||||
Context("autocfg: Auto-configuration of missing interface parameters", func() {
|
||||
|
||||
})
|
||||
})
|
@@ -1,8 +1,9 @@
|
||||
package test_test
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
"github.com/onsi/gomega/gexec"
|
||||
"riasc.eu/wice/pkg/util"
|
||||
|
||||
"github.com/onsi/ginkgo/v2/reporters"
|
||||
"github.com/onsi/ginkgo/v2/types"
|
||||
)
|
||||
|
||||
@@ -33,7 +35,6 @@ func TestSuite(t *testing.T) {
|
||||
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "E2E Test Suite", types.ReporterConfig{
|
||||
JSONReport: "logs/report.json",
|
||||
SlowSpecThreshold: 1 * time.Minute,
|
||||
})
|
||||
}
|
||||
@@ -45,3 +46,36 @@ var _ = BeforeSuite(func() {
|
||||
|
||||
DeferCleanup(gexec.CleanupBuildArtifacts)
|
||||
})
|
||||
|
||||
var _ = ReportAfterSuite("Write report", func(r Report) {
|
||||
r.SpecReports = nil
|
||||
reporters.GenerateJSONReport(r, "logs/report.json")
|
||||
})
|
||||
|
||||
func SpecName() []string {
|
||||
sr := CurrentSpecReport()
|
||||
|
||||
normalize := func(s string) ([]string, bool) {
|
||||
p := strings.SplitN(s, ":", 2)
|
||||
if len(p) != 2 {
|
||||
return []string{}, false
|
||||
}
|
||||
|
||||
ps := strings.Split(strings.ToLower(p[0]), " ")
|
||||
|
||||
return ps, true
|
||||
}
|
||||
|
||||
sn := []string{}
|
||||
for _, txt := range sr.ContainerHierarchyTexts {
|
||||
if n, ok := normalize(txt); ok {
|
||||
sn = append(sn, n...)
|
||||
}
|
||||
}
|
||||
|
||||
if n, ok := normalize(sr.LeafNodeText); ok {
|
||||
sn = append(sn, n...)
|
||||
}
|
||||
|
||||
return sn
|
||||
}
|
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/pkg/test"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
Reference in New Issue
Block a user