MCPcopy
hub / github.com/lxc/incus / TestSetNodeHeartbeat

Function TestSetNodeHeartbeat

internal/server/db/node_test.go:205–221  ·  view source on GitHub ↗

Update the heartbeat of a node.

(t *testing.T)

Source from the content-addressed store, hash-verified

203
204// Update the heartbeat of a node.
205func TestSetNodeHeartbeat(t *testing.T) {
206 tx, cleanup := db.NewTestClusterTx(t)
207 defer cleanup()
208
209 _, err := tx.CreateNode("buzz", "1.2.3.4:666")
210 require.NoError(t, err)
211
212 err = tx.SetNodeHeartbeat("1.2.3.4:666", time.Now().Add(-time.Minute))
213 require.NoError(t, err)
214
215 nodes, err := tx.GetNodes(context.Background())
216 require.NoError(t, err)
217 require.Len(t, nodes, 2)
218
219 node := nodes[1]
220 assert.True(t, node.IsOffline(20*time.Second))
221}
222
223// A node is considered empty only if it has no instances.
224func TestNodeIsEmpty_Instances(t *testing.T) {

Callers

nothing calls this directly

Calls 7

NewTestClusterTxFunction · 0.92
CreateNodeMethod · 0.80
SetNodeHeartbeatMethod · 0.80
GetNodesMethod · 0.80
IsOfflineMethod · 0.80
AddMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…