mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 06:19:41 +02:00
fix(tunnels): make the tunnels more robust EE-7042 (#11878)
This commit is contained in:
parent
0356288fd9
commit
4be2c061f5
20 changed files with 389 additions and 355 deletions
|
@ -7,14 +7,20 @@ import (
|
|||
"time"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/datastore"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPingAgentPanic(t *testing.T) {
|
||||
endpointID := portainer.EndpointID(1)
|
||||
endpoint := &portainer.Endpoint{
|
||||
ID: 1,
|
||||
Type: portainer.EdgeAgentOnDockerEnvironment,
|
||||
}
|
||||
|
||||
s := NewService(nil, nil, nil)
|
||||
_, store := datastore.MustNewTestStore(t, true, true)
|
||||
|
||||
s := NewService(store, nil, nil)
|
||||
|
||||
defer func() {
|
||||
require.Nil(t, recover())
|
||||
|
@ -32,8 +38,8 @@ func TestPingAgentPanic(t *testing.T) {
|
|||
require.NoError(t, http.Serve(ln, mux))
|
||||
}()
|
||||
|
||||
s.getTunnelDetails(endpointID)
|
||||
s.tunnelDetailsMap[endpointID].Port = ln.Addr().(*net.TCPAddr).Port
|
||||
s.Open(endpoint)
|
||||
s.activeTunnels[endpoint.ID].Port = ln.Addr().(*net.TCPAddr).Port
|
||||
|
||||
require.Error(t, s.pingAgent(endpointID))
|
||||
require.Error(t, s.pingAgent(endpoint.ID))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue