main_test.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package ipamperf
  14. import (
  15. "flag"
  16. "testing"
  17. "k8s.io/klog"
  18. "k8s.io/kubernetes/pkg/controller/nodeipam/ipam"
  19. "k8s.io/kubernetes/test/integration/framework"
  20. )
  21. var (
  22. resultsLogFile string
  23. isCustom bool
  24. customConfig = &Config{
  25. NumNodes: 10,
  26. KubeQPS: 30,
  27. CloudQPS: 30,
  28. CreateQPS: 100,
  29. AllocatorType: ipam.RangeAllocatorType,
  30. }
  31. )
  32. func TestMain(m *testing.M) {
  33. allocator := string(ipam.RangeAllocatorType)
  34. flag.StringVar(&resultsLogFile, "log", "", "log file to write JSON results to")
  35. flag.BoolVar(&isCustom, "custom", false, "enable custom test configuration")
  36. flag.StringVar(&allocator, "allocator", allocator, "allocator to use")
  37. flag.IntVar(&customConfig.KubeQPS, "kube-qps", customConfig.KubeQPS, "API server qps for allocations")
  38. flag.IntVar(&customConfig.NumNodes, "num-nodes", 10, "number of nodes to simulate")
  39. flag.IntVar(&customConfig.CreateQPS, "create-qps", customConfig.CreateQPS, "API server qps for node creation")
  40. flag.IntVar(&customConfig.CloudQPS, "cloud-qps", customConfig.CloudQPS, "GCE Cloud qps limit")
  41. flag.Parse()
  42. switch allocator {
  43. case string(ipam.RangeAllocatorType):
  44. customConfig.AllocatorType = ipam.RangeAllocatorType
  45. case string(ipam.CloudAllocatorType):
  46. customConfig.AllocatorType = ipam.CloudAllocatorType
  47. case string(ipam.IPAMFromCloudAllocatorType):
  48. customConfig.AllocatorType = ipam.IPAMFromCloudAllocatorType
  49. case string(ipam.IPAMFromClusterAllocatorType):
  50. customConfig.AllocatorType = ipam.IPAMFromClusterAllocatorType
  51. default:
  52. klog.Fatalf("Unknown allocator type: %s", allocator)
  53. }
  54. framework.EtcdMain(m.Run)
  55. }