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)
| 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. |
| 362 | func 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(` |
| 371 | INSERT 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…