main.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
  21. )
  22. func main() {
  23. endpointStr := flag.String("agent-endpoints", "localhost:9027", "HTTP RPC endpoints of agents. Do not specify the schema.")
  24. datadir := flag.String("data-dir", "agent.etcd", "etcd data directory location on agent machine.")
  25. stressKeySize := flag.Int("stress-key-size", 100, "the size of each key written into etcd.")
  26. stressKeySuffixRange := flag.Int("stress-key-count", 250000, "the count of key range written into etcd.")
  27. limit := flag.Int("limit", 3, "the limit of rounds to run failure set.")
  28. isV2Only := flag.Bool("v2-only", false, "'true' to run V2 only tester.")
  29. flag.Parse()
  30. endpoints := strings.Split(*endpointStr, ",")
  31. c, err := newCluster(endpoints, *datadir, *stressKeySize, *stressKeySuffixRange, *isV2Only)
  32. if err != nil {
  33. log.Fatal(err)
  34. }
  35. defer c.Terminate()
  36. t := &tester{
  37. failures: []failure{
  38. newFailureKillAll(),
  39. newFailureKillMajority(),
  40. newFailureKillOne(),
  41. newFailureKillLeader(),
  42. newFailureKillOneForLongTime(),
  43. newFailureKillLeaderForLongTime(),
  44. newFailureIsolate(),
  45. newFailureIsolateAll(),
  46. },
  47. cluster: c,
  48. limit: *limit,
  49. }
  50. sh := statusHandler{status: &t.status}
  51. http.Handle("/status", sh)
  52. http.Handle("/metrics", prometheus.Handler())
  53. go func() { log.Fatal(http.ListenAndServe(":9028", nil)) }()
  54. t.runLoop()
  55. }