MCPcopy
hub / github.com/NVIDIA/aistore / TestReregisterMultipleTargets

Function TestReregisterMultipleTargets

ais/tests/regression_test.go:452–549  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

450}
451
452func TestReregisterMultipleTargets(t *testing.T) {
453 tutils.CheckSkip(t, tutils.SkipTestArgs{Long: true})
454
455 var (
456 filesSentOrig = make(map[string]int64)
457 filesRecvOrig = make(map[string]int64)
458 bytesSentOrig = make(map[string]int64)
459 bytesRecvOrig = make(map[string]int64)
460 filesSent int64
461 filesRecv int64
462 bytesSent int64
463 bytesRecv int64
464
465 m = ioContext{
466 t: t,
467 num: 10000,
468 }
469 )
470
471 m.initWithCleanupAndSaveState()
472 m.expectTargets(2)
473 targetsToUnregister := m.originalTargetCount - 1
474
475 // Step 0: Collect rebalance stats
476 clusterStats := tutils.GetClusterStats(t, m.proxyURL)
477 for targetID, targetStats := range clusterStats.Target {
478 filesSentOrig[targetID] = tutils.GetNamedStatsVal(targetStats, stats.StreamsOutObjCount)
479 filesRecvOrig[targetID] = tutils.GetNamedStatsVal(targetStats, stats.StreamsInObjCount)
480 bytesSentOrig[targetID] = tutils.GetNamedStatsVal(targetStats, stats.StreamsOutObjSize)
481 bytesRecvOrig[targetID] = tutils.GetNamedStatsVal(targetStats, stats.StreamsInObjSize)
482 }
483
484 // Step 1: Unregister multiple targets
485 removed := make(map[string]*cluster.Snode, m.smap.CountActiveTargets()-1)
486 defer func() {
487 var rebID string
488 for _, tgt := range removed {
489 rebID = m.stopMaintenance(tgt)
490 }
491 if len(removed) != 0 && rebID != "" {
492 tutils.WaitForRebalanceByID(t, m.originalTargetCount, baseParams, rebID)
493 }
494 }()
495
496 targets := m.smap.Tmap.ActiveNodes()
497 for i := 0; i < targetsToUnregister; i++ {
498 tlog.Logf("Put %s in maintenance (no rebalance)\n", targets[i].StringEx())
499 args := &apc.ActValRmNode{DaemonID: targets[i].ID(), SkipRebalance: true}
500 _, err := api.StartMaintenance(baseParams, args)
501 tassert.CheckFatal(t, err)
502 removed[targets[i].ID()] = targets[i]
503 }
504
505 smap, err := tutils.WaitForClusterState(proxyURL, "remove targets",
506 m.smap.Version, m.originalProxyCount, m.originalTargetCount-targetsToUnregister)
507 tassert.CheckFatal(t, err)
508 tlog.Logf("The cluster now has %d target(s)\n", smap.CountActiveTargets())
509

Callers

nothing calls this directly

Calls 15

CheckSkipFunction · 0.92
GetClusterStatsFunction · 0.92
GetNamedStatsValFunction · 0.92
WaitForRebalanceByIDFunction · 0.92
LogfFunction · 0.92
StartMaintenanceFunction · 0.92
CheckFatalFunction · 0.92
WaitForClusterStateFunction · 0.92
CreateBucketWithCleanupFunction · 0.92
BaseAPIParamsFunction · 0.92
WaitForRebalAndResilFunction · 0.92
B2SFunction · 0.92

Tested by

no test coverage detected