23
23
import oracle .weblogic .domain .Model ;
24
24
import oracle .weblogic .domain .ServerPod ;
25
25
import oracle .weblogic .kubernetes .actions .impl .LoggingExporterParams ;
26
+ import oracle .weblogic .kubernetes .actions .impl .OperatorParams ;
27
+ import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
26
28
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
27
29
import oracle .weblogic .kubernetes .annotations .Namespaces ;
28
30
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
40
42
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
41
43
import static oracle .weblogic .kubernetes .TestConstants .COPY_WLS_LOGGING_EXPORTER_FILE_NAME ;
42
44
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
43
- import static oracle .weblogic .kubernetes .TestConstants .ELASTICSEARCH_HOST ;
44
45
import static oracle .weblogic .kubernetes .TestConstants .ELASTICSEARCH_HTTPS_PORT ;
45
46
import static oracle .weblogic .kubernetes .TestConstants .ELASTICSEARCH_HTTP_PORT ;
46
47
import static oracle .weblogic .kubernetes .TestConstants .ELASTICSEARCH_IMAGE ;
47
48
import static oracle .weblogic .kubernetes .TestConstants .ELASTICSEARCH_NAME ;
48
- import static oracle .weblogic .kubernetes .TestConstants .ELKSTACK_NAMESPACE ;
49
49
import static oracle .weblogic .kubernetes .TestConstants .KIBANA_IMAGE ;
50
50
import static oracle .weblogic .kubernetes .TestConstants .KIBANA_INDEX_KEY ;
51
51
import static oracle .weblogic .kubernetes .TestConstants .KIBANA_NAME ;
54
54
import static oracle .weblogic .kubernetes .TestConstants .LOGSTASH_INDEX_KEY ;
55
55
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_NAME ;
56
56
import static oracle .weblogic .kubernetes .TestConstants .OCIR_SECRET_NAME ;
57
+ import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_CHART_DIR ;
57
58
import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_RELEASE_NAME ;
58
59
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_INDEX_KEY ;
59
60
import static oracle .weblogic .kubernetes .TestConstants .WLS_LOGGING_EXPORTER_YAML_FILE_NAME ;
64
65
import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
65
66
import static oracle .weblogic .kubernetes .actions .TestActions .execCommand ;
66
67
import static oracle .weblogic .kubernetes .actions .TestActions .getOperatorPodName ;
68
+ import static oracle .weblogic .kubernetes .assertions .TestAssertions .operatorIsReady ;
67
69
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
68
70
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
71
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
69
72
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
70
73
import static oracle .weblogic .kubernetes .utils .ImageUtils .createMiiImageAndVerify ;
71
74
import static oracle .weblogic .kubernetes .utils .ImageUtils .createOcirRepoSecret ;
77
80
import static oracle .weblogic .kubernetes .utils .LoggingExporterUtils .uninstallAndVerifyKibana ;
78
81
import static oracle .weblogic .kubernetes .utils .LoggingExporterUtils .verifyLoggingExporterReady ;
79
82
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
83
+ import static oracle .weblogic .kubernetes .utils .OperatorUtils .upgradeAndVerifyOperator ;
84
+ import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
80
85
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
81
86
import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
82
87
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
@@ -133,6 +138,9 @@ class ItElasticLogging {
133
138
private static LoggingExporterParams kibanaParams = null ;
134
139
private static LoggingFacade logger = null ;
135
140
141
+ static String elasticSearchHost ;
142
+ static String elasticSearchNs ;
143
+
136
144
private static String k8sExecCmdPrefix ;
137
145
private static Map <String , String > testVarMap ;
138
146
@@ -145,7 +153,7 @@ class ItElasticLogging {
145
153
* JUnit engine parameter resolution mechanism.
146
154
*/
147
155
@ BeforeAll
148
- public static void init (@ Namespaces (2 ) List <String > namespaces ) {
156
+ public static void init (@ Namespaces (3 ) List <String > namespaces ) {
149
157
logger = getLogger ();
150
158
// create standard, reusable retry/backoff policy
151
159
withStandardRetryPolicy = with ().pollDelay (2 , SECONDS )
@@ -163,24 +171,28 @@ public static void init(@Namespaces(2) List<String> namespaces) {
163
171
domainNamespace = namespaces .get (1 );
164
172
165
173
// install and verify Elasticsearch
174
+ elasticSearchNs = namespaces .get (2 );
166
175
logger .info ("install and verify Elasticsearch" );
167
- elasticsearchParams = assertDoesNotThrow (() -> installAndVerifyElasticsearch (),
176
+ elasticsearchParams = assertDoesNotThrow (() -> installAndVerifyElasticsearch (elasticSearchNs ),
168
177
String .format ("Failed to install Elasticsearch" ));
169
178
assertTrue (elasticsearchParams != null , "Failed to install Elasticsearch" );
170
179
171
180
// install and verify Kibana
172
181
logger .info ("install and verify Kibana" );
173
- kibanaParams = assertDoesNotThrow (() -> installAndVerifyKibana (),
182
+ kibanaParams = assertDoesNotThrow (() -> installAndVerifyKibana (elasticSearchNs ),
174
183
String .format ("Failed to install Kibana" ));
175
184
assertTrue (kibanaParams != null , "Failed to install Kibana" );
176
185
177
186
// install and verify Operator
178
187
installAndVerifyOperator (opNamespace , opNamespace + "-sa" ,
179
188
false , 0 , true , domainNamespace );
180
189
190
+ String operatorPodName = assertDoesNotThrow (
191
+ () -> getOperatorPodName (OPERATOR_RELEASE_NAME , opNamespace ));
192
+
181
193
// install WebLogic Logging Exporter
182
194
installAndVerifyWlsLoggingExporter (managedServerFilter ,
183
- wlsLoggingExporterYamlFileLoc );
195
+ wlsLoggingExporterYamlFileLoc , elasticSearchNs );
184
196
185
197
// create and verify WebLogic domain image using model in image with model files
186
198
String imageName = createAndVerifyDomainImage ();
@@ -190,18 +202,43 @@ public static void init(@Namespaces(2) List<String> namespaces) {
190
202
createAndVerifyDomain (imageName );
191
203
192
204
testVarMap = new HashMap <String , String >();
193
-
194
- StringBuffer elasticsearchUrlBuff =
195
- new StringBuffer ("curl http://" )
196
- .append (ELASTICSEARCH_HOST )
197
- .append (":" )
198
- .append (ELASTICSEARCH_HTTP_PORT );
199
- k8sExecCmdPrefix = elasticsearchUrlBuff .toString ();
205
+ elasticSearchHost = "elasticsearch." + elasticSearchNs + ".svc.cluster.local" ;
206
+
207
+ // upgrade to latest operator
208
+ HelmParams upgradeHelmParams = new HelmParams ()
209
+ .releaseName (OPERATOR_RELEASE_NAME )
210
+ .namespace (opNamespace )
211
+ .chartDir (OPERATOR_CHART_DIR );
212
+
213
+ // build operator chart values
214
+ OperatorParams opParams = new OperatorParams ()
215
+ .helmParams (upgradeHelmParams )
216
+ .elkIntegrationEnabled (true )
217
+ .elasticSearchHost (elasticSearchHost );
218
+
219
+ assertTrue (upgradeAndVerifyOperator (opNamespace , opParams ),
220
+ String .format ("Failed to upgrade operator in namespace %s" , opNamespace ));
221
+
222
+ // check operator pod is not running
223
+ checkPodDoesNotExist (operatorPodName , null , opNamespace );
224
+
225
+ // wait for the operator to be ready
226
+ logger .info ("Wait for the operator pod is ready in namespace {0}" , opNamespace );
227
+ testUntil (
228
+ assertDoesNotThrow (() -> operatorIsReady (opNamespace ),
229
+ "operatorIsReady failed with ApiException" ),
230
+ logger ,
231
+ "operator to be running in namespace {0}" ,
232
+ opNamespace );
233
+
234
+ String elasticsearchUrlBuff
235
+ = "curl http://" + elasticSearchHost + ":" + ELASTICSEARCH_HTTP_PORT ;
236
+ k8sExecCmdPrefix = elasticsearchUrlBuff ;
200
237
logger .info ("Elasticsearch URL {0}" , k8sExecCmdPrefix );
201
238
202
239
// Verify that ELK Stack is ready to use
203
- testVarMap = verifyLoggingExporterReady (opNamespace , null , LOGSTASH_INDEX_KEY );
204
- Map <String , String > kibanaMap = verifyLoggingExporterReady (opNamespace , null , KIBANA_INDEX_KEY );
240
+ testVarMap = verifyLoggingExporterReady (opNamespace , elasticSearchNs , null , LOGSTASH_INDEX_KEY );
241
+ Map <String , String > kibanaMap = verifyLoggingExporterReady (opNamespace , elasticSearchNs , null , KIBANA_INDEX_KEY );
205
242
206
243
// merge testVarMap and kibanaMap
207
244
testVarMap .putAll (kibanaMap );
@@ -222,13 +259,13 @@ void tearDown() {
222
259
.elasticsearchImage (ELASTICSEARCH_IMAGE )
223
260
.elasticsearchHttpPort (ELASTICSEARCH_HTTP_PORT )
224
261
.elasticsearchHttpsPort (ELASTICSEARCH_HTTPS_PORT )
225
- .loggingExporterNamespace (ELKSTACK_NAMESPACE );
262
+ .loggingExporterNamespace (elasticSearchNs );
226
263
227
264
kibanaParams = new LoggingExporterParams ()
228
265
.kibanaName (KIBANA_NAME )
229
266
.kibanaImage (KIBANA_IMAGE )
230
267
.kibanaType (KIBANA_TYPE )
231
- .loggingExporterNamespace (ELKSTACK_NAMESPACE )
268
+ .loggingExporterNamespace (elasticSearchNs )
232
269
.kibanaContainerPort (KIBANA_PORT );
233
270
234
271
logger .info ("Uninstall Elasticsearch pod" );
@@ -298,7 +335,7 @@ void testWebLogicLogSearch() {
298
335
@ Test
299
336
@ DisplayName ("Use Elasticsearch Search APIs to query WebLogic log info in WLS server pod and verify" )
300
337
void testWlsLoggingExporter () throws Exception {
301
- Map <String , String > wlsMap = verifyLoggingExporterReady (opNamespace , null , WEBLOGIC_INDEX_KEY );
338
+ Map <String , String > wlsMap = verifyLoggingExporterReady (opNamespace , elasticSearchNs , null , WEBLOGIC_INDEX_KEY );
302
339
// merge testVarMap and wlsMap
303
340
testVarMap .putAll (wlsMap );
304
341
@@ -367,7 +404,7 @@ private static void createAndVerifyDomain(String miiImage) {
367
404
// create secret for admin credentials
368
405
logger .info ("Create secret for admin credentials" );
369
406
String adminSecretName = "weblogic-credentials" ;
370
- assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName ,
407
+ assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName ,
371
408
domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ),
372
409
String .format ("create secret for admin credentials failed for %s" , adminSecretName ));
373
410
0 commit comments