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 workloads 18 19 import ( 20 "time" 21 22 v1 "k8s.io/api/core/v1" 23 kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" 24 ) 25 26 // NodePerfWorkload provides the necessary information to run a workload for 27 // node performance testing. 28 type NodePerfWorkload interface { 29 // Name of the workload. 30 Name() string 31 // PodSpec used to run this workload. 32 PodSpec() v1.PodSpec 33 // Timeout provides the expected time to completion 34 // for this workload. 35 Timeout() time.Duration 36 // KubeletConfig specifies the Kubelet configuration 37 // required for this workload. 38 KubeletConfig(old *kubeletconfig.KubeletConfiguration) (new *kubeletconfig.KubeletConfiguration, err error) 39 // PreTestExec is used for defining logic that needs 40 // to be run before restarting the Kubelet with the new Kubelet 41 // configuration required for the workload. 42 PreTestExec() error 43 // PostTestExec is used for defining logic that needs 44 // to be run after the workload has completed. 45 PostTestExec() error 46 // ExtractPerformanceFromLogs is used get the performance of the workload 47 // from pod logs. Currently, we support only performance reported in 48 // time.Duration format. 49 ExtractPerformanceFromLogs(logs string) (perf time.Duration, err error) 50 } 51 52 // NodePerfWorkloads is the collection of all node performance testing workloads. 53 var NodePerfWorkloads = []NodePerfWorkload{npbISWorkload{}, npbEPWorkload{}, tfWideDeepWorkload{}} 54