@@ -30,34 +30,11 @@ import (
30
30
_ "k8s.io/kubernetes/test/e2e/lifecycle"
31
31
)
32
32
33
- // copied directly from github.com/openshift/origin/cmd/openshift-tests/provider.go
34
- // and github.com/openshift/origin/test/extended/util/test.go
35
- func initializeTestFramework (provider string ) error {
36
- providerInfo := & ClusterConfiguration {}
37
- if err := json .Unmarshal ([]byte (provider ), & providerInfo ); err != nil {
38
- return fmt .Errorf ("provider must be a JSON object with the 'type' key at a minimum: %v" , err )
39
- }
40
- if len (providerInfo .ProviderName ) == 0 {
41
- return fmt .Errorf ("provider must be a JSON object with the 'type' key" )
42
- }
43
- config := & ClusterConfiguration {}
44
- if err := json .Unmarshal ([]byte (provider ), config ); err != nil {
45
- return fmt .Errorf ("provider must decode into the ClusterConfig object: %v" , err )
46
- }
47
-
33
+ // Initialize a good enough test context for generating e2e tests,
34
+ // so they can be listed and filtered.
35
+ func initializeCommonTestFramework () error {
48
36
// update testContext with loaded config
49
37
testContext := & framework .TestContext
50
- testContext .Provider = config .ProviderName
51
- testContext .CloudConfig = framework.CloudConfig {
52
- ProjectID : config .ProjectID ,
53
- Region : config .Region ,
54
- Zone : config .Zone ,
55
- Zones : config .Zones ,
56
- NumNodes : config .NumNodes ,
57
- MultiMaster : config .MultiMaster ,
58
- MultiZone : config .MultiZone ,
59
- ConfigFile : config .ConfigFile ,
60
- }
61
38
testContext .AllowedNotReadyNodes = - 1
62
39
testContext .MinStartupPods = - 1
63
40
testContext .MaxNodesToGather = 0
@@ -91,6 +68,45 @@ func initializeTestFramework(provider string) error {
91
68
testContext .NodeOSDistro = "custom"
92
69
testContext .MasterOSDistro = "custom"
93
70
71
+ return nil
72
+ }
73
+
74
+ // Finish test context initialization. This is called before a real test is going to run.
75
+ // It parses the cloud provider and file other parameters that are needed for running
76
+ // already generated tests.
77
+ func updateTestFrameworkForTests (provider string ) error {
78
+ providerInfo := & ClusterConfiguration {}
79
+ if err := json .Unmarshal ([]byte (provider ), & providerInfo ); err != nil {
80
+ return fmt .Errorf ("provider must be a JSON object with the 'type' key at a minimum: %v" , err )
81
+ }
82
+ if len (providerInfo .ProviderName ) == 0 {
83
+ return fmt .Errorf ("provider must be a JSON object with the 'type' key" )
84
+ }
85
+ config := & ClusterConfiguration {}
86
+ if err := json .Unmarshal ([]byte (provider ), config ); err != nil {
87
+ return fmt .Errorf ("provider must decode into the ClusterConfig object: %v" , err )
88
+ }
89
+
90
+ // update testContext with loaded config
91
+ testContext := & framework .TestContext
92
+ testContext .Provider = config .ProviderName
93
+ testContext .CloudConfig = framework.CloudConfig {
94
+ ProjectID : config .ProjectID ,
95
+ Region : config .Region ,
96
+ Zone : config .Zone ,
97
+ Zones : config .Zones ,
98
+ NumNodes : config .NumNodes ,
99
+ MultiMaster : config .MultiMaster ,
100
+ MultiZone : config .MultiZone ,
101
+ ConfigFile : config .ConfigFile ,
102
+ }
103
+
104
+ // these constants are taken from kube e2e and used by tests
105
+ testContext .IPFamily = "ipv4"
106
+ if config .HasIPv6 && ! config .HasIPv4 {
107
+ testContext .IPFamily = "ipv6"
108
+ }
109
+
94
110
// load and set the host variable for kubectl
95
111
clientConfig := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (& clientcmd.ClientConfigLoadingRules {ExplicitPath : testContext .KubeConfig }, & clientcmd.ConfigOverrides {})
96
112
cfg , err := clientConfig .ClientConfig ()
@@ -108,13 +124,6 @@ func initializeTestFramework(provider string) error {
108
124
109
125
framework .AfterReadingAllFlags (testContext )
110
126
testContext .DumpLogsOnFailure = true
111
-
112
- // these constants are taken from kube e2e and used by tests
113
- testContext .IPFamily = "ipv4"
114
- if config .HasIPv6 && ! config .HasIPv4 {
115
- testContext .IPFamily = "ipv6"
116
- }
117
-
118
127
testContext .ReportDir = os .Getenv ("TEST_JUNIT_DIR" )
119
128
120
129
return nil
0 commit comments