github.com/TeaOSLab/EdgeNode@v1.3.8/internal/nodes/listener_manager_test.go (about) 1 package nodes 2 3 import ( 4 "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" 5 "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" 6 "testing" 7 ) 8 9 func TestListenerManager_Listen(t *testing.T) { 10 manager := NewListenerManager() 11 err := manager.Start(&nodeconfigs.NodeConfig{ 12 Servers: []*serverconfigs.ServerConfig{ 13 { 14 IsOn: true, 15 HTTP: &serverconfigs.HTTPProtocolConfig{ 16 BaseProtocol: serverconfigs.BaseProtocol{ 17 IsOn: true, 18 Listen: []*serverconfigs.NetworkAddressConfig{ 19 { 20 Protocol: serverconfigs.ProtocolHTTP, 21 PortRange: "1234", 22 }, 23 }, 24 }, 25 }, 26 }, 27 { 28 IsOn: true, 29 HTTP: &serverconfigs.HTTPProtocolConfig{ 30 BaseProtocol: serverconfigs.BaseProtocol{ 31 IsOn: true, 32 Listen: []*serverconfigs.NetworkAddressConfig{ 33 { 34 Protocol: serverconfigs.ProtocolHTTP, 35 PortRange: "1235", 36 }, 37 }, 38 }, 39 }, 40 }, 41 }, 42 }) 43 if err != nil { 44 t.Fatal(err) 45 } 46 47 err = manager.Start(&nodeconfigs.NodeConfig{ 48 Servers: []*serverconfigs.ServerConfig{ 49 { 50 IsOn: true, 51 HTTP: &serverconfigs.HTTPProtocolConfig{ 52 BaseProtocol: serverconfigs.BaseProtocol{ 53 IsOn: true, 54 Listen: []*serverconfigs.NetworkAddressConfig{ 55 { 56 Protocol: serverconfigs.ProtocolHTTP, 57 PortRange: "1234", 58 }, 59 }, 60 }, 61 }, 62 }, 63 { 64 IsOn: true, 65 HTTP: &serverconfigs.HTTPProtocolConfig{ 66 BaseProtocol: serverconfigs.BaseProtocol{ 67 IsOn: true, 68 Listen: []*serverconfigs.NetworkAddressConfig{ 69 { 70 Protocol: serverconfigs.ProtocolHTTP, 71 PortRange: "1236", 72 }, 73 }, 74 }, 75 }, 76 }, 77 }, 78 }) 79 if err != nil { 80 t.Fatal(err) 81 } 82 83 t.Log("all ok") 84 }