@@ -26,7 +26,6 @@ import (
26
26
"k8s.io/apimachinery/pkg/fields"
27
27
api "k8s.io/kubernetes/pkg/apis/core"
28
28
"k8s.io/kubernetes/test/e2e/framework"
29
- e2elog "k8s.io/kubernetes/test/e2e/framework/log"
30
29
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
31
30
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
32
31
"k8s.io/kubernetes/test/e2e/instrumentation/logging/utils"
@@ -57,7 +56,7 @@ func newEsLogProvider(f *framework.Framework) (*esLogProvider, error) {
57
56
func (p * esLogProvider ) Init () error {
58
57
f := p .Framework
59
58
// Check for the existence of the Elasticsearch service.
60
- e2elog .Logf ("Checking the Elasticsearch service exists." )
59
+ framework .Logf ("Checking the Elasticsearch service exists." )
61
60
s := f .ClientSet .CoreV1 ().Services (api .NamespaceSystem )
62
61
// Make a few attempts to connect. This makes the test robust against
63
62
// being run as the first e2e test just after the e2e cluster has been created.
@@ -66,14 +65,14 @@ func (p *esLogProvider) Init() error {
66
65
if _ , err = s .Get ("elasticsearch-logging" , meta_v1.GetOptions {}); err == nil {
67
66
break
68
67
}
69
- e2elog .Logf ("Attempt to check for the existence of the Elasticsearch service failed after %v" , time .Since (start ))
68
+ framework .Logf ("Attempt to check for the existence of the Elasticsearch service failed after %v" , time .Since (start ))
70
69
}
71
70
if err != nil {
72
71
return err
73
72
}
74
73
75
74
// Wait for the Elasticsearch pods to enter the running state.
76
- e2elog .Logf ("Checking to make sure the Elasticsearch pods are running" )
75
+ framework .Logf ("Checking to make sure the Elasticsearch pods are running" )
77
76
labelSelector := fields .SelectorFromSet (fields .Set (map [string ]string {"k8s-app" : "elasticsearch-logging" })).String ()
78
77
options := meta_v1.ListOptions {LabelSelector : labelSelector }
79
78
pods , err := f .ClientSet .CoreV1 ().Pods (api .NamespaceSystem ).List (options )
@@ -87,15 +86,15 @@ func (p *esLogProvider) Init() error {
87
86
}
88
87
}
89
88
90
- e2elog .Logf ("Checking to make sure we are talking to an Elasticsearch service." )
89
+ framework .Logf ("Checking to make sure we are talking to an Elasticsearch service." )
91
90
// Perform a few checks to make sure this looks like an Elasticsearch cluster.
92
91
var statusCode int
93
92
err = nil
94
93
var body []byte
95
94
for start := time .Now (); time .Since (start ) < esRetryTimeout ; time .Sleep (esRetryDelay ) {
96
95
proxyRequest , errProxy := e2eservice .GetServicesProxyRequest (f .ClientSet , f .ClientSet .CoreV1 ().RESTClient ().Get ())
97
96
if errProxy != nil {
98
- e2elog .Logf ("After %v failed to get services proxy request: %v" , time .Since (start ), errProxy )
97
+ framework .Logf ("After %v failed to get services proxy request: %v" , time .Since (start ), errProxy )
99
98
continue
100
99
}
101
100
// Query against the root URL for Elasticsearch.
@@ -106,11 +105,11 @@ func (p *esLogProvider) Init() error {
106
105
response .StatusCode (& statusCode )
107
106
108
107
if err != nil {
109
- e2elog .Logf ("After %v proxy call to elasticsearch-loigging failed: %v" , time .Since (start ), err )
108
+ framework .Logf ("After %v proxy call to elasticsearch-loigging failed: %v" , time .Since (start ), err )
110
109
continue
111
110
}
112
111
if int (statusCode ) != 200 {
113
- e2elog .Logf ("After %v Elasticsearch cluster has a bad status: %v" , time .Since (start ), statusCode )
112
+ framework .Logf ("After %v Elasticsearch cluster has a bad status: %v" , time .Since (start ), statusCode )
114
113
continue
115
114
}
116
115
break
@@ -119,17 +118,17 @@ func (p *esLogProvider) Init() error {
119
118
return err
120
119
}
121
120
if int (statusCode ) != 200 {
122
- e2elog .Failf ("Elasticsearch cluster has a bad status: %v" , statusCode )
121
+ framework .Failf ("Elasticsearch cluster has a bad status: %v" , statusCode )
123
122
}
124
123
125
124
// Now assume we really are talking to an Elasticsearch instance.
126
125
// Check the cluster health.
127
- e2elog .Logf ("Checking health of Elasticsearch service." )
126
+ framework .Logf ("Checking health of Elasticsearch service." )
128
127
healthy := false
129
128
for start := time .Now (); time .Since (start ) < esRetryTimeout ; time .Sleep (esRetryDelay ) {
130
129
proxyRequest , errProxy := e2eservice .GetServicesProxyRequest (f .ClientSet , f .ClientSet .CoreV1 ().RESTClient ().Get ())
131
130
if errProxy != nil {
132
- e2elog .Logf ("After %v failed to get services proxy request: %v" , time .Since (start ), errProxy )
131
+ framework .Logf ("After %v failed to get services proxy request: %v" , time .Since (start ), errProxy )
133
132
continue
134
133
}
135
134
body , err = proxyRequest .Namespace (api .NamespaceSystem ).
@@ -143,17 +142,17 @@ func (p *esLogProvider) Init() error {
143
142
health := make (map [string ]interface {})
144
143
err := json .Unmarshal (body , & health )
145
144
if err != nil {
146
- e2elog .Logf ("Bad json response from elasticsearch: %v" , err )
145
+ framework .Logf ("Bad json response from elasticsearch: %v" , err )
147
146
continue
148
147
}
149
148
statusIntf , ok := health ["status" ]
150
149
if ! ok {
151
- e2elog .Logf ("No status field found in cluster health response: %v" , health )
150
+ framework .Logf ("No status field found in cluster health response: %v" , health )
152
151
continue
153
152
}
154
153
status := statusIntf .(string )
155
154
if status != "green" && status != "yellow" {
156
- e2elog .Logf ("Cluster health has bad status: %v" , health )
155
+ framework .Logf ("Cluster health has bad status: %v" , health )
157
156
continue
158
157
}
159
158
if err == nil && ok {
@@ -177,12 +176,12 @@ func (p *esLogProvider) ReadEntries(name string) []utils.LogEntry {
177
176
178
177
proxyRequest , errProxy := e2eservice .GetServicesProxyRequest (f .ClientSet , f .ClientSet .CoreV1 ().RESTClient ().Get ())
179
178
if errProxy != nil {
180
- e2elog .Logf ("Failed to get services proxy request: %v" , errProxy )
179
+ framework .Logf ("Failed to get services proxy request: %v" , errProxy )
181
180
return nil
182
181
}
183
182
184
183
query := fmt .Sprintf ("kubernetes.pod_name:%s AND kubernetes.namespace_name:%s" , name , f .Namespace .Name )
185
- e2elog .Logf ("Sending a search request to Elasticsearch with the following query: %s" , query )
184
+ framework .Logf ("Sending a search request to Elasticsearch with the following query: %s" , query )
186
185
187
186
// Ask Elasticsearch to return all the log lines that were tagged with the
188
187
// pod name. Ask for ten times as many log lines because duplication is possible.
@@ -194,26 +193,26 @@ func (p *esLogProvider) ReadEntries(name string) []utils.LogEntry {
194
193
Param ("size" , strconv .Itoa (searchPageSize )).
195
194
DoRaw ()
196
195
if err != nil {
197
- e2elog .Logf ("Failed to make proxy call to elasticsearch-logging: %v" , err )
196
+ framework .Logf ("Failed to make proxy call to elasticsearch-logging: %v" , err )
198
197
return nil
199
198
}
200
199
201
200
var response map [string ]interface {}
202
201
err = json .Unmarshal (body , & response )
203
202
if err != nil {
204
- e2elog .Logf ("Failed to unmarshal response: %v" , err )
203
+ framework .Logf ("Failed to unmarshal response: %v" , err )
205
204
return nil
206
205
}
207
206
208
207
hits , ok := response ["hits" ].(map [string ]interface {})
209
208
if ! ok {
210
- e2elog .Logf ("response[hits] not of the expected type: %T" , response ["hits" ])
209
+ framework .Logf ("response[hits] not of the expected type: %T" , response ["hits" ])
211
210
return nil
212
211
}
213
212
214
213
h , ok := hits ["hits" ].([]interface {})
215
214
if ! ok {
216
- e2elog .Logf ("Hits not of the expected type: %T" , hits ["hits" ])
215
+ framework .Logf ("Hits not of the expected type: %T" , hits ["hits" ])
217
216
return nil
218
217
}
219
218
@@ -222,13 +221,13 @@ func (p *esLogProvider) ReadEntries(name string) []utils.LogEntry {
222
221
for _ , e := range h {
223
222
l , ok := e .(map [string ]interface {})
224
223
if ! ok {
225
- e2elog .Logf ("Element of hit not of expected type: %T" , e )
224
+ framework .Logf ("Element of hit not of expected type: %T" , e )
226
225
continue
227
226
}
228
227
229
228
source , ok := l ["_source" ].(map [string ]interface {})
230
229
if ! ok {
231
- e2elog .Logf ("_source not of the expected type: %T" , l ["_source" ])
230
+ framework .Logf ("_source not of the expected type: %T" , l ["_source" ])
232
231
continue
233
232
}
234
233
@@ -244,7 +243,7 @@ func (p *esLogProvider) ReadEntries(name string) []utils.LogEntry {
244
243
continue
245
244
}
246
245
247
- e2elog .Logf ("Log is of unknown type, got %v, want string or object in field 'log'" , source )
246
+ framework .Logf ("Log is of unknown type, got %v, want string or object in field 'log'" , source )
248
247
}
249
248
250
249
return entries
0 commit comments