k8s.io/perf-tests/clusterloader2@v0.0.0-20240304094227-64bdb12da87e/pkg/measurement/interface.go (about) 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 measurement 18 19 import ( 20 "time" 21 22 "k8s.io/perf-tests/clusterloader2/pkg/config" 23 "k8s.io/perf-tests/clusterloader2/pkg/framework" 24 "k8s.io/perf-tests/clusterloader2/pkg/provider" 25 26 "k8s.io/apimachinery/pkg/version" 27 ) 28 29 // Config provides client and parameters required for the measurement execution. 30 type Config struct { 31 // ClusterFramework returns cluster framework. 32 ClusterFramework *framework.Framework 33 // PrometheusFramework returns prometheus framework. 34 PrometheusFramework *framework.Framework 35 // Params is a map of {name: value} pairs enabling for injection of arbitrary config 36 // into the Execute method. 37 Params map[string]interface{} 38 // TemplateProvider provides templated objects. 39 TemplateProvider *config.TemplateProvider 40 ClusterLoaderConfig *config.ClusterLoaderConfig 41 42 // Identifier identifies this instance of measurement. 43 Identifier string 44 CloudProvider provider.Provider 45 46 // ClusterVersion contains the version of the cluster and is used to select 47 // available metrics. 48 ClusterVersion version.Info 49 } 50 51 // Measurement is an common interface for all measurements methods. It should be implemented by the user to 52 // allow his/her measurement method to be registered in the measurement factory. 53 // See https://github.com/kubernetes/perf-tests/blob/master/clusterloader2/docs/design.md for reference. 54 type Measurement interface { 55 Execute(config *Config) ([]Summary, error) 56 Dispose() 57 String() string 58 } 59 60 type createMeasurementFunc func() Measurement 61 62 // Summary represenst result of specific measurement. 63 type Summary interface { 64 SummaryName() string 65 SummaryExt() string 66 SummaryTime() time.Time 67 SummaryContent() string 68 }