...

Source file src/k8s.io/kubernetes/test/integration/ipamperf/main_test.go

Documentation: k8s.io/kubernetes/test/integration/ipamperf

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

View as plain text