@@ -19,6 +19,7 @@ package kubetest
19
19
20
20
import (
21
21
"context"
22
+ "fmt"
22
23
"os"
23
24
"os/exec"
24
25
"os/user"
@@ -32,6 +33,7 @@ import (
32
33
"k8s.io/client-go/discovery"
33
34
"k8s.io/client-go/tools/clientcmd"
34
35
"sigs.k8s.io/cluster-api/test/framework"
36
+ "sigs.k8s.io/yaml"
35
37
)
36
38
37
39
const (
@@ -111,12 +113,11 @@ func Run(ctx context.Context, input RunInput) error {
111
113
"slowSpecThreshold" : strconv .Itoa (input .GinkgoSlowSpecThreshold ),
112
114
}
113
115
114
- // Copy configuration files for kubetest into the artifacts directory
115
- // to avoid issues with volume mounts on MacOS
116
- tmpConfigFilePath := path .Join (kubetestConfigDir , "viper-config.yaml" )
117
- if err := copyFile (input .ConfigFilePath , tmpConfigFilePath ); err != nil {
116
+ config , err := parseKubetestConfig (input .ConfigFilePath )
117
+ if err != nil {
118
118
return err
119
119
}
120
+
120
121
tmpKubeConfigPath , err := dockeriseKubeconfig (kubetestConfigDir , input .ClusterProxy .GetKubeconfigPath ())
121
122
if err != nil {
122
123
return err
@@ -138,7 +139,6 @@ func Run(ctx context.Context, input RunInput) error {
138
139
"dump-logs-on-failure" : "false" ,
139
140
"report-prefix" : "kubetest." ,
140
141
"num-nodes" : strconv .FormatInt (int64 (input .NumberOfNodes ), 10 ),
141
- "viper-config" : "/tmp/viper-config.yaml" ,
142
142
}
143
143
ginkgoArgs := buildArgs (ginkgoVars , "-" )
144
144
e2eArgs := buildArgs (e2eVars , "--" )
@@ -147,15 +147,14 @@ func Run(ctx context.Context, input RunInput) error {
147
147
}
148
148
kubeConfigVolumeMount := volumeArg (tmpKubeConfigPath , "/tmp/kubeconfig" )
149
149
outputVolumeMount := volumeArg (reportDir , "/output" )
150
- viperVolumeMount := volumeArg (tmpConfigFilePath , "/tmp/viper-config.yaml" )
151
150
user , err := user .Current ()
152
151
if err != nil {
153
152
return errors .Wrap (err , "unable to determine current user" )
154
153
}
155
154
userArg := user .Uid + ":" + user .Gid
156
155
entrypointArg := "--entrypoint=/usr/local/bin/ginkgo"
157
156
networkArg := "--network=kind"
158
- e2eCmd := exec .Command ("docker" , "run" , "--user" , userArg , entrypointArg , kubeConfigVolumeMount , outputVolumeMount , viperVolumeMount , "-t" , networkArg )
157
+ e2eCmd := exec .Command ("docker" , "run" , "--user" , userArg , entrypointArg , kubeConfigVolumeMount , outputVolumeMount , "-t" , networkArg )
159
158
if len (testRepoListVolumeArgs ) > 0 {
160
159
e2eCmd .Args = append (e2eCmd .Args , testRepoListVolumeArgs ... )
161
160
}
@@ -164,13 +163,32 @@ func Run(ctx context.Context, input RunInput) error {
164
163
e2eCmd .Args = append (e2eCmd .Args , "/usr/local/bin/e2e.test" )
165
164
e2eCmd .Args = append (e2eCmd .Args , "--" )
166
165
e2eCmd .Args = append (e2eCmd .Args , e2eArgs ... )
166
+ e2eCmd .Args = append (e2eCmd .Args , config .toFlags ()... )
167
167
e2eCmd = framework .CompleteCommand (e2eCmd , "Running e2e test" , false )
168
168
if err := e2eCmd .Run (); err != nil {
169
169
return errors .Wrap (err , "Unable to run conformance tests" )
170
170
}
171
171
return framework .GatherJUnitReports (reportDir , input .ArtifactsDirectory )
172
172
}
173
173
174
+ type kubetestConfig map [string ]string
175
+
176
+ func (c kubetestConfig ) toFlags () []string {
177
+ return buildArgs (c , "-" )
178
+ }
179
+
180
+ func parseKubetestConfig (kubetestConfigFile string ) (kubetestConfig , error ) {
181
+ conf := make (kubetestConfig )
182
+ data , err := os .ReadFile (kubetestConfigFile )
183
+ if err != nil {
184
+ return nil , fmt .Errorf ("unable to read kubetest config file %s: %w" , kubetestConfigFile , err )
185
+ }
186
+ if err := yaml .Unmarshal (data , conf ); err != nil {
187
+ return nil , fmt .Errorf ("unable to parse kubetest config file %s as valid, non-nested YAML: %w" , kubetestConfigFile , err )
188
+ }
189
+ return conf , nil
190
+ }
191
+
174
192
func isUsingCIArtifactsVersion (k8sVersion string ) bool {
175
193
return strings .Contains (k8sVersion , "-" )
176
194
}
0 commit comments