targetRejoin kills a random selected target, wait for it to rejoin and verifies it
(t *testing.T)
| 479 | |
| 480 | // targetRejoin kills a random selected target, wait for it to rejoin and verifies it |
| 481 | func targetRejoin(t *testing.T) { |
| 482 | var ( |
| 483 | id string |
| 484 | node *cluster.Snode |
| 485 | proxyURL = tutils.RandomProxyURL(t) |
| 486 | ) |
| 487 | |
| 488 | smap := tutils.GetClusterMap(t, proxyURL) |
| 489 | tlog.Logf("targets: %d, proxies: %d\n", smap.CountActiveTargets(), smap.CountActiveProxies()) |
| 490 | |
| 491 | node, _ = smap.GetRandTarget() |
| 492 | id = node.ID() |
| 493 | |
| 494 | cmd, err := tutils.KillNode(node) |
| 495 | tassert.CheckFatal(t, err) |
| 496 | smap, err = tutils.WaitForClusterState(proxyURL, "synchronize on 'target crashed'", |
| 497 | smap.Version, smap.CountActiveProxies(), smap.CountActiveTargets()-1) |
| 498 | tassert.CheckFatal(t, err) |
| 499 | |
| 500 | if _, ok := smap.Tmap[id]; ok { |
| 501 | t.Fatalf("Killed target was not removed from the Smap: %v", id) |
| 502 | } |
| 503 | |
| 504 | err = tutils.RestoreNode(cmd, false, "target") |
| 505 | tassert.CheckFatal(t, err) |
| 506 | |
| 507 | smap, err = tutils.WaitForClusterState(proxyURL, "synchronize on 'target rejoined'", |
| 508 | smap.Version, smap.CountActiveProxies(), smap.CountActiveTargets()+1) |
| 509 | tassert.CheckFatal(t, err) |
| 510 | |
| 511 | if _, ok := smap.Tmap[id]; !ok { |
| 512 | t.Fatalf("Restarted target %s did not rejoin the cluster", id) |
| 513 | } |
| 514 | tutils.WaitForRebalAndResil(t, tutils.BaseAPIParams(proxyURL)) |
| 515 | } |
| 516 | |
| 517 | // crashAndFastRestore kills the primary and restores it before a new leader is elected |
| 518 | func crashAndFastRestore(t *testing.T) { |
nothing calls this directly
no test coverage detected