github.com/TeaOSLab/EdgeNode@v1.3.8/internal/nodes/listener_base_test.go (about)

     1  // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
     2  
     3  package nodes
     4  
     5  import (
     6  	"context"
     7  	"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
     8  	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
     9  	"github.com/iwind/TeaGo/types"
    10  	"testing"
    11  	"time"
    12  )
    13  
    14  func TestBaseListener_FindServer(t *testing.T) {
    15  	sharedNodeConfig = &nodeconfigs.NodeConfig{}
    16  
    17  	var listener = &BaseListener{}
    18  	listener.Group = serverconfigs.NewServerAddressGroup("https://*:443")
    19  	for i := 0; i < 1_000_000; i++ {
    20  		var server = &serverconfigs.ServerConfig{
    21  			IsOn: true,
    22  			Name: types.String(i) + ".hello.com",
    23  			ServerNames: []*serverconfigs.ServerNameConfig{
    24  				{Name: types.String(i) + ".hello.com"},
    25  			},
    26  		}
    27  		_ = server.Init(context.Background())
    28  		listener.Group.Add(server)
    29  	}
    30  
    31  	var before = time.Now()
    32  	defer func() {
    33  		t.Log(time.Since(before).Seconds()*1000, "ms")
    34  	}()
    35  
    36  	t.Log(listener.findNamedServerMatched("855555.hello.com"))
    37  }