main.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2015 CoreOS, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package main
  15. import (
  16. "flag"
  17. "log"
  18. "net/http"
  19. "strings"
  20. )
  21. func main() {
  22. endpointStr := flag.String("agent-endpoints", ":9027", "HTTP RPC endpoints of agents")
  23. datadir := flag.String("data-dir", "agent.etcd", "etcd data directory location on agent machine")
  24. stressKeySize := flag.Int("stress-key-size", 100, "the size of each key written into etcd")
  25. stressKeySuffixRange := flag.Int("stress-key-count", 250000, "the count of key range written into etcd")
  26. limit := flag.Int("limit", 3, "the limit of rounds to run failure set")
  27. flag.Parse()
  28. endpoints := strings.Split(*endpointStr, ",")
  29. c, err := newCluster(endpoints, *datadir, *stressKeySize, *stressKeySuffixRange)
  30. if err != nil {
  31. log.Fatal(err)
  32. }
  33. defer c.Terminate()
  34. t := &tester{
  35. failures: []failure{
  36. newFailureKillAll(),
  37. newFailureKillMajority(),
  38. newFailureKillOne(),
  39. newFailureKillOneForLongTime(),
  40. newFailureIsolate(),
  41. newFailureIsolateAll(),
  42. },
  43. cluster: c,
  44. limit: *limit,
  45. }
  46. sh := statusHandler{status: &t.status}
  47. http.Handle("/status", sh)
  48. go func() { log.Fatal(http.ListenAndServe(":9028", nil)) }()
  49. t.runLoop()
  50. }