main.go 2.2 KB

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