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

Function TestGetCandidateMembers_Pending

internal/server/db/node_test.go:362–383  ·  view source on GitHub ↗

If there are 2 online nodes, and an instance is pending on one of them, return the address of the other one number of instances.

(t *testing.T)

Source from the content-addressed store, hash-verified

360// If there are 2 online nodes, and an instance is pending on one of them,
361// return the address of the other one number of instances.
362func TestGetCandidateMembers_Pending(t *testing.T) {
363 tx, cleanup := db.NewTestClusterTx(t)
364 defer cleanup()
365
366 _, err := tx.CreateNode("buzz", "1.2.3.4:666")
367 require.NoError(t, err)
368
369 // Add a pending instance to the default node (ID 1)
370 _, err = tx.Tx().Exec(`
371INSERT INTO operations (id, uuid, node_id, type, project_id) VALUES (1, 'abc', 1, ?, 1)
372`, operationtype.InstanceCreate)
373 require.NoError(t, err)
374
375 allMembers, err := tx.GetNodes(context.Background())
376 require.NoError(t, err)
377
378 members, err := tx.GetCandidateMembers(context.Background(), allMembers, nil, "", nil, time.Duration(db.DefaultOfflineThreshold)*time.Second)
379 require.NoError(t, err)
380 require.Len(t, members, 2)
381
382 assert.Equal(t, "buzz", members[0].Name)
383}
384
385// If specific architectures were selected, return only nodes with those
386// architectures.

Callers

nothing calls this directly

Calls 7

NewTestClusterTxFunction · 0.92
CreateNodeMethod · 0.80
TxMethod · 0.80
GetNodesMethod · 0.80
GetCandidateMembersMethod · 0.80
ExecMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…