mirror of
https://github.com/singchia/frontier.git
synced 2026-04-23 00:17:06 +08:00
f420773b0e
* Add comprehensive in-process test framework Add unit tests for exchange layer, E2E integration tests, security tests (race + fuzz), and Go benchmark tests replacing the old shell-script-based bench programs. All tests run in-process without requiring an external frontier process. Suppress klog and armorigo log noise in all test files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update build configs, Dockerfiles and dependencies Update Makefile with new targets, consolidate frontier_all.yaml config, bump base image versions in Dockerfiles, and update go.mod/go.sum. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Revert etc/frontier_all.yaml to previous version Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
96 lines
2.0 KiB
Go
96 lines
2.0 KiB
Go
package security
|
|
|
|
import (
|
|
"flag"
|
|
"io"
|
|
"net"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/jumboframes/armorigo/log"
|
|
"github.com/singchia/frontier/api/dataplane/v1/edge"
|
|
"github.com/singchia/frontier/api/dataplane/v1/service"
|
|
gconfig "github.com/singchia/frontier/pkg/config"
|
|
"github.com/singchia/frontier/pkg/frontier/config"
|
|
"github.com/singchia/frontier/pkg/frontier/edgebound"
|
|
"github.com/singchia/frontier/pkg/frontier/exchange"
|
|
"github.com/singchia/frontier/pkg/frontier/mq"
|
|
"github.com/singchia/frontier/pkg/frontier/repo"
|
|
"github.com/singchia/frontier/pkg/frontier/servicebound"
|
|
"github.com/singchia/go-timer/v2"
|
|
"k8s.io/klog/v2"
|
|
)
|
|
|
|
func init() {
|
|
klog.InitFlags(nil)
|
|
flag.Set("v", "0")
|
|
flag.Set("logtostderr", "false")
|
|
flag.Set("stderrthreshold", "FATAL")
|
|
|
|
log.SetLevel(log.LevelFatal)
|
|
log.SetOutput(io.Discard)
|
|
}
|
|
|
|
const (
|
|
edgeboundAddr = "127.0.0.1:13200"
|
|
serviceboundAddr = "127.0.0.1:13201"
|
|
testNetwork = "tcp"
|
|
)
|
|
|
|
var (
|
|
testEdgeDial edge.Dialer
|
|
testSvcDial service.Dialer
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
conf := &config.Configuration{
|
|
Edgebound: config.Edgebound{
|
|
Listen: gconfig.Listen{Network: testNetwork, Addr: edgeboundAddr},
|
|
EdgeIDAllocWhenNoIDServiceOn: true,
|
|
},
|
|
Servicebound: config.Servicebound{
|
|
Listen: gconfig.Listen{Network: testNetwork, Addr: serviceboundAddr},
|
|
},
|
|
}
|
|
|
|
r, err := repo.NewRepo(conf)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
mqm, err := mq.NewMQM(conf)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
tmr := timer.NewTimer()
|
|
ex := exchange.NewExchange(conf, mqm)
|
|
|
|
sb, err := servicebound.NewServicebound(conf, r, nil, ex, mqm, tmr)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
eb, err := edgebound.NewEdgebound(conf, r, nil, ex, tmr)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
go sb.Serve()
|
|
go eb.Serve()
|
|
time.Sleep(30 * time.Millisecond)
|
|
|
|
testEdgeDial = func() (net.Conn, error) {
|
|
return net.Dial(testNetwork, edgeboundAddr)
|
|
}
|
|
testSvcDial = func() (net.Conn, error) {
|
|
return net.Dial(testNetwork, serviceboundAddr)
|
|
}
|
|
|
|
code := m.Run()
|
|
|
|
eb.Close()
|
|
sb.Close()
|
|
r.Close()
|
|
mqm.Close()
|
|
tmr.Close()
|
|
os.Exit(code)
|
|
}
|