k8s.io/kubernetes@v1.29.3/test/e2e/storage/framework/testconfig.go (about) 1 /* 2 Copyright 2020 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 framework 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 "k8s.io/kubernetes/test/e2e/framework" 22 e2epod "k8s.io/kubernetes/test/e2e/framework/pod" 23 e2evolume "k8s.io/kubernetes/test/e2e/framework/volume" 24 ) 25 26 // PerTestConfig represents parameters that control test execution. 27 // One instance gets allocated for each test and is then passed 28 // via pointer to functions involved in the test. 29 type PerTestConfig struct { 30 // The test driver for the test. 31 Driver TestDriver 32 33 // Some short word that gets inserted into dynamically 34 // generated entities (pods, paths) as first part of the name 35 // to make debugging easier. Can be the same for different 36 // tests inside the test suite. 37 Prefix string 38 39 // The framework instance allocated for the current test. 40 Framework *framework.Framework 41 42 // If non-empty, Pods using a volume will be scheduled 43 // according to the NodeSelection. Otherwise Kubernetes will 44 // pick a node. 45 ClientNodeSelection e2epod.NodeSelection 46 47 // Some test drivers initialize a storage server. This is 48 // the configuration that then has to be used to run tests. 49 // The values above are ignored for such tests. 50 ServerConfig *e2evolume.TestConfig 51 52 // Some drivers run in their own namespace 53 DriverNamespace *v1.Namespace 54 } 55 56 // GetUniqueDriverName returns unique driver name that can be used parallelly in tests 57 func (config *PerTestConfig) GetUniqueDriverName() string { 58 return config.Driver.GetDriverInfo().Name + "-" + config.Framework.UniqueName 59 } 60 61 // ConvertTestConfig returns a framework test config with the 62 // parameters specified for the testsuite or (if available) the 63 // dynamically created config for the volume server. 64 // 65 // This is done because TestConfig is the public API for 66 // the testsuites package whereas volume.TestConfig is merely 67 // an implementation detail. It contains fields that have no effect. 68 func ConvertTestConfig(in *PerTestConfig) e2evolume.TestConfig { 69 if in.ServerConfig != nil { 70 return *in.ServerConfig 71 } 72 73 return e2evolume.TestConfig{ 74 Namespace: in.Framework.Namespace.Name, 75 Prefix: in.Prefix, 76 ClientNodeSelection: in.ClientNodeSelection, 77 } 78 }