mirror of https://github.com/portainer/portainer
chore(endpointutils): remove unnecessary field BE-10415 (#1136)
parent
c90a15dd0f
commit
110f88f22d
|
@ -83,7 +83,6 @@
|
||||||
"MigrateIngresses": true
|
"MigrateIngresses": true
|
||||||
},
|
},
|
||||||
"PublicURL": "",
|
"PublicURL": "",
|
||||||
"QueryDate": 0,
|
|
||||||
"SecuritySettings": {
|
"SecuritySettings": {
|
||||||
"allowBindMountsForRegularUsers": true,
|
"allowBindMountsForRegularUsers": true,
|
||||||
"allowContainerCapabilitiesForRegularUsers": true,
|
"allowContainerCapabilitiesForRegularUsers": true,
|
||||||
|
|
|
@ -2,10 +2,12 @@ package endpointutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
portainer "github.com/portainer/portainer/api"
|
portainer "github.com/portainer/portainer/api"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
type isEndpointTypeTest struct {
|
type isEndpointTypeTest struct {
|
||||||
|
@ -120,3 +122,18 @@ func Test_FilterByExcludeIDs(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpdateEdgeEndpointHeartbeat(t *testing.T) {
|
||||||
|
endpoint := &portainer.Endpoint{
|
||||||
|
Type: portainer.EdgeAgentOnDockerEnvironment,
|
||||||
|
LastCheckInDate: time.Now().Unix(),
|
||||||
|
EdgeCheckinInterval: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateEdgeEndpointHeartbeat(endpoint, &portainer.Settings{})
|
||||||
|
require.True(t, endpoint.Heartbeat)
|
||||||
|
|
||||||
|
endpoint.LastCheckInDate = time.Now().Add(-time.Minute).Unix()
|
||||||
|
UpdateEdgeEndpointHeartbeat(endpoint, &portainer.Settings{})
|
||||||
|
require.False(t, endpoint.Heartbeat)
|
||||||
|
}
|
||||||
|
|
|
@ -215,9 +215,8 @@ func UpdateEdgeEndpointHeartbeat(endpoint *portainer.Endpoint, settings *portain
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint.QueryDate = time.Now().Unix()
|
|
||||||
checkInInterval := getEndpointCheckinInterval(endpoint, settings)
|
checkInInterval := getEndpointCheckinInterval(endpoint, settings)
|
||||||
endpoint.Heartbeat = endpoint.QueryDate-endpoint.LastCheckInDate <= int64(checkInInterval*2+20)
|
endpoint.Heartbeat = time.Now().Unix()-endpoint.LastCheckInDate <= int64(checkInInterval*2+20)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getEndpointCheckinInterval(endpoint *portainer.Endpoint, settings *portainer.Settings) int {
|
func getEndpointCheckinInterval(endpoint *portainer.Endpoint, settings *portainer.Settings) int {
|
||||||
|
|
|
@ -448,8 +448,6 @@ type (
|
||||||
AMTDeviceGUID string `json:"AMTDeviceGUID,omitempty" example:"4c4c4544-004b-3910-8037-b6c04f504633"`
|
AMTDeviceGUID string `json:"AMTDeviceGUID,omitempty" example:"4c4c4544-004b-3910-8037-b6c04f504633"`
|
||||||
// LastCheckInDate mark last check-in date on checkin
|
// LastCheckInDate mark last check-in date on checkin
|
||||||
LastCheckInDate int64
|
LastCheckInDate int64
|
||||||
// QueryDate of each query with the endpoints list
|
|
||||||
QueryDate int64
|
|
||||||
// Heartbeat indicates the heartbeat status of an edge environment
|
// Heartbeat indicates the heartbeat status of an edge environment
|
||||||
Heartbeat bool `json:"Heartbeat" example:"true"`
|
Heartbeat bool `json:"Heartbeat" example:"true"`
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,13 @@ test('given edge id and last checkin is set, should show heartbeat', async () =>
|
||||||
async function renderComponent(
|
async function renderComponent(
|
||||||
edgeId = '',
|
edgeId = '',
|
||||||
lastCheckInDate = 0,
|
lastCheckInDate = 0,
|
||||||
checkInInterval = 0,
|
checkInInterval = 0
|
||||||
queryDate = 0
|
|
||||||
) {
|
) {
|
||||||
const environment = createMockEnvironment();
|
const environment = createMockEnvironment();
|
||||||
|
|
||||||
environment.EdgeID = edgeId;
|
environment.EdgeID = edgeId;
|
||||||
environment.LastCheckInDate = lastCheckInDate;
|
environment.LastCheckInDate = lastCheckInDate;
|
||||||
environment.EdgeCheckinInterval = checkInInterval;
|
environment.EdgeCheckinInterval = checkInInterval;
|
||||||
environment.QueryDate = queryDate;
|
|
||||||
|
|
||||||
const Wrapped = withTestQueryProvider(EdgeIndicator);
|
const Wrapped = withTestQueryProvider(EdgeIndicator);
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,6 @@ export type Environment = {
|
||||||
EdgeID?: string;
|
EdgeID?: string;
|
||||||
EdgeKey: string;
|
EdgeKey: string;
|
||||||
EdgeCheckinInterval?: number;
|
EdgeCheckinInterval?: number;
|
||||||
QueryDate?: number;
|
|
||||||
Heartbeat?: boolean;
|
Heartbeat?: boolean;
|
||||||
LastCheckInDate?: number;
|
LastCheckInDate?: number;
|
||||||
Name: string;
|
Name: string;
|
||||||
|
|
Loading…
Reference in New Issue