| 519 | def test_repairer_servers_of_happiness(self): |
| 520 | # The repairer is supposed to generate and place as many of the |
| 521 | # missing shares as possible without caring about how they are |
| 522 | # distributed. |
| 523 | self.basedir = "repairer/Repairer/repairer_servers_of_happiness" |
| 524 | self.set_up_grid(num_clients=2, num_servers=10) |
| 525 | d = self.upload_and_stash() |
| 526 | # Now delete some servers. We want to leave 3 servers, which |
| 527 | # will allow us to restore the file to a healthy state without |
| 528 | # distributing the shares widely enough to satisfy the default |
| 529 | # happiness setting. |
| 530 | def _delete_some_servers(ignored): |
| 531 | for i in xrange(7): |
| 532 | self.g.remove_server(self.g.servers_by_number[i].my_nodeid) |
| 533 | |
| 534 | assert len(self.g.servers_by_number) == 3 |
| 535 | |
| 536 | d.addCallback(_delete_some_servers) |
| 537 | # Now try to repair the file. |
| 538 | d.addCallback(lambda ignored: |
| 539 | self.c0_filenode.check_and_repair(Monitor(), verify=False)) |
| 540 | def _check_results(crr): |
| 541 | self.failUnlessIsInstance(crr, |
| 542 | check_results.CheckAndRepairResults) |
| 543 | pre = crr.get_pre_repair_results() |
| 544 | post = crr.get_post_repair_results() |
| 545 | for p in (pre, post): |
| 546 | self.failUnlessIsInstance(p, check_results.CheckResults) |
| 547 | |
| 548 | self.failIf(pre.is_healthy()) |
| 549 | self.failUnless(post.is_healthy()) |
| 550 | |
| 551 | d.addCallback(_check_results) |
| 552 | return d |
| 553 | |