func main() { rootConfig, err := config.NewConfig(os.Args) if err != nil { panic(fmt.Sprintf("Failed to parse config: %s", err.Error())) } err = rootConfig.Validate() if err != nil { panic(fmt.Sprintf("Invalid config: %s", err.Error())) } err = rootConfig.BuildLogger() if err != nil { panic(fmt.Sprintf("Failed to build logger: %s", err.Error())) } logger := rootConfig.Logger nodeManager := node_manager.New(rootConfig, clock.DefaultClock()) bootstrapper := bootstrapperPkg.New(nodeManager) if rootConfig.RepairMode == "bootstrap" { err = bootstrapper.Bootstrap() } else if rootConfig.RepairMode == "rejoin-unsafe" { err = bootstrapper.RejoinUnsafe() } else { logger.Error("Invalid repair mode:", errors.New(fmt.Sprintf("%s", rootConfig.RepairMode))) printHumanReadableErr(err) os.Exit(1) } if err != nil { logger.Error("Failed to repair cluster", err, lager.Data{ "config": rootConfig, }) printHumanReadableErr(err) os.Exit(1) } logger.Info("Successfully repaired cluster") fmt.Println("Successfully repaired cluster") }
}) JustBeforeEach(func() { testServers = []*httptest.Server{} for i := 0; i < ServerCount; i++ { newServer := httptest.NewServer(endpointHandlers[i]) testServers = append(testServers, newServer) rootConfig.HealthcheckURLs = append(rootConfig.HealthcheckURLs, newServer.URL) } fakeClock := &clockPkg.FakeClock{} fakeClock.AfterStub = func(interval time.Duration) <-chan time.Time { return time.After(1 * time.Millisecond) } nodeManager = node_manager.New(rootConfig, fakeClock) }) AfterEach(func() { for _, ts := range testServers { ts.Close() } }) Describe("#VerifyClusterIsUnhealthy", func() { Context("when all nodes are full mysql nodes", func() { Context("when all mysql nodes are unhealthy", func() { BeforeEach(func() { for _, handler := range endpointHandlers { handler.StubEndpointWithStatus("/", http.StatusServiceUnavailable, "not synced") }